diff --git a/authentication.go b/authentication.go index f1839f5..1809fc5 100644 --- a/authentication.go +++ b/authentication.go @@ -28,8 +28,12 @@ type Authentication struct { OIDCIssuerURL string `json:"OIDC_issuer_url,omitempty"` // OIDCClientID holds the value of the "OIDC_client_id" field. OIDCClientID string `json:"OIDC_client_id,omitempty"` - // OIDCRole holds the value of the "OIDC_role" field. - OIDCRole string `json:"OIDC_role,omitempty"` + // OIDC role/group that maps to admin (e.g. openuem_admin) + OIDCRoleAdmin string `json:"OIDC_role_admin,omitempty"` + // OIDC role/group that maps to operator (e.g. openuem_operator) + OIDCRoleOperator string `json:"OIDC_role_operator,omitempty"` + // OIDC role/group that maps to user (e.g. openuem_user) + OIDCRoleUser string `json:"OIDC_role_user,omitempty"` // OIDCCookieEncriptionKey holds the value of the "OIDC_cookie_encription_key" field. OIDCCookieEncriptionKey string `json:"OIDC_cookie_encription_key,omitempty"` // OIDCKeycloakPublicKey holds the value of the "OIDC_keycloak_public_key" field. @@ -52,7 +56,7 @@ func (*Authentication) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case authentication.FieldID: values[i] = new(sql.NullInt64) - case authentication.FieldOIDCProvider, authentication.FieldOIDCIssuerURL, authentication.FieldOIDCClientID, authentication.FieldOIDCRole, authentication.FieldOIDCCookieEncriptionKey, authentication.FieldOIDCKeycloakPublicKey: + case authentication.FieldOIDCProvider, authentication.FieldOIDCIssuerURL, authentication.FieldOIDCClientID, authentication.FieldOIDCRoleAdmin, authentication.FieldOIDCRoleOperator, authentication.FieldOIDCRoleUser, authentication.FieldOIDCCookieEncriptionKey, authentication.FieldOIDCKeycloakPublicKey: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -111,11 +115,23 @@ func (a *Authentication) assignValues(columns []string, values []any) error { } else if value.Valid { a.OIDCClientID = value.String } - case authentication.FieldOIDCRole: + case authentication.FieldOIDCRoleAdmin: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field OIDC_role", values[i]) + return fmt.Errorf("unexpected type %T for field OIDC_role_admin", values[i]) } else if value.Valid { - a.OIDCRole = value.String + a.OIDCRoleAdmin = value.String + } + case authentication.FieldOIDCRoleOperator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field OIDC_role_operator", values[i]) + } else if value.Valid { + a.OIDCRoleOperator = value.String + } + case authentication.FieldOIDCRoleUser: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field OIDC_role_user", values[i]) + } else if value.Valid { + a.OIDCRoleUser = value.String } case authentication.FieldOIDCCookieEncriptionKey: if value, ok := values[i].(*sql.NullString); !ok { @@ -201,8 +217,14 @@ func (a *Authentication) String() string { builder.WriteString("OIDC_client_id=") builder.WriteString(a.OIDCClientID) builder.WriteString(", ") - builder.WriteString("OIDC_role=") - builder.WriteString(a.OIDCRole) + builder.WriteString("OIDC_role_admin=") + builder.WriteString(a.OIDCRoleAdmin) + builder.WriteString(", ") + builder.WriteString("OIDC_role_operator=") + builder.WriteString(a.OIDCRoleOperator) + builder.WriteString(", ") + builder.WriteString("OIDC_role_user=") + builder.WriteString(a.OIDCRoleUser) builder.WriteString(", ") builder.WriteString("OIDC_cookie_encription_key=") builder.WriteString(a.OIDCCookieEncriptionKey) diff --git a/authentication/authentication.go b/authentication/authentication.go index 130169d..ceaacc0 100644 --- a/authentication/authentication.go +++ b/authentication/authentication.go @@ -23,8 +23,12 @@ const ( FieldOIDCIssuerURL = "oidc_issuer_url" // FieldOIDCClientID holds the string denoting the oidc_client_id field in the database. FieldOIDCClientID = "oidc_client_id" - // FieldOIDCRole holds the string denoting the oidc_role field in the database. - FieldOIDCRole = "oidc_role" + // FieldOIDCRoleAdmin holds the string denoting the oidc_role_admin field in the database. + FieldOIDCRoleAdmin = "oidc_role_admin" + // FieldOIDCRoleOperator holds the string denoting the oidc_role_operator field in the database. + FieldOIDCRoleOperator = "oidc_role_operator" + // FieldOIDCRoleUser holds the string denoting the oidc_role_user field in the database. + FieldOIDCRoleUser = "oidc_role_user" // FieldOIDCCookieEncriptionKey holds the string denoting the oidc_cookie_encription_key field in the database. FieldOIDCCookieEncriptionKey = "oidc_cookie_encription_key" // FieldOIDCKeycloakPublicKey holds the string denoting the oidc_keycloak_public_key field in the database. @@ -48,7 +52,9 @@ var Columns = []string{ FieldOIDCProvider, FieldOIDCIssuerURL, FieldOIDCClientID, - FieldOIDCRole, + FieldOIDCRoleAdmin, + FieldOIDCRoleOperator, + FieldOIDCRoleUser, FieldOIDCCookieEncriptionKey, FieldOIDCKeycloakPublicKey, FieldOIDCAutoCreateAccount, @@ -79,8 +85,12 @@ var ( DefaultOIDCIssuerURL string // DefaultOIDCClientID holds the default value on creation for the "OIDC_client_id" field. DefaultOIDCClientID string - // DefaultOIDCRole holds the default value on creation for the "OIDC_role" field. - DefaultOIDCRole string + // DefaultOIDCRoleAdmin holds the default value on creation for the "OIDC_role_admin" field. + DefaultOIDCRoleAdmin string + // DefaultOIDCRoleOperator holds the default value on creation for the "OIDC_role_operator" field. + DefaultOIDCRoleOperator string + // DefaultOIDCRoleUser holds the default value on creation for the "OIDC_role_user" field. + DefaultOIDCRoleUser string // DefaultOIDCCookieEncriptionKey holds the default value on creation for the "OIDC_cookie_encription_key" field. DefaultOIDCCookieEncriptionKey string // DefaultOIDCKeycloakPublicKey holds the default value on creation for the "OIDC_keycloak_public_key" field. @@ -131,9 +141,19 @@ func ByOIDCClientID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOIDCClientID, opts...).ToFunc() } -// ByOIDCRole orders the results by the OIDC_role field. -func ByOIDCRole(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldOIDCRole, opts...).ToFunc() +// ByOIDCRoleAdmin orders the results by the OIDC_role_admin field. +func ByOIDCRoleAdmin(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOIDCRoleAdmin, opts...).ToFunc() +} + +// ByOIDCRoleOperator orders the results by the OIDC_role_operator field. +func ByOIDCRoleOperator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOIDCRoleOperator, opts...).ToFunc() +} + +// ByOIDCRoleUser orders the results by the OIDC_role_user field. +func ByOIDCRoleUser(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOIDCRoleUser, opts...).ToFunc() } // ByOIDCCookieEncriptionKey orders the results by the OIDC_cookie_encription_key field. diff --git a/authentication/where.go b/authentication/where.go index 230b3a6..c2f42b3 100644 --- a/authentication/where.go +++ b/authentication/where.go @@ -82,9 +82,19 @@ func OIDCClientID(v string) predicate.Authentication { return predicate.Authentication(sql.FieldEQ(FieldOIDCClientID, v)) } -// OIDCRole applies equality check predicate on the "OIDC_role" field. It's identical to OIDCRoleEQ. -func OIDCRole(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldEQ(FieldOIDCRole, v)) +// OIDCRoleAdmin applies equality check predicate on the "OIDC_role_admin" field. It's identical to OIDCRoleAdminEQ. +func OIDCRoleAdmin(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEQ(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleOperator applies equality check predicate on the "OIDC_role_operator" field. It's identical to OIDCRoleOperatorEQ. +func OIDCRoleOperator(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEQ(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleUser applies equality check predicate on the "OIDC_role_user" field. It's identical to OIDCRoleUserEQ. +func OIDCRoleUser(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEQ(FieldOIDCRoleUser, v)) } // OIDCCookieEncriptionKey applies equality check predicate on the "OIDC_cookie_encription_key" field. It's identical to OIDCCookieEncriptionKeyEQ. @@ -397,79 +407,229 @@ func OIDCClientIDContainsFold(v string) predicate.Authentication { return predicate.Authentication(sql.FieldContainsFold(FieldOIDCClientID, v)) } -// OIDCRoleEQ applies the EQ predicate on the "OIDC_role" field. -func OIDCRoleEQ(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldEQ(FieldOIDCRole, v)) +// OIDCRoleAdminEQ applies the EQ predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminEQ(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEQ(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminNEQ applies the NEQ predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminNEQ(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldNEQ(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminIn applies the In predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminIn(vs ...string) predicate.Authentication { + return predicate.Authentication(sql.FieldIn(FieldOIDCRoleAdmin, vs...)) +} + +// OIDCRoleAdminNotIn applies the NotIn predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminNotIn(vs ...string) predicate.Authentication { + return predicate.Authentication(sql.FieldNotIn(FieldOIDCRoleAdmin, vs...)) +} + +// OIDCRoleAdminGT applies the GT predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminGT(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldGT(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminGTE applies the GTE predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminGTE(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldGTE(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminLT applies the LT predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminLT(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldLT(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminLTE applies the LTE predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminLTE(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldLTE(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminContains applies the Contains predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminContains(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldContains(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminHasPrefix applies the HasPrefix predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminHasPrefix(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldHasPrefix(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminHasSuffix applies the HasSuffix predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminHasSuffix(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldHasSuffix(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminIsNil applies the IsNil predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminIsNil() predicate.Authentication { + return predicate.Authentication(sql.FieldIsNull(FieldOIDCRoleAdmin)) +} + +// OIDCRoleAdminNotNil applies the NotNil predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminNotNil() predicate.Authentication { + return predicate.Authentication(sql.FieldNotNull(FieldOIDCRoleAdmin)) +} + +// OIDCRoleAdminEqualFold applies the EqualFold predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminEqualFold(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEqualFold(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleAdminContainsFold applies the ContainsFold predicate on the "OIDC_role_admin" field. +func OIDCRoleAdminContainsFold(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldContainsFold(FieldOIDCRoleAdmin, v)) +} + +// OIDCRoleOperatorEQ applies the EQ predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorEQ(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEQ(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorNEQ applies the NEQ predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorNEQ(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldNEQ(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorIn applies the In predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorIn(vs ...string) predicate.Authentication { + return predicate.Authentication(sql.FieldIn(FieldOIDCRoleOperator, vs...)) +} + +// OIDCRoleOperatorNotIn applies the NotIn predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorNotIn(vs ...string) predicate.Authentication { + return predicate.Authentication(sql.FieldNotIn(FieldOIDCRoleOperator, vs...)) +} + +// OIDCRoleOperatorGT applies the GT predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorGT(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldGT(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorGTE applies the GTE predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorGTE(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldGTE(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorLT applies the LT predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorLT(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldLT(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorLTE applies the LTE predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorLTE(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldLTE(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorContains applies the Contains predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorContains(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldContains(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorHasPrefix applies the HasPrefix predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorHasPrefix(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldHasPrefix(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorHasSuffix applies the HasSuffix predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorHasSuffix(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldHasSuffix(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorIsNil applies the IsNil predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorIsNil() predicate.Authentication { + return predicate.Authentication(sql.FieldIsNull(FieldOIDCRoleOperator)) +} + +// OIDCRoleOperatorNotNil applies the NotNil predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorNotNil() predicate.Authentication { + return predicate.Authentication(sql.FieldNotNull(FieldOIDCRoleOperator)) +} + +// OIDCRoleOperatorEqualFold applies the EqualFold predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorEqualFold(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEqualFold(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleOperatorContainsFold applies the ContainsFold predicate on the "OIDC_role_operator" field. +func OIDCRoleOperatorContainsFold(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldContainsFold(FieldOIDCRoleOperator, v)) +} + +// OIDCRoleUserEQ applies the EQ predicate on the "OIDC_role_user" field. +func OIDCRoleUserEQ(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEQ(FieldOIDCRoleUser, v)) } -// OIDCRoleNEQ applies the NEQ predicate on the "OIDC_role" field. -func OIDCRoleNEQ(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldNEQ(FieldOIDCRole, v)) +// OIDCRoleUserNEQ applies the NEQ predicate on the "OIDC_role_user" field. +func OIDCRoleUserNEQ(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldNEQ(FieldOIDCRoleUser, v)) } -// OIDCRoleIn applies the In predicate on the "OIDC_role" field. -func OIDCRoleIn(vs ...string) predicate.Authentication { - return predicate.Authentication(sql.FieldIn(FieldOIDCRole, vs...)) +// OIDCRoleUserIn applies the In predicate on the "OIDC_role_user" field. +func OIDCRoleUserIn(vs ...string) predicate.Authentication { + return predicate.Authentication(sql.FieldIn(FieldOIDCRoleUser, vs...)) } -// OIDCRoleNotIn applies the NotIn predicate on the "OIDC_role" field. -func OIDCRoleNotIn(vs ...string) predicate.Authentication { - return predicate.Authentication(sql.FieldNotIn(FieldOIDCRole, vs...)) +// OIDCRoleUserNotIn applies the NotIn predicate on the "OIDC_role_user" field. +func OIDCRoleUserNotIn(vs ...string) predicate.Authentication { + return predicate.Authentication(sql.FieldNotIn(FieldOIDCRoleUser, vs...)) } -// OIDCRoleGT applies the GT predicate on the "OIDC_role" field. -func OIDCRoleGT(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldGT(FieldOIDCRole, v)) +// OIDCRoleUserGT applies the GT predicate on the "OIDC_role_user" field. +func OIDCRoleUserGT(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldGT(FieldOIDCRoleUser, v)) } -// OIDCRoleGTE applies the GTE predicate on the "OIDC_role" field. -func OIDCRoleGTE(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldGTE(FieldOIDCRole, v)) +// OIDCRoleUserGTE applies the GTE predicate on the "OIDC_role_user" field. +func OIDCRoleUserGTE(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldGTE(FieldOIDCRoleUser, v)) } -// OIDCRoleLT applies the LT predicate on the "OIDC_role" field. -func OIDCRoleLT(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldLT(FieldOIDCRole, v)) +// OIDCRoleUserLT applies the LT predicate on the "OIDC_role_user" field. +func OIDCRoleUserLT(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldLT(FieldOIDCRoleUser, v)) } -// OIDCRoleLTE applies the LTE predicate on the "OIDC_role" field. -func OIDCRoleLTE(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldLTE(FieldOIDCRole, v)) +// OIDCRoleUserLTE applies the LTE predicate on the "OIDC_role_user" field. +func OIDCRoleUserLTE(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldLTE(FieldOIDCRoleUser, v)) } -// OIDCRoleContains applies the Contains predicate on the "OIDC_role" field. -func OIDCRoleContains(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldContains(FieldOIDCRole, v)) +// OIDCRoleUserContains applies the Contains predicate on the "OIDC_role_user" field. +func OIDCRoleUserContains(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldContains(FieldOIDCRoleUser, v)) } -// OIDCRoleHasPrefix applies the HasPrefix predicate on the "OIDC_role" field. -func OIDCRoleHasPrefix(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldHasPrefix(FieldOIDCRole, v)) +// OIDCRoleUserHasPrefix applies the HasPrefix predicate on the "OIDC_role_user" field. +func OIDCRoleUserHasPrefix(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldHasPrefix(FieldOIDCRoleUser, v)) } -// OIDCRoleHasSuffix applies the HasSuffix predicate on the "OIDC_role" field. -func OIDCRoleHasSuffix(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldHasSuffix(FieldOIDCRole, v)) +// OIDCRoleUserHasSuffix applies the HasSuffix predicate on the "OIDC_role_user" field. +func OIDCRoleUserHasSuffix(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldHasSuffix(FieldOIDCRoleUser, v)) } -// OIDCRoleIsNil applies the IsNil predicate on the "OIDC_role" field. -func OIDCRoleIsNil() predicate.Authentication { - return predicate.Authentication(sql.FieldIsNull(FieldOIDCRole)) +// OIDCRoleUserIsNil applies the IsNil predicate on the "OIDC_role_user" field. +func OIDCRoleUserIsNil() predicate.Authentication { + return predicate.Authentication(sql.FieldIsNull(FieldOIDCRoleUser)) } -// OIDCRoleNotNil applies the NotNil predicate on the "OIDC_role" field. -func OIDCRoleNotNil() predicate.Authentication { - return predicate.Authentication(sql.FieldNotNull(FieldOIDCRole)) +// OIDCRoleUserNotNil applies the NotNil predicate on the "OIDC_role_user" field. +func OIDCRoleUserNotNil() predicate.Authentication { + return predicate.Authentication(sql.FieldNotNull(FieldOIDCRoleUser)) } -// OIDCRoleEqualFold applies the EqualFold predicate on the "OIDC_role" field. -func OIDCRoleEqualFold(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldEqualFold(FieldOIDCRole, v)) +// OIDCRoleUserEqualFold applies the EqualFold predicate on the "OIDC_role_user" field. +func OIDCRoleUserEqualFold(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldEqualFold(FieldOIDCRoleUser, v)) } -// OIDCRoleContainsFold applies the ContainsFold predicate on the "OIDC_role" field. -func OIDCRoleContainsFold(v string) predicate.Authentication { - return predicate.Authentication(sql.FieldContainsFold(FieldOIDCRole, v)) +// OIDCRoleUserContainsFold applies the ContainsFold predicate on the "OIDC_role_user" field. +func OIDCRoleUserContainsFold(v string) predicate.Authentication { + return predicate.Authentication(sql.FieldContainsFold(FieldOIDCRoleUser, v)) } // OIDCCookieEncriptionKeyEQ applies the EQ predicate on the "OIDC_cookie_encription_key" field. diff --git a/authentication_create.go b/authentication_create.go index 5ef43b1..7d5a133 100644 --- a/authentication_create.go +++ b/authentication_create.go @@ -105,16 +105,44 @@ func (ac *AuthenticationCreate) SetNillableOIDCClientID(s *string) *Authenticati return ac } -// SetOIDCRole sets the "OIDC_role" field. -func (ac *AuthenticationCreate) SetOIDCRole(s string) *AuthenticationCreate { - ac.mutation.SetOIDCRole(s) +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (ac *AuthenticationCreate) SetOIDCRoleAdmin(s string) *AuthenticationCreate { + ac.mutation.SetOIDCRoleAdmin(s) return ac } -// SetNillableOIDCRole sets the "OIDC_role" field if the given value is not nil. -func (ac *AuthenticationCreate) SetNillableOIDCRole(s *string) *AuthenticationCreate { +// SetNillableOIDCRoleAdmin sets the "OIDC_role_admin" field if the given value is not nil. +func (ac *AuthenticationCreate) SetNillableOIDCRoleAdmin(s *string) *AuthenticationCreate { if s != nil { - ac.SetOIDCRole(*s) + ac.SetOIDCRoleAdmin(*s) + } + return ac +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (ac *AuthenticationCreate) SetOIDCRoleOperator(s string) *AuthenticationCreate { + ac.mutation.SetOIDCRoleOperator(s) + return ac +} + +// SetNillableOIDCRoleOperator sets the "OIDC_role_operator" field if the given value is not nil. +func (ac *AuthenticationCreate) SetNillableOIDCRoleOperator(s *string) *AuthenticationCreate { + if s != nil { + ac.SetOIDCRoleOperator(*s) + } + return ac +} + +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (ac *AuthenticationCreate) SetOIDCRoleUser(s string) *AuthenticationCreate { + ac.mutation.SetOIDCRoleUser(s) + return ac +} + +// SetNillableOIDCRoleUser sets the "OIDC_role_user" field if the given value is not nil. +func (ac *AuthenticationCreate) SetNillableOIDCRoleUser(s *string) *AuthenticationCreate { + if s != nil { + ac.SetOIDCRoleUser(*s) } return ac } @@ -248,9 +276,17 @@ func (ac *AuthenticationCreate) defaults() { v := authentication.DefaultOIDCClientID ac.mutation.SetOIDCClientID(v) } - if _, ok := ac.mutation.OIDCRole(); !ok { - v := authentication.DefaultOIDCRole - ac.mutation.SetOIDCRole(v) + if _, ok := ac.mutation.OIDCRoleAdmin(); !ok { + v := authentication.DefaultOIDCRoleAdmin + ac.mutation.SetOIDCRoleAdmin(v) + } + if _, ok := ac.mutation.OIDCRoleOperator(); !ok { + v := authentication.DefaultOIDCRoleOperator + ac.mutation.SetOIDCRoleOperator(v) + } + if _, ok := ac.mutation.OIDCRoleUser(); !ok { + v := authentication.DefaultOIDCRoleUser + ac.mutation.SetOIDCRoleUser(v) } if _, ok := ac.mutation.OIDCCookieEncriptionKey(); !ok { v := authentication.DefaultOIDCCookieEncriptionKey @@ -327,9 +363,17 @@ func (ac *AuthenticationCreate) createSpec() (*Authentication, *sqlgraph.CreateS _spec.SetField(authentication.FieldOIDCClientID, field.TypeString, value) _node.OIDCClientID = value } - if value, ok := ac.mutation.OIDCRole(); ok { - _spec.SetField(authentication.FieldOIDCRole, field.TypeString, value) - _node.OIDCRole = value + if value, ok := ac.mutation.OIDCRoleAdmin(); ok { + _spec.SetField(authentication.FieldOIDCRoleAdmin, field.TypeString, value) + _node.OIDCRoleAdmin = value + } + if value, ok := ac.mutation.OIDCRoleOperator(); ok { + _spec.SetField(authentication.FieldOIDCRoleOperator, field.TypeString, value) + _node.OIDCRoleOperator = value + } + if value, ok := ac.mutation.OIDCRoleUser(); ok { + _spec.SetField(authentication.FieldOIDCRoleUser, field.TypeString, value) + _node.OIDCRoleUser = value } if value, ok := ac.mutation.OIDCCookieEncriptionKey(); ok { _spec.SetField(authentication.FieldOIDCCookieEncriptionKey, field.TypeString, value) @@ -511,21 +555,57 @@ func (u *AuthenticationUpsert) ClearOIDCClientID() *AuthenticationUpsert { return u } -// SetOIDCRole sets the "OIDC_role" field. -func (u *AuthenticationUpsert) SetOIDCRole(v string) *AuthenticationUpsert { - u.Set(authentication.FieldOIDCRole, v) +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (u *AuthenticationUpsert) SetOIDCRoleAdmin(v string) *AuthenticationUpsert { + u.Set(authentication.FieldOIDCRoleAdmin, v) return u } -// UpdateOIDCRole sets the "OIDC_role" field to the value that was provided on create. -func (u *AuthenticationUpsert) UpdateOIDCRole() *AuthenticationUpsert { - u.SetExcluded(authentication.FieldOIDCRole) +// UpdateOIDCRoleAdmin sets the "OIDC_role_admin" field to the value that was provided on create. +func (u *AuthenticationUpsert) UpdateOIDCRoleAdmin() *AuthenticationUpsert { + u.SetExcluded(authentication.FieldOIDCRoleAdmin) return u } -// ClearOIDCRole clears the value of the "OIDC_role" field. -func (u *AuthenticationUpsert) ClearOIDCRole() *AuthenticationUpsert { - u.SetNull(authentication.FieldOIDCRole) +// ClearOIDCRoleAdmin clears the value of the "OIDC_role_admin" field. +func (u *AuthenticationUpsert) ClearOIDCRoleAdmin() *AuthenticationUpsert { + u.SetNull(authentication.FieldOIDCRoleAdmin) + return u +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (u *AuthenticationUpsert) SetOIDCRoleOperator(v string) *AuthenticationUpsert { + u.Set(authentication.FieldOIDCRoleOperator, v) + return u +} + +// UpdateOIDCRoleOperator sets the "OIDC_role_operator" field to the value that was provided on create. +func (u *AuthenticationUpsert) UpdateOIDCRoleOperator() *AuthenticationUpsert { + u.SetExcluded(authentication.FieldOIDCRoleOperator) + return u +} + +// ClearOIDCRoleOperator clears the value of the "OIDC_role_operator" field. +func (u *AuthenticationUpsert) ClearOIDCRoleOperator() *AuthenticationUpsert { + u.SetNull(authentication.FieldOIDCRoleOperator) + return u +} + +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (u *AuthenticationUpsert) SetOIDCRoleUser(v string) *AuthenticationUpsert { + u.Set(authentication.FieldOIDCRoleUser, v) + return u +} + +// UpdateOIDCRoleUser sets the "OIDC_role_user" field to the value that was provided on create. +func (u *AuthenticationUpsert) UpdateOIDCRoleUser() *AuthenticationUpsert { + u.SetExcluded(authentication.FieldOIDCRoleUser) + return u +} + +// ClearOIDCRoleUser clears the value of the "OIDC_role_user" field. +func (u *AuthenticationUpsert) ClearOIDCRoleUser() *AuthenticationUpsert { + u.SetNull(authentication.FieldOIDCRoleUser) return u } @@ -785,24 +865,66 @@ func (u *AuthenticationUpsertOne) ClearOIDCClientID() *AuthenticationUpsertOne { }) } -// SetOIDCRole sets the "OIDC_role" field. -func (u *AuthenticationUpsertOne) SetOIDCRole(v string) *AuthenticationUpsertOne { +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (u *AuthenticationUpsertOne) SetOIDCRoleAdmin(v string) *AuthenticationUpsertOne { + return u.Update(func(s *AuthenticationUpsert) { + s.SetOIDCRoleAdmin(v) + }) +} + +// UpdateOIDCRoleAdmin sets the "OIDC_role_admin" field to the value that was provided on create. +func (u *AuthenticationUpsertOne) UpdateOIDCRoleAdmin() *AuthenticationUpsertOne { + return u.Update(func(s *AuthenticationUpsert) { + s.UpdateOIDCRoleAdmin() + }) +} + +// ClearOIDCRoleAdmin clears the value of the "OIDC_role_admin" field. +func (u *AuthenticationUpsertOne) ClearOIDCRoleAdmin() *AuthenticationUpsertOne { + return u.Update(func(s *AuthenticationUpsert) { + s.ClearOIDCRoleAdmin() + }) +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (u *AuthenticationUpsertOne) SetOIDCRoleOperator(v string) *AuthenticationUpsertOne { + return u.Update(func(s *AuthenticationUpsert) { + s.SetOIDCRoleOperator(v) + }) +} + +// UpdateOIDCRoleOperator sets the "OIDC_role_operator" field to the value that was provided on create. +func (u *AuthenticationUpsertOne) UpdateOIDCRoleOperator() *AuthenticationUpsertOne { return u.Update(func(s *AuthenticationUpsert) { - s.SetOIDCRole(v) + s.UpdateOIDCRoleOperator() }) } -// UpdateOIDCRole sets the "OIDC_role" field to the value that was provided on create. -func (u *AuthenticationUpsertOne) UpdateOIDCRole() *AuthenticationUpsertOne { +// ClearOIDCRoleOperator clears the value of the "OIDC_role_operator" field. +func (u *AuthenticationUpsertOne) ClearOIDCRoleOperator() *AuthenticationUpsertOne { return u.Update(func(s *AuthenticationUpsert) { - s.UpdateOIDCRole() + s.ClearOIDCRoleOperator() }) } -// ClearOIDCRole clears the value of the "OIDC_role" field. -func (u *AuthenticationUpsertOne) ClearOIDCRole() *AuthenticationUpsertOne { +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (u *AuthenticationUpsertOne) SetOIDCRoleUser(v string) *AuthenticationUpsertOne { return u.Update(func(s *AuthenticationUpsert) { - s.ClearOIDCRole() + s.SetOIDCRoleUser(v) + }) +} + +// UpdateOIDCRoleUser sets the "OIDC_role_user" field to the value that was provided on create. +func (u *AuthenticationUpsertOne) UpdateOIDCRoleUser() *AuthenticationUpsertOne { + return u.Update(func(s *AuthenticationUpsert) { + s.UpdateOIDCRoleUser() + }) +} + +// ClearOIDCRoleUser clears the value of the "OIDC_role_user" field. +func (u *AuthenticationUpsertOne) ClearOIDCRoleUser() *AuthenticationUpsertOne { + return u.Update(func(s *AuthenticationUpsert) { + s.ClearOIDCRoleUser() }) } @@ -1241,24 +1363,66 @@ func (u *AuthenticationUpsertBulk) ClearOIDCClientID() *AuthenticationUpsertBulk }) } -// SetOIDCRole sets the "OIDC_role" field. -func (u *AuthenticationUpsertBulk) SetOIDCRole(v string) *AuthenticationUpsertBulk { +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (u *AuthenticationUpsertBulk) SetOIDCRoleAdmin(v string) *AuthenticationUpsertBulk { + return u.Update(func(s *AuthenticationUpsert) { + s.SetOIDCRoleAdmin(v) + }) +} + +// UpdateOIDCRoleAdmin sets the "OIDC_role_admin" field to the value that was provided on create. +func (u *AuthenticationUpsertBulk) UpdateOIDCRoleAdmin() *AuthenticationUpsertBulk { + return u.Update(func(s *AuthenticationUpsert) { + s.UpdateOIDCRoleAdmin() + }) +} + +// ClearOIDCRoleAdmin clears the value of the "OIDC_role_admin" field. +func (u *AuthenticationUpsertBulk) ClearOIDCRoleAdmin() *AuthenticationUpsertBulk { + return u.Update(func(s *AuthenticationUpsert) { + s.ClearOIDCRoleAdmin() + }) +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (u *AuthenticationUpsertBulk) SetOIDCRoleOperator(v string) *AuthenticationUpsertBulk { + return u.Update(func(s *AuthenticationUpsert) { + s.SetOIDCRoleOperator(v) + }) +} + +// UpdateOIDCRoleOperator sets the "OIDC_role_operator" field to the value that was provided on create. +func (u *AuthenticationUpsertBulk) UpdateOIDCRoleOperator() *AuthenticationUpsertBulk { + return u.Update(func(s *AuthenticationUpsert) { + s.UpdateOIDCRoleOperator() + }) +} + +// ClearOIDCRoleOperator clears the value of the "OIDC_role_operator" field. +func (u *AuthenticationUpsertBulk) ClearOIDCRoleOperator() *AuthenticationUpsertBulk { + return u.Update(func(s *AuthenticationUpsert) { + s.ClearOIDCRoleOperator() + }) +} + +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (u *AuthenticationUpsertBulk) SetOIDCRoleUser(v string) *AuthenticationUpsertBulk { return u.Update(func(s *AuthenticationUpsert) { - s.SetOIDCRole(v) + s.SetOIDCRoleUser(v) }) } -// UpdateOIDCRole sets the "OIDC_role" field to the value that was provided on create. -func (u *AuthenticationUpsertBulk) UpdateOIDCRole() *AuthenticationUpsertBulk { +// UpdateOIDCRoleUser sets the "OIDC_role_user" field to the value that was provided on create. +func (u *AuthenticationUpsertBulk) UpdateOIDCRoleUser() *AuthenticationUpsertBulk { return u.Update(func(s *AuthenticationUpsert) { - s.UpdateOIDCRole() + s.UpdateOIDCRoleUser() }) } -// ClearOIDCRole clears the value of the "OIDC_role" field. -func (u *AuthenticationUpsertBulk) ClearOIDCRole() *AuthenticationUpsertBulk { +// ClearOIDCRoleUser clears the value of the "OIDC_role_user" field. +func (u *AuthenticationUpsertBulk) ClearOIDCRoleUser() *AuthenticationUpsertBulk { return u.Update(func(s *AuthenticationUpsert) { - s.ClearOIDCRole() + s.ClearOIDCRoleUser() }) } diff --git a/authentication_update.go b/authentication_update.go index df2e254..84abf4d 100644 --- a/authentication_update.go +++ b/authentication_update.go @@ -148,23 +148,63 @@ func (au *AuthenticationUpdate) ClearOIDCClientID() *AuthenticationUpdate { return au } -// SetOIDCRole sets the "OIDC_role" field. -func (au *AuthenticationUpdate) SetOIDCRole(s string) *AuthenticationUpdate { - au.mutation.SetOIDCRole(s) +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (au *AuthenticationUpdate) SetOIDCRoleAdmin(s string) *AuthenticationUpdate { + au.mutation.SetOIDCRoleAdmin(s) return au } -// SetNillableOIDCRole sets the "OIDC_role" field if the given value is not nil. -func (au *AuthenticationUpdate) SetNillableOIDCRole(s *string) *AuthenticationUpdate { +// SetNillableOIDCRoleAdmin sets the "OIDC_role_admin" field if the given value is not nil. +func (au *AuthenticationUpdate) SetNillableOIDCRoleAdmin(s *string) *AuthenticationUpdate { if s != nil { - au.SetOIDCRole(*s) + au.SetOIDCRoleAdmin(*s) } return au } -// ClearOIDCRole clears the value of the "OIDC_role" field. -func (au *AuthenticationUpdate) ClearOIDCRole() *AuthenticationUpdate { - au.mutation.ClearOIDCRole() +// ClearOIDCRoleAdmin clears the value of the "OIDC_role_admin" field. +func (au *AuthenticationUpdate) ClearOIDCRoleAdmin() *AuthenticationUpdate { + au.mutation.ClearOIDCRoleAdmin() + return au +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (au *AuthenticationUpdate) SetOIDCRoleOperator(s string) *AuthenticationUpdate { + au.mutation.SetOIDCRoleOperator(s) + return au +} + +// SetNillableOIDCRoleOperator sets the "OIDC_role_operator" field if the given value is not nil. +func (au *AuthenticationUpdate) SetNillableOIDCRoleOperator(s *string) *AuthenticationUpdate { + if s != nil { + au.SetOIDCRoleOperator(*s) + } + return au +} + +// ClearOIDCRoleOperator clears the value of the "OIDC_role_operator" field. +func (au *AuthenticationUpdate) ClearOIDCRoleOperator() *AuthenticationUpdate { + au.mutation.ClearOIDCRoleOperator() + return au +} + +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (au *AuthenticationUpdate) SetOIDCRoleUser(s string) *AuthenticationUpdate { + au.mutation.SetOIDCRoleUser(s) + return au +} + +// SetNillableOIDCRoleUser sets the "OIDC_role_user" field if the given value is not nil. +func (au *AuthenticationUpdate) SetNillableOIDCRoleUser(s *string) *AuthenticationUpdate { + if s != nil { + au.SetOIDCRoleUser(*s) + } + return au +} + +// ClearOIDCRoleUser clears the value of the "OIDC_role_user" field. +func (au *AuthenticationUpdate) ClearOIDCRoleUser() *AuthenticationUpdate { + au.mutation.ClearOIDCRoleUser() return au } @@ -351,11 +391,23 @@ func (au *AuthenticationUpdate) sqlSave(ctx context.Context) (n int, err error) if au.mutation.OIDCClientIDCleared() { _spec.ClearField(authentication.FieldOIDCClientID, field.TypeString) } - if value, ok := au.mutation.OIDCRole(); ok { - _spec.SetField(authentication.FieldOIDCRole, field.TypeString, value) + if value, ok := au.mutation.OIDCRoleAdmin(); ok { + _spec.SetField(authentication.FieldOIDCRoleAdmin, field.TypeString, value) + } + if au.mutation.OIDCRoleAdminCleared() { + _spec.ClearField(authentication.FieldOIDCRoleAdmin, field.TypeString) + } + if value, ok := au.mutation.OIDCRoleOperator(); ok { + _spec.SetField(authentication.FieldOIDCRoleOperator, field.TypeString, value) + } + if au.mutation.OIDCRoleOperatorCleared() { + _spec.ClearField(authentication.FieldOIDCRoleOperator, field.TypeString) + } + if value, ok := au.mutation.OIDCRoleUser(); ok { + _spec.SetField(authentication.FieldOIDCRoleUser, field.TypeString, value) } - if au.mutation.OIDCRoleCleared() { - _spec.ClearField(authentication.FieldOIDCRole, field.TypeString) + if au.mutation.OIDCRoleUserCleared() { + _spec.ClearField(authentication.FieldOIDCRoleUser, field.TypeString) } if value, ok := au.mutation.OIDCCookieEncriptionKey(); ok { _spec.SetField(authentication.FieldOIDCCookieEncriptionKey, field.TypeString, value) @@ -529,23 +581,63 @@ func (auo *AuthenticationUpdateOne) ClearOIDCClientID() *AuthenticationUpdateOne return auo } -// SetOIDCRole sets the "OIDC_role" field. -func (auo *AuthenticationUpdateOne) SetOIDCRole(s string) *AuthenticationUpdateOne { - auo.mutation.SetOIDCRole(s) +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (auo *AuthenticationUpdateOne) SetOIDCRoleAdmin(s string) *AuthenticationUpdateOne { + auo.mutation.SetOIDCRoleAdmin(s) return auo } -// SetNillableOIDCRole sets the "OIDC_role" field if the given value is not nil. -func (auo *AuthenticationUpdateOne) SetNillableOIDCRole(s *string) *AuthenticationUpdateOne { +// SetNillableOIDCRoleAdmin sets the "OIDC_role_admin" field if the given value is not nil. +func (auo *AuthenticationUpdateOne) SetNillableOIDCRoleAdmin(s *string) *AuthenticationUpdateOne { if s != nil { - auo.SetOIDCRole(*s) + auo.SetOIDCRoleAdmin(*s) } return auo } -// ClearOIDCRole clears the value of the "OIDC_role" field. -func (auo *AuthenticationUpdateOne) ClearOIDCRole() *AuthenticationUpdateOne { - auo.mutation.ClearOIDCRole() +// ClearOIDCRoleAdmin clears the value of the "OIDC_role_admin" field. +func (auo *AuthenticationUpdateOne) ClearOIDCRoleAdmin() *AuthenticationUpdateOne { + auo.mutation.ClearOIDCRoleAdmin() + return auo +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (auo *AuthenticationUpdateOne) SetOIDCRoleOperator(s string) *AuthenticationUpdateOne { + auo.mutation.SetOIDCRoleOperator(s) + return auo +} + +// SetNillableOIDCRoleOperator sets the "OIDC_role_operator" field if the given value is not nil. +func (auo *AuthenticationUpdateOne) SetNillableOIDCRoleOperator(s *string) *AuthenticationUpdateOne { + if s != nil { + auo.SetOIDCRoleOperator(*s) + } + return auo +} + +// ClearOIDCRoleOperator clears the value of the "OIDC_role_operator" field. +func (auo *AuthenticationUpdateOne) ClearOIDCRoleOperator() *AuthenticationUpdateOne { + auo.mutation.ClearOIDCRoleOperator() + return auo +} + +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (auo *AuthenticationUpdateOne) SetOIDCRoleUser(s string) *AuthenticationUpdateOne { + auo.mutation.SetOIDCRoleUser(s) + return auo +} + +// SetNillableOIDCRoleUser sets the "OIDC_role_user" field if the given value is not nil. +func (auo *AuthenticationUpdateOne) SetNillableOIDCRoleUser(s *string) *AuthenticationUpdateOne { + if s != nil { + auo.SetOIDCRoleUser(*s) + } + return auo +} + +// ClearOIDCRoleUser clears the value of the "OIDC_role_user" field. +func (auo *AuthenticationUpdateOne) ClearOIDCRoleUser() *AuthenticationUpdateOne { + auo.mutation.ClearOIDCRoleUser() return auo } @@ -762,11 +854,23 @@ func (auo *AuthenticationUpdateOne) sqlSave(ctx context.Context) (_node *Authent if auo.mutation.OIDCClientIDCleared() { _spec.ClearField(authentication.FieldOIDCClientID, field.TypeString) } - if value, ok := auo.mutation.OIDCRole(); ok { - _spec.SetField(authentication.FieldOIDCRole, field.TypeString, value) + if value, ok := auo.mutation.OIDCRoleAdmin(); ok { + _spec.SetField(authentication.FieldOIDCRoleAdmin, field.TypeString, value) + } + if auo.mutation.OIDCRoleAdminCleared() { + _spec.ClearField(authentication.FieldOIDCRoleAdmin, field.TypeString) + } + if value, ok := auo.mutation.OIDCRoleOperator(); ok { + _spec.SetField(authentication.FieldOIDCRoleOperator, field.TypeString, value) + } + if auo.mutation.OIDCRoleOperatorCleared() { + _spec.ClearField(authentication.FieldOIDCRoleOperator, field.TypeString) + } + if value, ok := auo.mutation.OIDCRoleUser(); ok { + _spec.SetField(authentication.FieldOIDCRoleUser, field.TypeString, value) } - if auo.mutation.OIDCRoleCleared() { - _spec.ClearField(authentication.FieldOIDCRole, field.TypeString) + if auo.mutation.OIDCRoleUserCleared() { + _spec.ClearField(authentication.FieldOIDCRoleUser, field.TypeString) } if value, ok := auo.mutation.OIDCCookieEncriptionKey(); ok { _spec.SetField(authentication.FieldOIDCCookieEncriptionKey, field.TypeString, value) diff --git a/branding.go b/branding.go new file mode 100644 index 0000000..02918fb --- /dev/null +++ b/branding.go @@ -0,0 +1,193 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/open-uem/ent/branding" +) + +// Branding is the model entity for the Branding schema. +type Branding struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Logo as base64 data URL + LogoLight string `json:"logo_light,omitempty"` + // Favicon as base64 data URL + LogoSmall string `json:"logo_small,omitempty"` + // Primary brand color (hex) + PrimaryColor string `json:"primary_color,omitempty"` + // Custom product name to display + ProductName string `json:"product_name,omitempty"` + // Login page background image as base64 data URL + LoginBackgroundImage string `json:"login_background_image,omitempty"` + // Welcome text shown on login page + LoginWelcomeText string `json:"login_welcome_text,omitempty"` + // Whether to display the version number in the header + ShowVersion bool `json:"show_version,omitempty"` + // URL or email for bug reports + BugReportLink string `json:"bug_report_link,omitempty"` + // URL or email for help/documentation + HelpLink string `json:"help_link,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Branding) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case branding.FieldShowVersion: + values[i] = new(sql.NullBool) + case branding.FieldID: + values[i] = new(sql.NullInt64) + case branding.FieldLogoLight, branding.FieldLogoSmall, branding.FieldPrimaryColor, branding.FieldProductName, branding.FieldLoginBackgroundImage, branding.FieldLoginWelcomeText, branding.FieldBugReportLink, branding.FieldHelpLink: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Branding fields. +func (b *Branding) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case branding.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + b.ID = int(value.Int64) + case branding.FieldLogoLight: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field logo_light", values[i]) + } else if value.Valid { + b.LogoLight = value.String + } + case branding.FieldLogoSmall: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field logo_small", values[i]) + } else if value.Valid { + b.LogoSmall = value.String + } + case branding.FieldPrimaryColor: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field primary_color", values[i]) + } else if value.Valid { + b.PrimaryColor = value.String + } + case branding.FieldProductName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field product_name", values[i]) + } else if value.Valid { + b.ProductName = value.String + } + case branding.FieldLoginBackgroundImage: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_background_image", values[i]) + } else if value.Valid { + b.LoginBackgroundImage = value.String + } + case branding.FieldLoginWelcomeText: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_welcome_text", values[i]) + } else if value.Valid { + b.LoginWelcomeText = value.String + } + case branding.FieldShowVersion: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field show_version", values[i]) + } else if value.Valid { + b.ShowVersion = value.Bool + } + case branding.FieldBugReportLink: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field bug_report_link", values[i]) + } else if value.Valid { + b.BugReportLink = value.String + } + case branding.FieldHelpLink: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field help_link", values[i]) + } else if value.Valid { + b.HelpLink = value.String + } + default: + b.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Branding. +// This includes values selected through modifiers, order, etc. +func (b *Branding) Value(name string) (ent.Value, error) { + return b.selectValues.Get(name) +} + +// Update returns a builder for updating this Branding. +// Note that you need to call Branding.Unwrap() before calling this method if this Branding +// was returned from a transaction, and the transaction was committed or rolled back. +func (b *Branding) Update() *BrandingUpdateOne { + return NewBrandingClient(b.config).UpdateOne(b) +} + +// Unwrap unwraps the Branding entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (b *Branding) Unwrap() *Branding { + _tx, ok := b.config.driver.(*txDriver) + if !ok { + panic("ent: Branding is not a transactional entity") + } + b.config.driver = _tx.drv + return b +} + +// String implements the fmt.Stringer. +func (b *Branding) String() string { + var builder strings.Builder + builder.WriteString("Branding(") + builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) + builder.WriteString("logo_light=") + builder.WriteString(b.LogoLight) + builder.WriteString(", ") + builder.WriteString("logo_small=") + builder.WriteString(b.LogoSmall) + builder.WriteString(", ") + builder.WriteString("primary_color=") + builder.WriteString(b.PrimaryColor) + builder.WriteString(", ") + builder.WriteString("product_name=") + builder.WriteString(b.ProductName) + builder.WriteString(", ") + builder.WriteString("login_background_image=") + builder.WriteString(b.LoginBackgroundImage) + builder.WriteString(", ") + builder.WriteString("login_welcome_text=") + builder.WriteString(b.LoginWelcomeText) + builder.WriteString(", ") + builder.WriteString("show_version=") + builder.WriteString(fmt.Sprintf("%v", b.ShowVersion)) + builder.WriteString(", ") + builder.WriteString("bug_report_link=") + builder.WriteString(b.BugReportLink) + builder.WriteString(", ") + builder.WriteString("help_link=") + builder.WriteString(b.HelpLink) + builder.WriteByte(')') + return builder.String() +} + +// Brandings is a parsable slice of Branding. +type Brandings []*Branding diff --git a/branding/branding.go b/branding/branding.go new file mode 100644 index 0000000..ef4fcee --- /dev/null +++ b/branding/branding.go @@ -0,0 +1,124 @@ +// Code generated by ent, DO NOT EDIT. + +package branding + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the branding type in the database. + Label = "branding" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldLogoLight holds the string denoting the logo_light field in the database. + FieldLogoLight = "logo_light" + // FieldLogoSmall holds the string denoting the logo_small field in the database. + FieldLogoSmall = "logo_small" + // FieldPrimaryColor holds the string denoting the primary_color field in the database. + FieldPrimaryColor = "primary_color" + // FieldProductName holds the string denoting the product_name field in the database. + FieldProductName = "product_name" + // FieldLoginBackgroundImage holds the string denoting the login_background_image field in the database. + FieldLoginBackgroundImage = "login_background_image" + // FieldLoginWelcomeText holds the string denoting the login_welcome_text field in the database. + FieldLoginWelcomeText = "login_welcome_text" + // FieldShowVersion holds the string denoting the show_version field in the database. + FieldShowVersion = "show_version" + // FieldBugReportLink holds the string denoting the bug_report_link field in the database. + FieldBugReportLink = "bug_report_link" + // FieldHelpLink holds the string denoting the help_link field in the database. + FieldHelpLink = "help_link" + // Table holds the table name of the branding in the database. + Table = "brandings" +) + +// Columns holds all SQL columns for branding fields. +var Columns = []string{ + FieldID, + FieldLogoLight, + FieldLogoSmall, + FieldPrimaryColor, + FieldProductName, + FieldLoginBackgroundImage, + FieldLoginWelcomeText, + FieldShowVersion, + FieldBugReportLink, + FieldHelpLink, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultPrimaryColor holds the default value on creation for the "primary_color" field. + DefaultPrimaryColor string + // DefaultProductName holds the default value on creation for the "product_name" field. + DefaultProductName string + // DefaultShowVersion holds the default value on creation for the "show_version" field. + DefaultShowVersion bool + // DefaultBugReportLink holds the default value on creation for the "bug_report_link" field. + DefaultBugReportLink string + // DefaultHelpLink holds the default value on creation for the "help_link" field. + DefaultHelpLink string +) + +// OrderOption defines the ordering options for the Branding queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByLogoLight orders the results by the logo_light field. +func ByLogoLight(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLogoLight, opts...).ToFunc() +} + +// ByLogoSmall orders the results by the logo_small field. +func ByLogoSmall(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLogoSmall, opts...).ToFunc() +} + +// ByPrimaryColor orders the results by the primary_color field. +func ByPrimaryColor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPrimaryColor, opts...).ToFunc() +} + +// ByProductName orders the results by the product_name field. +func ByProductName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProductName, opts...).ToFunc() +} + +// ByLoginBackgroundImage orders the results by the login_background_image field. +func ByLoginBackgroundImage(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginBackgroundImage, opts...).ToFunc() +} + +// ByLoginWelcomeText orders the results by the login_welcome_text field. +func ByLoginWelcomeText(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginWelcomeText, opts...).ToFunc() +} + +// ByShowVersion orders the results by the show_version field. +func ByShowVersion(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldShowVersion, opts...).ToFunc() +} + +// ByBugReportLink orders the results by the bug_report_link field. +func ByBugReportLink(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBugReportLink, opts...).ToFunc() +} + +// ByHelpLink orders the results by the help_link field. +func ByHelpLink(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHelpLink, opts...).ToFunc() +} diff --git a/branding/where.go b/branding/where.go new file mode 100644 index 0000000..f39b3db --- /dev/null +++ b/branding/where.go @@ -0,0 +1,733 @@ +// Code generated by ent, DO NOT EDIT. + +package branding + +import ( + "entgo.io/ent/dialect/sql" + "github.com/open-uem/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldID, id)) +} + +// LogoLight applies equality check predicate on the "logo_light" field. It's identical to LogoLightEQ. +func LogoLight(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLogoLight, v)) +} + +// LogoSmall applies equality check predicate on the "logo_small" field. It's identical to LogoSmallEQ. +func LogoSmall(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLogoSmall, v)) +} + +// PrimaryColor applies equality check predicate on the "primary_color" field. It's identical to PrimaryColorEQ. +func PrimaryColor(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldPrimaryColor, v)) +} + +// ProductName applies equality check predicate on the "product_name" field. It's identical to ProductNameEQ. +func ProductName(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldProductName, v)) +} + +// LoginBackgroundImage applies equality check predicate on the "login_background_image" field. It's identical to LoginBackgroundImageEQ. +func LoginBackgroundImage(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLoginBackgroundImage, v)) +} + +// LoginWelcomeText applies equality check predicate on the "login_welcome_text" field. It's identical to LoginWelcomeTextEQ. +func LoginWelcomeText(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLoginWelcomeText, v)) +} + +// ShowVersion applies equality check predicate on the "show_version" field. It's identical to ShowVersionEQ. +func ShowVersion(v bool) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldShowVersion, v)) +} + +// BugReportLink applies equality check predicate on the "bug_report_link" field. It's identical to BugReportLinkEQ. +func BugReportLink(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldBugReportLink, v)) +} + +// HelpLink applies equality check predicate on the "help_link" field. It's identical to HelpLinkEQ. +func HelpLink(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldHelpLink, v)) +} + +// LogoLightEQ applies the EQ predicate on the "logo_light" field. +func LogoLightEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLogoLight, v)) +} + +// LogoLightNEQ applies the NEQ predicate on the "logo_light" field. +func LogoLightNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldLogoLight, v)) +} + +// LogoLightIn applies the In predicate on the "logo_light" field. +func LogoLightIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldLogoLight, vs...)) +} + +// LogoLightNotIn applies the NotIn predicate on the "logo_light" field. +func LogoLightNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldLogoLight, vs...)) +} + +// LogoLightGT applies the GT predicate on the "logo_light" field. +func LogoLightGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldLogoLight, v)) +} + +// LogoLightGTE applies the GTE predicate on the "logo_light" field. +func LogoLightGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldLogoLight, v)) +} + +// LogoLightLT applies the LT predicate on the "logo_light" field. +func LogoLightLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldLogoLight, v)) +} + +// LogoLightLTE applies the LTE predicate on the "logo_light" field. +func LogoLightLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldLogoLight, v)) +} + +// LogoLightContains applies the Contains predicate on the "logo_light" field. +func LogoLightContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldLogoLight, v)) +} + +// LogoLightHasPrefix applies the HasPrefix predicate on the "logo_light" field. +func LogoLightHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldLogoLight, v)) +} + +// LogoLightHasSuffix applies the HasSuffix predicate on the "logo_light" field. +func LogoLightHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldLogoLight, v)) +} + +// LogoLightIsNil applies the IsNil predicate on the "logo_light" field. +func LogoLightIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldLogoLight)) +} + +// LogoLightNotNil applies the NotNil predicate on the "logo_light" field. +func LogoLightNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldLogoLight)) +} + +// LogoLightEqualFold applies the EqualFold predicate on the "logo_light" field. +func LogoLightEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldLogoLight, v)) +} + +// LogoLightContainsFold applies the ContainsFold predicate on the "logo_light" field. +func LogoLightContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldLogoLight, v)) +} + +// LogoSmallEQ applies the EQ predicate on the "logo_small" field. +func LogoSmallEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLogoSmall, v)) +} + +// LogoSmallNEQ applies the NEQ predicate on the "logo_small" field. +func LogoSmallNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldLogoSmall, v)) +} + +// LogoSmallIn applies the In predicate on the "logo_small" field. +func LogoSmallIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldLogoSmall, vs...)) +} + +// LogoSmallNotIn applies the NotIn predicate on the "logo_small" field. +func LogoSmallNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldLogoSmall, vs...)) +} + +// LogoSmallGT applies the GT predicate on the "logo_small" field. +func LogoSmallGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldLogoSmall, v)) +} + +// LogoSmallGTE applies the GTE predicate on the "logo_small" field. +func LogoSmallGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldLogoSmall, v)) +} + +// LogoSmallLT applies the LT predicate on the "logo_small" field. +func LogoSmallLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldLogoSmall, v)) +} + +// LogoSmallLTE applies the LTE predicate on the "logo_small" field. +func LogoSmallLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldLogoSmall, v)) +} + +// LogoSmallContains applies the Contains predicate on the "logo_small" field. +func LogoSmallContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldLogoSmall, v)) +} + +// LogoSmallHasPrefix applies the HasPrefix predicate on the "logo_small" field. +func LogoSmallHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldLogoSmall, v)) +} + +// LogoSmallHasSuffix applies the HasSuffix predicate on the "logo_small" field. +func LogoSmallHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldLogoSmall, v)) +} + +// LogoSmallIsNil applies the IsNil predicate on the "logo_small" field. +func LogoSmallIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldLogoSmall)) +} + +// LogoSmallNotNil applies the NotNil predicate on the "logo_small" field. +func LogoSmallNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldLogoSmall)) +} + +// LogoSmallEqualFold applies the EqualFold predicate on the "logo_small" field. +func LogoSmallEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldLogoSmall, v)) +} + +// LogoSmallContainsFold applies the ContainsFold predicate on the "logo_small" field. +func LogoSmallContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldLogoSmall, v)) +} + +// PrimaryColorEQ applies the EQ predicate on the "primary_color" field. +func PrimaryColorEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldPrimaryColor, v)) +} + +// PrimaryColorNEQ applies the NEQ predicate on the "primary_color" field. +func PrimaryColorNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldPrimaryColor, v)) +} + +// PrimaryColorIn applies the In predicate on the "primary_color" field. +func PrimaryColorIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldPrimaryColor, vs...)) +} + +// PrimaryColorNotIn applies the NotIn predicate on the "primary_color" field. +func PrimaryColorNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldPrimaryColor, vs...)) +} + +// PrimaryColorGT applies the GT predicate on the "primary_color" field. +func PrimaryColorGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldPrimaryColor, v)) +} + +// PrimaryColorGTE applies the GTE predicate on the "primary_color" field. +func PrimaryColorGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldPrimaryColor, v)) +} + +// PrimaryColorLT applies the LT predicate on the "primary_color" field. +func PrimaryColorLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldPrimaryColor, v)) +} + +// PrimaryColorLTE applies the LTE predicate on the "primary_color" field. +func PrimaryColorLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldPrimaryColor, v)) +} + +// PrimaryColorContains applies the Contains predicate on the "primary_color" field. +func PrimaryColorContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldPrimaryColor, v)) +} + +// PrimaryColorHasPrefix applies the HasPrefix predicate on the "primary_color" field. +func PrimaryColorHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldPrimaryColor, v)) +} + +// PrimaryColorHasSuffix applies the HasSuffix predicate on the "primary_color" field. +func PrimaryColorHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldPrimaryColor, v)) +} + +// PrimaryColorIsNil applies the IsNil predicate on the "primary_color" field. +func PrimaryColorIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldPrimaryColor)) +} + +// PrimaryColorNotNil applies the NotNil predicate on the "primary_color" field. +func PrimaryColorNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldPrimaryColor)) +} + +// PrimaryColorEqualFold applies the EqualFold predicate on the "primary_color" field. +func PrimaryColorEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldPrimaryColor, v)) +} + +// PrimaryColorContainsFold applies the ContainsFold predicate on the "primary_color" field. +func PrimaryColorContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldPrimaryColor, v)) +} + +// ProductNameEQ applies the EQ predicate on the "product_name" field. +func ProductNameEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldProductName, v)) +} + +// ProductNameNEQ applies the NEQ predicate on the "product_name" field. +func ProductNameNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldProductName, v)) +} + +// ProductNameIn applies the In predicate on the "product_name" field. +func ProductNameIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldProductName, vs...)) +} + +// ProductNameNotIn applies the NotIn predicate on the "product_name" field. +func ProductNameNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldProductName, vs...)) +} + +// ProductNameGT applies the GT predicate on the "product_name" field. +func ProductNameGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldProductName, v)) +} + +// ProductNameGTE applies the GTE predicate on the "product_name" field. +func ProductNameGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldProductName, v)) +} + +// ProductNameLT applies the LT predicate on the "product_name" field. +func ProductNameLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldProductName, v)) +} + +// ProductNameLTE applies the LTE predicate on the "product_name" field. +func ProductNameLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldProductName, v)) +} + +// ProductNameContains applies the Contains predicate on the "product_name" field. +func ProductNameContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldProductName, v)) +} + +// ProductNameHasPrefix applies the HasPrefix predicate on the "product_name" field. +func ProductNameHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldProductName, v)) +} + +// ProductNameHasSuffix applies the HasSuffix predicate on the "product_name" field. +func ProductNameHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldProductName, v)) +} + +// ProductNameIsNil applies the IsNil predicate on the "product_name" field. +func ProductNameIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldProductName)) +} + +// ProductNameNotNil applies the NotNil predicate on the "product_name" field. +func ProductNameNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldProductName)) +} + +// ProductNameEqualFold applies the EqualFold predicate on the "product_name" field. +func ProductNameEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldProductName, v)) +} + +// ProductNameContainsFold applies the ContainsFold predicate on the "product_name" field. +func ProductNameContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldProductName, v)) +} + +// LoginBackgroundImageEQ applies the EQ predicate on the "login_background_image" field. +func LoginBackgroundImageEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageNEQ applies the NEQ predicate on the "login_background_image" field. +func LoginBackgroundImageNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageIn applies the In predicate on the "login_background_image" field. +func LoginBackgroundImageIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldLoginBackgroundImage, vs...)) +} + +// LoginBackgroundImageNotIn applies the NotIn predicate on the "login_background_image" field. +func LoginBackgroundImageNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldLoginBackgroundImage, vs...)) +} + +// LoginBackgroundImageGT applies the GT predicate on the "login_background_image" field. +func LoginBackgroundImageGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageGTE applies the GTE predicate on the "login_background_image" field. +func LoginBackgroundImageGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageLT applies the LT predicate on the "login_background_image" field. +func LoginBackgroundImageLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageLTE applies the LTE predicate on the "login_background_image" field. +func LoginBackgroundImageLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageContains applies the Contains predicate on the "login_background_image" field. +func LoginBackgroundImageContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageHasPrefix applies the HasPrefix predicate on the "login_background_image" field. +func LoginBackgroundImageHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageHasSuffix applies the HasSuffix predicate on the "login_background_image" field. +func LoginBackgroundImageHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageIsNil applies the IsNil predicate on the "login_background_image" field. +func LoginBackgroundImageIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldLoginBackgroundImage)) +} + +// LoginBackgroundImageNotNil applies the NotNil predicate on the "login_background_image" field. +func LoginBackgroundImageNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldLoginBackgroundImage)) +} + +// LoginBackgroundImageEqualFold applies the EqualFold predicate on the "login_background_image" field. +func LoginBackgroundImageEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldLoginBackgroundImage, v)) +} + +// LoginBackgroundImageContainsFold applies the ContainsFold predicate on the "login_background_image" field. +func LoginBackgroundImageContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldLoginBackgroundImage, v)) +} + +// LoginWelcomeTextEQ applies the EQ predicate on the "login_welcome_text" field. +func LoginWelcomeTextEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextNEQ applies the NEQ predicate on the "login_welcome_text" field. +func LoginWelcomeTextNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextIn applies the In predicate on the "login_welcome_text" field. +func LoginWelcomeTextIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldLoginWelcomeText, vs...)) +} + +// LoginWelcomeTextNotIn applies the NotIn predicate on the "login_welcome_text" field. +func LoginWelcomeTextNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldLoginWelcomeText, vs...)) +} + +// LoginWelcomeTextGT applies the GT predicate on the "login_welcome_text" field. +func LoginWelcomeTextGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextGTE applies the GTE predicate on the "login_welcome_text" field. +func LoginWelcomeTextGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextLT applies the LT predicate on the "login_welcome_text" field. +func LoginWelcomeTextLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextLTE applies the LTE predicate on the "login_welcome_text" field. +func LoginWelcomeTextLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextContains applies the Contains predicate on the "login_welcome_text" field. +func LoginWelcomeTextContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextHasPrefix applies the HasPrefix predicate on the "login_welcome_text" field. +func LoginWelcomeTextHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextHasSuffix applies the HasSuffix predicate on the "login_welcome_text" field. +func LoginWelcomeTextHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextIsNil applies the IsNil predicate on the "login_welcome_text" field. +func LoginWelcomeTextIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldLoginWelcomeText)) +} + +// LoginWelcomeTextNotNil applies the NotNil predicate on the "login_welcome_text" field. +func LoginWelcomeTextNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldLoginWelcomeText)) +} + +// LoginWelcomeTextEqualFold applies the EqualFold predicate on the "login_welcome_text" field. +func LoginWelcomeTextEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldLoginWelcomeText, v)) +} + +// LoginWelcomeTextContainsFold applies the ContainsFold predicate on the "login_welcome_text" field. +func LoginWelcomeTextContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldLoginWelcomeText, v)) +} + +// ShowVersionEQ applies the EQ predicate on the "show_version" field. +func ShowVersionEQ(v bool) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldShowVersion, v)) +} + +// ShowVersionNEQ applies the NEQ predicate on the "show_version" field. +func ShowVersionNEQ(v bool) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldShowVersion, v)) +} + +// ShowVersionIsNil applies the IsNil predicate on the "show_version" field. +func ShowVersionIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldShowVersion)) +} + +// ShowVersionNotNil applies the NotNil predicate on the "show_version" field. +func ShowVersionNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldShowVersion)) +} + +// BugReportLinkEQ applies the EQ predicate on the "bug_report_link" field. +func BugReportLinkEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldBugReportLink, v)) +} + +// BugReportLinkNEQ applies the NEQ predicate on the "bug_report_link" field. +func BugReportLinkNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldBugReportLink, v)) +} + +// BugReportLinkIn applies the In predicate on the "bug_report_link" field. +func BugReportLinkIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldBugReportLink, vs...)) +} + +// BugReportLinkNotIn applies the NotIn predicate on the "bug_report_link" field. +func BugReportLinkNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldBugReportLink, vs...)) +} + +// BugReportLinkGT applies the GT predicate on the "bug_report_link" field. +func BugReportLinkGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldBugReportLink, v)) +} + +// BugReportLinkGTE applies the GTE predicate on the "bug_report_link" field. +func BugReportLinkGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldBugReportLink, v)) +} + +// BugReportLinkLT applies the LT predicate on the "bug_report_link" field. +func BugReportLinkLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldBugReportLink, v)) +} + +// BugReportLinkLTE applies the LTE predicate on the "bug_report_link" field. +func BugReportLinkLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldBugReportLink, v)) +} + +// BugReportLinkContains applies the Contains predicate on the "bug_report_link" field. +func BugReportLinkContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldBugReportLink, v)) +} + +// BugReportLinkHasPrefix applies the HasPrefix predicate on the "bug_report_link" field. +func BugReportLinkHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldBugReportLink, v)) +} + +// BugReportLinkHasSuffix applies the HasSuffix predicate on the "bug_report_link" field. +func BugReportLinkHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldBugReportLink, v)) +} + +// BugReportLinkIsNil applies the IsNil predicate on the "bug_report_link" field. +func BugReportLinkIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldBugReportLink)) +} + +// BugReportLinkNotNil applies the NotNil predicate on the "bug_report_link" field. +func BugReportLinkNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldBugReportLink)) +} + +// BugReportLinkEqualFold applies the EqualFold predicate on the "bug_report_link" field. +func BugReportLinkEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldBugReportLink, v)) +} + +// BugReportLinkContainsFold applies the ContainsFold predicate on the "bug_report_link" field. +func BugReportLinkContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldBugReportLink, v)) +} + +// HelpLinkEQ applies the EQ predicate on the "help_link" field. +func HelpLinkEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldEQ(FieldHelpLink, v)) +} + +// HelpLinkNEQ applies the NEQ predicate on the "help_link" field. +func HelpLinkNEQ(v string) predicate.Branding { + return predicate.Branding(sql.FieldNEQ(FieldHelpLink, v)) +} + +// HelpLinkIn applies the In predicate on the "help_link" field. +func HelpLinkIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldIn(FieldHelpLink, vs...)) +} + +// HelpLinkNotIn applies the NotIn predicate on the "help_link" field. +func HelpLinkNotIn(vs ...string) predicate.Branding { + return predicate.Branding(sql.FieldNotIn(FieldHelpLink, vs...)) +} + +// HelpLinkGT applies the GT predicate on the "help_link" field. +func HelpLinkGT(v string) predicate.Branding { + return predicate.Branding(sql.FieldGT(FieldHelpLink, v)) +} + +// HelpLinkGTE applies the GTE predicate on the "help_link" field. +func HelpLinkGTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldGTE(FieldHelpLink, v)) +} + +// HelpLinkLT applies the LT predicate on the "help_link" field. +func HelpLinkLT(v string) predicate.Branding { + return predicate.Branding(sql.FieldLT(FieldHelpLink, v)) +} + +// HelpLinkLTE applies the LTE predicate on the "help_link" field. +func HelpLinkLTE(v string) predicate.Branding { + return predicate.Branding(sql.FieldLTE(FieldHelpLink, v)) +} + +// HelpLinkContains applies the Contains predicate on the "help_link" field. +func HelpLinkContains(v string) predicate.Branding { + return predicate.Branding(sql.FieldContains(FieldHelpLink, v)) +} + +// HelpLinkHasPrefix applies the HasPrefix predicate on the "help_link" field. +func HelpLinkHasPrefix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasPrefix(FieldHelpLink, v)) +} + +// HelpLinkHasSuffix applies the HasSuffix predicate on the "help_link" field. +func HelpLinkHasSuffix(v string) predicate.Branding { + return predicate.Branding(sql.FieldHasSuffix(FieldHelpLink, v)) +} + +// HelpLinkIsNil applies the IsNil predicate on the "help_link" field. +func HelpLinkIsNil() predicate.Branding { + return predicate.Branding(sql.FieldIsNull(FieldHelpLink)) +} + +// HelpLinkNotNil applies the NotNil predicate on the "help_link" field. +func HelpLinkNotNil() predicate.Branding { + return predicate.Branding(sql.FieldNotNull(FieldHelpLink)) +} + +// HelpLinkEqualFold applies the EqualFold predicate on the "help_link" field. +func HelpLinkEqualFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldEqualFold(FieldHelpLink, v)) +} + +// HelpLinkContainsFold applies the ContainsFold predicate on the "help_link" field. +func HelpLinkContainsFold(v string) predicate.Branding { + return predicate.Branding(sql.FieldContainsFold(FieldHelpLink, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Branding) predicate.Branding { + return predicate.Branding(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Branding) predicate.Branding { + return predicate.Branding(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Branding) predicate.Branding { + return predicate.Branding(sql.NotPredicates(p)) +} diff --git a/branding_create.go b/branding_create.go new file mode 100644 index 0000000..77a0bb9 --- /dev/null +++ b/branding_create.go @@ -0,0 +1,1129 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/branding" +) + +// BrandingCreate is the builder for creating a Branding entity. +type BrandingCreate struct { + config + mutation *BrandingMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetLogoLight sets the "logo_light" field. +func (bc *BrandingCreate) SetLogoLight(s string) *BrandingCreate { + bc.mutation.SetLogoLight(s) + return bc +} + +// SetNillableLogoLight sets the "logo_light" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableLogoLight(s *string) *BrandingCreate { + if s != nil { + bc.SetLogoLight(*s) + } + return bc +} + +// SetLogoSmall sets the "logo_small" field. +func (bc *BrandingCreate) SetLogoSmall(s string) *BrandingCreate { + bc.mutation.SetLogoSmall(s) + return bc +} + +// SetNillableLogoSmall sets the "logo_small" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableLogoSmall(s *string) *BrandingCreate { + if s != nil { + bc.SetLogoSmall(*s) + } + return bc +} + +// SetPrimaryColor sets the "primary_color" field. +func (bc *BrandingCreate) SetPrimaryColor(s string) *BrandingCreate { + bc.mutation.SetPrimaryColor(s) + return bc +} + +// SetNillablePrimaryColor sets the "primary_color" field if the given value is not nil. +func (bc *BrandingCreate) SetNillablePrimaryColor(s *string) *BrandingCreate { + if s != nil { + bc.SetPrimaryColor(*s) + } + return bc +} + +// SetProductName sets the "product_name" field. +func (bc *BrandingCreate) SetProductName(s string) *BrandingCreate { + bc.mutation.SetProductName(s) + return bc +} + +// SetNillableProductName sets the "product_name" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableProductName(s *string) *BrandingCreate { + if s != nil { + bc.SetProductName(*s) + } + return bc +} + +// SetLoginBackgroundImage sets the "login_background_image" field. +func (bc *BrandingCreate) SetLoginBackgroundImage(s string) *BrandingCreate { + bc.mutation.SetLoginBackgroundImage(s) + return bc +} + +// SetNillableLoginBackgroundImage sets the "login_background_image" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableLoginBackgroundImage(s *string) *BrandingCreate { + if s != nil { + bc.SetLoginBackgroundImage(*s) + } + return bc +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (bc *BrandingCreate) SetLoginWelcomeText(s string) *BrandingCreate { + bc.mutation.SetLoginWelcomeText(s) + return bc +} + +// SetNillableLoginWelcomeText sets the "login_welcome_text" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableLoginWelcomeText(s *string) *BrandingCreate { + if s != nil { + bc.SetLoginWelcomeText(*s) + } + return bc +} + +// SetShowVersion sets the "show_version" field. +func (bc *BrandingCreate) SetShowVersion(b bool) *BrandingCreate { + bc.mutation.SetShowVersion(b) + return bc +} + +// SetNillableShowVersion sets the "show_version" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableShowVersion(b *bool) *BrandingCreate { + if b != nil { + bc.SetShowVersion(*b) + } + return bc +} + +// SetBugReportLink sets the "bug_report_link" field. +func (bc *BrandingCreate) SetBugReportLink(s string) *BrandingCreate { + bc.mutation.SetBugReportLink(s) + return bc +} + +// SetNillableBugReportLink sets the "bug_report_link" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableBugReportLink(s *string) *BrandingCreate { + if s != nil { + bc.SetBugReportLink(*s) + } + return bc +} + +// SetHelpLink sets the "help_link" field. +func (bc *BrandingCreate) SetHelpLink(s string) *BrandingCreate { + bc.mutation.SetHelpLink(s) + return bc +} + +// SetNillableHelpLink sets the "help_link" field if the given value is not nil. +func (bc *BrandingCreate) SetNillableHelpLink(s *string) *BrandingCreate { + if s != nil { + bc.SetHelpLink(*s) + } + return bc +} + +// Mutation returns the BrandingMutation object of the builder. +func (bc *BrandingCreate) Mutation() *BrandingMutation { + return bc.mutation +} + +// Save creates the Branding in the database. +func (bc *BrandingCreate) Save(ctx context.Context) (*Branding, error) { + bc.defaults() + return withHooks(ctx, bc.sqlSave, bc.mutation, bc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (bc *BrandingCreate) SaveX(ctx context.Context) *Branding { + v, err := bc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bc *BrandingCreate) Exec(ctx context.Context) error { + _, err := bc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bc *BrandingCreate) ExecX(ctx context.Context) { + if err := bc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (bc *BrandingCreate) defaults() { + if _, ok := bc.mutation.PrimaryColor(); !ok { + v := branding.DefaultPrimaryColor + bc.mutation.SetPrimaryColor(v) + } + if _, ok := bc.mutation.ProductName(); !ok { + v := branding.DefaultProductName + bc.mutation.SetProductName(v) + } + if _, ok := bc.mutation.ShowVersion(); !ok { + v := branding.DefaultShowVersion + bc.mutation.SetShowVersion(v) + } + if _, ok := bc.mutation.BugReportLink(); !ok { + v := branding.DefaultBugReportLink + bc.mutation.SetBugReportLink(v) + } + if _, ok := bc.mutation.HelpLink(); !ok { + v := branding.DefaultHelpLink + bc.mutation.SetHelpLink(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (bc *BrandingCreate) check() error { + return nil +} + +func (bc *BrandingCreate) sqlSave(ctx context.Context) (*Branding, error) { + if err := bc.check(); err != nil { + return nil, err + } + _node, _spec := bc.createSpec() + if err := sqlgraph.CreateNode(ctx, bc.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 = int(id) + bc.mutation.id = &_node.ID + bc.mutation.done = true + return _node, nil +} + +func (bc *BrandingCreate) createSpec() (*Branding, *sqlgraph.CreateSpec) { + var ( + _node = &Branding{config: bc.config} + _spec = sqlgraph.NewCreateSpec(branding.Table, sqlgraph.NewFieldSpec(branding.FieldID, field.TypeInt)) + ) + _spec.OnConflict = bc.conflict + if value, ok := bc.mutation.LogoLight(); ok { + _spec.SetField(branding.FieldLogoLight, field.TypeString, value) + _node.LogoLight = value + } + if value, ok := bc.mutation.LogoSmall(); ok { + _spec.SetField(branding.FieldLogoSmall, field.TypeString, value) + _node.LogoSmall = value + } + if value, ok := bc.mutation.PrimaryColor(); ok { + _spec.SetField(branding.FieldPrimaryColor, field.TypeString, value) + _node.PrimaryColor = value + } + if value, ok := bc.mutation.ProductName(); ok { + _spec.SetField(branding.FieldProductName, field.TypeString, value) + _node.ProductName = value + } + if value, ok := bc.mutation.LoginBackgroundImage(); ok { + _spec.SetField(branding.FieldLoginBackgroundImage, field.TypeString, value) + _node.LoginBackgroundImage = value + } + if value, ok := bc.mutation.LoginWelcomeText(); ok { + _spec.SetField(branding.FieldLoginWelcomeText, field.TypeString, value) + _node.LoginWelcomeText = value + } + if value, ok := bc.mutation.ShowVersion(); ok { + _spec.SetField(branding.FieldShowVersion, field.TypeBool, value) + _node.ShowVersion = value + } + if value, ok := bc.mutation.BugReportLink(); ok { + _spec.SetField(branding.FieldBugReportLink, field.TypeString, value) + _node.BugReportLink = value + } + if value, ok := bc.mutation.HelpLink(); ok { + _spec.SetField(branding.FieldHelpLink, field.TypeString, value) + _node.HelpLink = value + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Branding.Create(). +// SetLogoLight(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.BrandingUpsert) { +// SetLogoLight(v+v). +// }). +// Exec(ctx) +func (bc *BrandingCreate) OnConflict(opts ...sql.ConflictOption) *BrandingUpsertOne { + bc.conflict = opts + return &BrandingUpsertOne{ + create: bc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Branding.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bc *BrandingCreate) OnConflictColumns(columns ...string) *BrandingUpsertOne { + bc.conflict = append(bc.conflict, sql.ConflictColumns(columns...)) + return &BrandingUpsertOne{ + create: bc, + } +} + +type ( + // BrandingUpsertOne is the builder for "upsert"-ing + // one Branding node. + BrandingUpsertOne struct { + create *BrandingCreate + } + + // BrandingUpsert is the "OnConflict" setter. + BrandingUpsert struct { + *sql.UpdateSet + } +) + +// SetLogoLight sets the "logo_light" field. +func (u *BrandingUpsert) SetLogoLight(v string) *BrandingUpsert { + u.Set(branding.FieldLogoLight, v) + return u +} + +// UpdateLogoLight sets the "logo_light" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateLogoLight() *BrandingUpsert { + u.SetExcluded(branding.FieldLogoLight) + return u +} + +// ClearLogoLight clears the value of the "logo_light" field. +func (u *BrandingUpsert) ClearLogoLight() *BrandingUpsert { + u.SetNull(branding.FieldLogoLight) + return u +} + +// SetLogoSmall sets the "logo_small" field. +func (u *BrandingUpsert) SetLogoSmall(v string) *BrandingUpsert { + u.Set(branding.FieldLogoSmall, v) + return u +} + +// UpdateLogoSmall sets the "logo_small" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateLogoSmall() *BrandingUpsert { + u.SetExcluded(branding.FieldLogoSmall) + return u +} + +// ClearLogoSmall clears the value of the "logo_small" field. +func (u *BrandingUpsert) ClearLogoSmall() *BrandingUpsert { + u.SetNull(branding.FieldLogoSmall) + return u +} + +// SetPrimaryColor sets the "primary_color" field. +func (u *BrandingUpsert) SetPrimaryColor(v string) *BrandingUpsert { + u.Set(branding.FieldPrimaryColor, v) + return u +} + +// UpdatePrimaryColor sets the "primary_color" field to the value that was provided on create. +func (u *BrandingUpsert) UpdatePrimaryColor() *BrandingUpsert { + u.SetExcluded(branding.FieldPrimaryColor) + return u +} + +// ClearPrimaryColor clears the value of the "primary_color" field. +func (u *BrandingUpsert) ClearPrimaryColor() *BrandingUpsert { + u.SetNull(branding.FieldPrimaryColor) + return u +} + +// SetProductName sets the "product_name" field. +func (u *BrandingUpsert) SetProductName(v string) *BrandingUpsert { + u.Set(branding.FieldProductName, v) + return u +} + +// UpdateProductName sets the "product_name" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateProductName() *BrandingUpsert { + u.SetExcluded(branding.FieldProductName) + return u +} + +// ClearProductName clears the value of the "product_name" field. +func (u *BrandingUpsert) ClearProductName() *BrandingUpsert { + u.SetNull(branding.FieldProductName) + return u +} + +// SetLoginBackgroundImage sets the "login_background_image" field. +func (u *BrandingUpsert) SetLoginBackgroundImage(v string) *BrandingUpsert { + u.Set(branding.FieldLoginBackgroundImage, v) + return u +} + +// UpdateLoginBackgroundImage sets the "login_background_image" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateLoginBackgroundImage() *BrandingUpsert { + u.SetExcluded(branding.FieldLoginBackgroundImage) + return u +} + +// ClearLoginBackgroundImage clears the value of the "login_background_image" field. +func (u *BrandingUpsert) ClearLoginBackgroundImage() *BrandingUpsert { + u.SetNull(branding.FieldLoginBackgroundImage) + return u +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (u *BrandingUpsert) SetLoginWelcomeText(v string) *BrandingUpsert { + u.Set(branding.FieldLoginWelcomeText, v) + return u +} + +// UpdateLoginWelcomeText sets the "login_welcome_text" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateLoginWelcomeText() *BrandingUpsert { + u.SetExcluded(branding.FieldLoginWelcomeText) + return u +} + +// ClearLoginWelcomeText clears the value of the "login_welcome_text" field. +func (u *BrandingUpsert) ClearLoginWelcomeText() *BrandingUpsert { + u.SetNull(branding.FieldLoginWelcomeText) + return u +} + +// SetShowVersion sets the "show_version" field. +func (u *BrandingUpsert) SetShowVersion(v bool) *BrandingUpsert { + u.Set(branding.FieldShowVersion, v) + return u +} + +// UpdateShowVersion sets the "show_version" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateShowVersion() *BrandingUpsert { + u.SetExcluded(branding.FieldShowVersion) + return u +} + +// ClearShowVersion clears the value of the "show_version" field. +func (u *BrandingUpsert) ClearShowVersion() *BrandingUpsert { + u.SetNull(branding.FieldShowVersion) + return u +} + +// SetBugReportLink sets the "bug_report_link" field. +func (u *BrandingUpsert) SetBugReportLink(v string) *BrandingUpsert { + u.Set(branding.FieldBugReportLink, v) + return u +} + +// UpdateBugReportLink sets the "bug_report_link" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateBugReportLink() *BrandingUpsert { + u.SetExcluded(branding.FieldBugReportLink) + return u +} + +// ClearBugReportLink clears the value of the "bug_report_link" field. +func (u *BrandingUpsert) ClearBugReportLink() *BrandingUpsert { + u.SetNull(branding.FieldBugReportLink) + return u +} + +// SetHelpLink sets the "help_link" field. +func (u *BrandingUpsert) SetHelpLink(v string) *BrandingUpsert { + u.Set(branding.FieldHelpLink, v) + return u +} + +// UpdateHelpLink sets the "help_link" field to the value that was provided on create. +func (u *BrandingUpsert) UpdateHelpLink() *BrandingUpsert { + u.SetExcluded(branding.FieldHelpLink) + return u +} + +// ClearHelpLink clears the value of the "help_link" field. +func (u *BrandingUpsert) ClearHelpLink() *BrandingUpsert { + u.SetNull(branding.FieldHelpLink) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.Branding.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BrandingUpsertOne) UpdateNewValues() *BrandingUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Branding.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BrandingUpsertOne) Ignore() *BrandingUpsertOne { + 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 *BrandingUpsertOne) DoNothing() *BrandingUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BrandingCreate.OnConflict +// documentation for more info. +func (u *BrandingUpsertOne) Update(set func(*BrandingUpsert)) *BrandingUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BrandingUpsert{UpdateSet: update}) + })) + return u +} + +// SetLogoLight sets the "logo_light" field. +func (u *BrandingUpsertOne) SetLogoLight(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetLogoLight(v) + }) +} + +// UpdateLogoLight sets the "logo_light" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateLogoLight() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLogoLight() + }) +} + +// ClearLogoLight clears the value of the "logo_light" field. +func (u *BrandingUpsertOne) ClearLogoLight() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearLogoLight() + }) +} + +// SetLogoSmall sets the "logo_small" field. +func (u *BrandingUpsertOne) SetLogoSmall(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetLogoSmall(v) + }) +} + +// UpdateLogoSmall sets the "logo_small" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateLogoSmall() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLogoSmall() + }) +} + +// ClearLogoSmall clears the value of the "logo_small" field. +func (u *BrandingUpsertOne) ClearLogoSmall() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearLogoSmall() + }) +} + +// SetPrimaryColor sets the "primary_color" field. +func (u *BrandingUpsertOne) SetPrimaryColor(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetPrimaryColor(v) + }) +} + +// UpdatePrimaryColor sets the "primary_color" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdatePrimaryColor() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdatePrimaryColor() + }) +} + +// ClearPrimaryColor clears the value of the "primary_color" field. +func (u *BrandingUpsertOne) ClearPrimaryColor() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearPrimaryColor() + }) +} + +// SetProductName sets the "product_name" field. +func (u *BrandingUpsertOne) SetProductName(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetProductName(v) + }) +} + +// UpdateProductName sets the "product_name" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateProductName() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateProductName() + }) +} + +// ClearProductName clears the value of the "product_name" field. +func (u *BrandingUpsertOne) ClearProductName() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearProductName() + }) +} + +// SetLoginBackgroundImage sets the "login_background_image" field. +func (u *BrandingUpsertOne) SetLoginBackgroundImage(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetLoginBackgroundImage(v) + }) +} + +// UpdateLoginBackgroundImage sets the "login_background_image" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateLoginBackgroundImage() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLoginBackgroundImage() + }) +} + +// ClearLoginBackgroundImage clears the value of the "login_background_image" field. +func (u *BrandingUpsertOne) ClearLoginBackgroundImage() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearLoginBackgroundImage() + }) +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (u *BrandingUpsertOne) SetLoginWelcomeText(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetLoginWelcomeText(v) + }) +} + +// UpdateLoginWelcomeText sets the "login_welcome_text" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateLoginWelcomeText() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLoginWelcomeText() + }) +} + +// ClearLoginWelcomeText clears the value of the "login_welcome_text" field. +func (u *BrandingUpsertOne) ClearLoginWelcomeText() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearLoginWelcomeText() + }) +} + +// SetShowVersion sets the "show_version" field. +func (u *BrandingUpsertOne) SetShowVersion(v bool) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetShowVersion(v) + }) +} + +// UpdateShowVersion sets the "show_version" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateShowVersion() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateShowVersion() + }) +} + +// ClearShowVersion clears the value of the "show_version" field. +func (u *BrandingUpsertOne) ClearShowVersion() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearShowVersion() + }) +} + +// SetBugReportLink sets the "bug_report_link" field. +func (u *BrandingUpsertOne) SetBugReportLink(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetBugReportLink(v) + }) +} + +// UpdateBugReportLink sets the "bug_report_link" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateBugReportLink() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateBugReportLink() + }) +} + +// ClearBugReportLink clears the value of the "bug_report_link" field. +func (u *BrandingUpsertOne) ClearBugReportLink() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearBugReportLink() + }) +} + +// SetHelpLink sets the "help_link" field. +func (u *BrandingUpsertOne) SetHelpLink(v string) *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.SetHelpLink(v) + }) +} + +// UpdateHelpLink sets the "help_link" field to the value that was provided on create. +func (u *BrandingUpsertOne) UpdateHelpLink() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.UpdateHelpLink() + }) +} + +// ClearHelpLink clears the value of the "help_link" field. +func (u *BrandingUpsertOne) ClearHelpLink() *BrandingUpsertOne { + return u.Update(func(s *BrandingUpsert) { + s.ClearHelpLink() + }) +} + +// Exec executes the query. +func (u *BrandingUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BrandingCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BrandingUpsertOne) 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 *BrandingUpsertOne) ID(ctx context.Context) (id int, 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 *BrandingUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// BrandingCreateBulk is the builder for creating many Branding entities in bulk. +type BrandingCreateBulk struct { + config + err error + builders []*BrandingCreate + conflict []sql.ConflictOption +} + +// Save creates the Branding entities in the database. +func (bcb *BrandingCreateBulk) Save(ctx context.Context) ([]*Branding, error) { + if bcb.err != nil { + return nil, bcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) + nodes := make([]*Branding, len(bcb.builders)) + mutators := make([]Mutator, len(bcb.builders)) + for i := range bcb.builders { + func(i int, root context.Context) { + builder := bcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*BrandingMutation) + 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, bcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = bcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, bcb.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 = int(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, bcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (bcb *BrandingCreateBulk) SaveX(ctx context.Context) []*Branding { + v, err := bcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (bcb *BrandingCreateBulk) Exec(ctx context.Context) error { + _, err := bcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bcb *BrandingCreateBulk) ExecX(ctx context.Context) { + if err := bcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Branding.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.BrandingUpsert) { +// SetLogoLight(v+v). +// }). +// Exec(ctx) +func (bcb *BrandingCreateBulk) OnConflict(opts ...sql.ConflictOption) *BrandingUpsertBulk { + bcb.conflict = opts + return &BrandingUpsertBulk{ + create: bcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Branding.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (bcb *BrandingCreateBulk) OnConflictColumns(columns ...string) *BrandingUpsertBulk { + bcb.conflict = append(bcb.conflict, sql.ConflictColumns(columns...)) + return &BrandingUpsertBulk{ + create: bcb, + } +} + +// BrandingUpsertBulk is the builder for "upsert"-ing +// a bulk of Branding nodes. +type BrandingUpsertBulk struct { + create *BrandingCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Branding.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *BrandingUpsertBulk) UpdateNewValues() *BrandingUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Branding.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *BrandingUpsertBulk) Ignore() *BrandingUpsertBulk { + 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 *BrandingUpsertBulk) DoNothing() *BrandingUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the BrandingCreateBulk.OnConflict +// documentation for more info. +func (u *BrandingUpsertBulk) Update(set func(*BrandingUpsert)) *BrandingUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&BrandingUpsert{UpdateSet: update}) + })) + return u +} + +// SetLogoLight sets the "logo_light" field. +func (u *BrandingUpsertBulk) SetLogoLight(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetLogoLight(v) + }) +} + +// UpdateLogoLight sets the "logo_light" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateLogoLight() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLogoLight() + }) +} + +// ClearLogoLight clears the value of the "logo_light" field. +func (u *BrandingUpsertBulk) ClearLogoLight() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearLogoLight() + }) +} + +// SetLogoSmall sets the "logo_small" field. +func (u *BrandingUpsertBulk) SetLogoSmall(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetLogoSmall(v) + }) +} + +// UpdateLogoSmall sets the "logo_small" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateLogoSmall() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLogoSmall() + }) +} + +// ClearLogoSmall clears the value of the "logo_small" field. +func (u *BrandingUpsertBulk) ClearLogoSmall() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearLogoSmall() + }) +} + +// SetPrimaryColor sets the "primary_color" field. +func (u *BrandingUpsertBulk) SetPrimaryColor(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetPrimaryColor(v) + }) +} + +// UpdatePrimaryColor sets the "primary_color" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdatePrimaryColor() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdatePrimaryColor() + }) +} + +// ClearPrimaryColor clears the value of the "primary_color" field. +func (u *BrandingUpsertBulk) ClearPrimaryColor() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearPrimaryColor() + }) +} + +// SetProductName sets the "product_name" field. +func (u *BrandingUpsertBulk) SetProductName(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetProductName(v) + }) +} + +// UpdateProductName sets the "product_name" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateProductName() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateProductName() + }) +} + +// ClearProductName clears the value of the "product_name" field. +func (u *BrandingUpsertBulk) ClearProductName() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearProductName() + }) +} + +// SetLoginBackgroundImage sets the "login_background_image" field. +func (u *BrandingUpsertBulk) SetLoginBackgroundImage(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetLoginBackgroundImage(v) + }) +} + +// UpdateLoginBackgroundImage sets the "login_background_image" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateLoginBackgroundImage() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLoginBackgroundImage() + }) +} + +// ClearLoginBackgroundImage clears the value of the "login_background_image" field. +func (u *BrandingUpsertBulk) ClearLoginBackgroundImage() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearLoginBackgroundImage() + }) +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (u *BrandingUpsertBulk) SetLoginWelcomeText(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetLoginWelcomeText(v) + }) +} + +// UpdateLoginWelcomeText sets the "login_welcome_text" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateLoginWelcomeText() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateLoginWelcomeText() + }) +} + +// ClearLoginWelcomeText clears the value of the "login_welcome_text" field. +func (u *BrandingUpsertBulk) ClearLoginWelcomeText() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearLoginWelcomeText() + }) +} + +// SetShowVersion sets the "show_version" field. +func (u *BrandingUpsertBulk) SetShowVersion(v bool) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetShowVersion(v) + }) +} + +// UpdateShowVersion sets the "show_version" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateShowVersion() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateShowVersion() + }) +} + +// ClearShowVersion clears the value of the "show_version" field. +func (u *BrandingUpsertBulk) ClearShowVersion() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearShowVersion() + }) +} + +// SetBugReportLink sets the "bug_report_link" field. +func (u *BrandingUpsertBulk) SetBugReportLink(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetBugReportLink(v) + }) +} + +// UpdateBugReportLink sets the "bug_report_link" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateBugReportLink() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateBugReportLink() + }) +} + +// ClearBugReportLink clears the value of the "bug_report_link" field. +func (u *BrandingUpsertBulk) ClearBugReportLink() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearBugReportLink() + }) +} + +// SetHelpLink sets the "help_link" field. +func (u *BrandingUpsertBulk) SetHelpLink(v string) *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.SetHelpLink(v) + }) +} + +// UpdateHelpLink sets the "help_link" field to the value that was provided on create. +func (u *BrandingUpsertBulk) UpdateHelpLink() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.UpdateHelpLink() + }) +} + +// ClearHelpLink clears the value of the "help_link" field. +func (u *BrandingUpsertBulk) ClearHelpLink() *BrandingUpsertBulk { + return u.Update(func(s *BrandingUpsert) { + s.ClearHelpLink() + }) +} + +// Exec executes the query. +func (u *BrandingUpsertBulk) 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 BrandingCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for BrandingCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *BrandingUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/branding_delete.go b/branding_delete.go new file mode 100644 index 0000000..b4462da --- /dev/null +++ b/branding_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/branding" + "github.com/open-uem/ent/predicate" +) + +// BrandingDelete is the builder for deleting a Branding entity. +type BrandingDelete struct { + config + hooks []Hook + mutation *BrandingMutation +} + +// Where appends a list predicates to the BrandingDelete builder. +func (bd *BrandingDelete) Where(ps ...predicate.Branding) *BrandingDelete { + bd.mutation.Where(ps...) + return bd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (bd *BrandingDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, bd.sqlExec, bd.mutation, bd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (bd *BrandingDelete) ExecX(ctx context.Context) int { + n, err := bd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (bd *BrandingDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(branding.Table, sqlgraph.NewFieldSpec(branding.FieldID, field.TypeInt)) + if ps := bd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + bd.mutation.done = true + return affected, err +} + +// BrandingDeleteOne is the builder for deleting a single Branding entity. +type BrandingDeleteOne struct { + bd *BrandingDelete +} + +// Where appends a list predicates to the BrandingDelete builder. +func (bdo *BrandingDeleteOne) Where(ps ...predicate.Branding) *BrandingDeleteOne { + bdo.bd.mutation.Where(ps...) + return bdo +} + +// Exec executes the deletion query. +func (bdo *BrandingDeleteOne) Exec(ctx context.Context) error { + n, err := bdo.bd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{branding.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (bdo *BrandingDeleteOne) ExecX(ctx context.Context) { + if err := bdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/branding_query.go b/branding_query.go new file mode 100644 index 0000000..d60d85f --- /dev/null +++ b/branding_query.go @@ -0,0 +1,550 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/branding" + "github.com/open-uem/ent/predicate" +) + +// BrandingQuery is the builder for querying Branding entities. +type BrandingQuery struct { + config + ctx *QueryContext + order []branding.OrderOption + inters []Interceptor + predicates []predicate.Branding + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the BrandingQuery builder. +func (bq *BrandingQuery) Where(ps ...predicate.Branding) *BrandingQuery { + bq.predicates = append(bq.predicates, ps...) + return bq +} + +// Limit the number of records to be returned by this query. +func (bq *BrandingQuery) Limit(limit int) *BrandingQuery { + bq.ctx.Limit = &limit + return bq +} + +// Offset to start from. +func (bq *BrandingQuery) Offset(offset int) *BrandingQuery { + bq.ctx.Offset = &offset + return bq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (bq *BrandingQuery) Unique(unique bool) *BrandingQuery { + bq.ctx.Unique = &unique + return bq +} + +// Order specifies how the records should be ordered. +func (bq *BrandingQuery) Order(o ...branding.OrderOption) *BrandingQuery { + bq.order = append(bq.order, o...) + return bq +} + +// First returns the first Branding entity from the query. +// Returns a *NotFoundError when no Branding was found. +func (bq *BrandingQuery) First(ctx context.Context) (*Branding, error) { + nodes, err := bq.Limit(1).All(setContextOp(ctx, bq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{branding.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (bq *BrandingQuery) FirstX(ctx context.Context) *Branding { + node, err := bq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Branding ID from the query. +// Returns a *NotFoundError when no Branding ID was found. +func (bq *BrandingQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(1).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{branding.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (bq *BrandingQuery) FirstIDX(ctx context.Context) int { + id, err := bq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Branding entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Branding entity is found. +// Returns a *NotFoundError when no Branding entities are found. +func (bq *BrandingQuery) Only(ctx context.Context) (*Branding, error) { + nodes, err := bq.Limit(2).All(setContextOp(ctx, bq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{branding.Label} + default: + return nil, &NotSingularError{branding.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (bq *BrandingQuery) OnlyX(ctx context.Context) *Branding { + node, err := bq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Branding ID in the query. +// Returns a *NotSingularError when more than one Branding ID is found. +// Returns a *NotFoundError when no entities are found. +func (bq *BrandingQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = bq.Limit(2).IDs(setContextOp(ctx, bq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{branding.Label} + default: + err = &NotSingularError{branding.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (bq *BrandingQuery) OnlyIDX(ctx context.Context) int { + id, err := bq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Brandings. +func (bq *BrandingQuery) All(ctx context.Context) ([]*Branding, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryAll) + if err := bq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Branding, *BrandingQuery]() + return withInterceptors[[]*Branding](ctx, bq, qr, bq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (bq *BrandingQuery) AllX(ctx context.Context) []*Branding { + nodes, err := bq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Branding IDs. +func (bq *BrandingQuery) IDs(ctx context.Context) (ids []int, err error) { + if bq.ctx.Unique == nil && bq.path != nil { + bq.Unique(true) + } + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryIDs) + if err = bq.Select(branding.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (bq *BrandingQuery) IDsX(ctx context.Context) []int { + ids, err := bq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (bq *BrandingQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryCount) + if err := bq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, bq, querierCount[*BrandingQuery](), bq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (bq *BrandingQuery) CountX(ctx context.Context) int { + count, err := bq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (bq *BrandingQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, bq.ctx, ent.OpQueryExist) + switch _, err := bq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (bq *BrandingQuery) ExistX(ctx context.Context) bool { + exist, err := bq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the BrandingQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (bq *BrandingQuery) Clone() *BrandingQuery { + if bq == nil { + return nil + } + return &BrandingQuery{ + config: bq.config, + ctx: bq.ctx.Clone(), + order: append([]branding.OrderOption{}, bq.order...), + inters: append([]Interceptor{}, bq.inters...), + predicates: append([]predicate.Branding{}, bq.predicates...), + // clone intermediate query. + sql: bq.sql.Clone(), + path: bq.path, + modifiers: append([]func(*sql.Selector){}, bq.modifiers...), + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// LogoLight string `json:"logo_light,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Branding.Query(). +// GroupBy(branding.FieldLogoLight). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (bq *BrandingQuery) GroupBy(field string, fields ...string) *BrandingGroupBy { + bq.ctx.Fields = append([]string{field}, fields...) + grbuild := &BrandingGroupBy{build: bq} + grbuild.flds = &bq.ctx.Fields + grbuild.label = branding.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// LogoLight string `json:"logo_light,omitempty"` +// } +// +// client.Branding.Query(). +// Select(branding.FieldLogoLight). +// Scan(ctx, &v) +func (bq *BrandingQuery) Select(fields ...string) *BrandingSelect { + bq.ctx.Fields = append(bq.ctx.Fields, fields...) + sbuild := &BrandingSelect{BrandingQuery: bq} + sbuild.label = branding.Label + sbuild.flds, sbuild.scan = &bq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a BrandingSelect configured with the given aggregations. +func (bq *BrandingQuery) Aggregate(fns ...AggregateFunc) *BrandingSelect { + return bq.Select().Aggregate(fns...) +} + +func (bq *BrandingQuery) prepareQuery(ctx context.Context) error { + for _, inter := range bq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, bq); err != nil { + return err + } + } + } + for _, f := range bq.ctx.Fields { + if !branding.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if bq.path != nil { + prev, err := bq.path(ctx) + if err != nil { + return err + } + bq.sql = prev + } + return nil +} + +func (bq *BrandingQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Branding, error) { + var ( + nodes = []*Branding{} + _spec = bq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Branding).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Branding{config: bq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (bq *BrandingQuery) sqlCount(ctx context.Context) (int, error) { + _spec := bq.querySpec() + if len(bq.modifiers) > 0 { + _spec.Modifiers = bq.modifiers + } + _spec.Node.Columns = bq.ctx.Fields + if len(bq.ctx.Fields) > 0 { + _spec.Unique = bq.ctx.Unique != nil && *bq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, bq.driver, _spec) +} + +func (bq *BrandingQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(branding.Table, branding.Columns, sqlgraph.NewFieldSpec(branding.FieldID, field.TypeInt)) + _spec.From = bq.sql + if unique := bq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if bq.path != nil { + _spec.Unique = true + } + if fields := bq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, branding.FieldID) + for i := range fields { + if fields[i] != branding.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := bq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := bq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := bq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := bq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (bq *BrandingQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(bq.driver.Dialect()) + t1 := builder.Table(branding.Table) + columns := bq.ctx.Fields + if len(columns) == 0 { + columns = branding.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if bq.sql != nil { + selector = bq.sql + selector.Select(selector.Columns(columns...)...) + } + if bq.ctx.Unique != nil && *bq.ctx.Unique { + selector.Distinct() + } + for _, m := range bq.modifiers { + m(selector) + } + for _, p := range bq.predicates { + p(selector) + } + for _, p := range bq.order { + p(selector) + } + if offset := bq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := bq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (bq *BrandingQuery) Modify(modifiers ...func(s *sql.Selector)) *BrandingSelect { + bq.modifiers = append(bq.modifiers, modifiers...) + return bq.Select() +} + +// BrandingGroupBy is the group-by builder for Branding entities. +type BrandingGroupBy struct { + selector + build *BrandingQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (bgb *BrandingGroupBy) Aggregate(fns ...AggregateFunc) *BrandingGroupBy { + bgb.fns = append(bgb.fns, fns...) + return bgb +} + +// Scan applies the selector query and scans the result into the given value. +func (bgb *BrandingGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bgb.build.ctx, ent.OpQueryGroupBy) + if err := bgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BrandingQuery, *BrandingGroupBy](ctx, bgb.build, bgb, bgb.build.inters, v) +} + +func (bgb *BrandingGroupBy) sqlScan(ctx context.Context, root *BrandingQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(bgb.fns)) + for _, fn := range bgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*bgb.flds)+len(bgb.fns)) + for _, f := range *bgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*bgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// BrandingSelect is the builder for selecting fields of Branding entities. +type BrandingSelect struct { + *BrandingQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (bs *BrandingSelect) Aggregate(fns ...AggregateFunc) *BrandingSelect { + bs.fns = append(bs.fns, fns...) + return bs +} + +// Scan applies the selector query and scans the result into the given value. +func (bs *BrandingSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, bs.ctx, ent.OpQuerySelect) + if err := bs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*BrandingQuery, *BrandingSelect](ctx, bs.BrandingQuery, bs, bs.inters, v) +} + +func (bs *BrandingSelect) sqlScan(ctx context.Context, root *BrandingQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(bs.fns)) + for _, fn := range bs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*bs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := bs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (bs *BrandingSelect) Modify(modifiers ...func(s *sql.Selector)) *BrandingSelect { + bs.modifiers = append(bs.modifiers, modifiers...) + return bs +} diff --git a/branding_update.go b/branding_update.go new file mode 100644 index 0000000..7b549b1 --- /dev/null +++ b/branding_update.go @@ -0,0 +1,659 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/branding" + "github.com/open-uem/ent/predicate" +) + +// BrandingUpdate is the builder for updating Branding entities. +type BrandingUpdate struct { + config + hooks []Hook + mutation *BrandingMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the BrandingUpdate builder. +func (bu *BrandingUpdate) Where(ps ...predicate.Branding) *BrandingUpdate { + bu.mutation.Where(ps...) + return bu +} + +// SetLogoLight sets the "logo_light" field. +func (bu *BrandingUpdate) SetLogoLight(s string) *BrandingUpdate { + bu.mutation.SetLogoLight(s) + return bu +} + +// SetNillableLogoLight sets the "logo_light" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableLogoLight(s *string) *BrandingUpdate { + if s != nil { + bu.SetLogoLight(*s) + } + return bu +} + +// ClearLogoLight clears the value of the "logo_light" field. +func (bu *BrandingUpdate) ClearLogoLight() *BrandingUpdate { + bu.mutation.ClearLogoLight() + return bu +} + +// SetLogoSmall sets the "logo_small" field. +func (bu *BrandingUpdate) SetLogoSmall(s string) *BrandingUpdate { + bu.mutation.SetLogoSmall(s) + return bu +} + +// SetNillableLogoSmall sets the "logo_small" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableLogoSmall(s *string) *BrandingUpdate { + if s != nil { + bu.SetLogoSmall(*s) + } + return bu +} + +// ClearLogoSmall clears the value of the "logo_small" field. +func (bu *BrandingUpdate) ClearLogoSmall() *BrandingUpdate { + bu.mutation.ClearLogoSmall() + return bu +} + +// SetPrimaryColor sets the "primary_color" field. +func (bu *BrandingUpdate) SetPrimaryColor(s string) *BrandingUpdate { + bu.mutation.SetPrimaryColor(s) + return bu +} + +// SetNillablePrimaryColor sets the "primary_color" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillablePrimaryColor(s *string) *BrandingUpdate { + if s != nil { + bu.SetPrimaryColor(*s) + } + return bu +} + +// ClearPrimaryColor clears the value of the "primary_color" field. +func (bu *BrandingUpdate) ClearPrimaryColor() *BrandingUpdate { + bu.mutation.ClearPrimaryColor() + return bu +} + +// SetProductName sets the "product_name" field. +func (bu *BrandingUpdate) SetProductName(s string) *BrandingUpdate { + bu.mutation.SetProductName(s) + return bu +} + +// SetNillableProductName sets the "product_name" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableProductName(s *string) *BrandingUpdate { + if s != nil { + bu.SetProductName(*s) + } + return bu +} + +// ClearProductName clears the value of the "product_name" field. +func (bu *BrandingUpdate) ClearProductName() *BrandingUpdate { + bu.mutation.ClearProductName() + return bu +} + +// SetLoginBackgroundImage sets the "login_background_image" field. +func (bu *BrandingUpdate) SetLoginBackgroundImage(s string) *BrandingUpdate { + bu.mutation.SetLoginBackgroundImage(s) + return bu +} + +// SetNillableLoginBackgroundImage sets the "login_background_image" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableLoginBackgroundImage(s *string) *BrandingUpdate { + if s != nil { + bu.SetLoginBackgroundImage(*s) + } + return bu +} + +// ClearLoginBackgroundImage clears the value of the "login_background_image" field. +func (bu *BrandingUpdate) ClearLoginBackgroundImage() *BrandingUpdate { + bu.mutation.ClearLoginBackgroundImage() + return bu +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (bu *BrandingUpdate) SetLoginWelcomeText(s string) *BrandingUpdate { + bu.mutation.SetLoginWelcomeText(s) + return bu +} + +// SetNillableLoginWelcomeText sets the "login_welcome_text" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableLoginWelcomeText(s *string) *BrandingUpdate { + if s != nil { + bu.SetLoginWelcomeText(*s) + } + return bu +} + +// ClearLoginWelcomeText clears the value of the "login_welcome_text" field. +func (bu *BrandingUpdate) ClearLoginWelcomeText() *BrandingUpdate { + bu.mutation.ClearLoginWelcomeText() + return bu +} + +// SetShowVersion sets the "show_version" field. +func (bu *BrandingUpdate) SetShowVersion(b bool) *BrandingUpdate { + bu.mutation.SetShowVersion(b) + return bu +} + +// SetNillableShowVersion sets the "show_version" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableShowVersion(b *bool) *BrandingUpdate { + if b != nil { + bu.SetShowVersion(*b) + } + return bu +} + +// ClearShowVersion clears the value of the "show_version" field. +func (bu *BrandingUpdate) ClearShowVersion() *BrandingUpdate { + bu.mutation.ClearShowVersion() + return bu +} + +// SetBugReportLink sets the "bug_report_link" field. +func (bu *BrandingUpdate) SetBugReportLink(s string) *BrandingUpdate { + bu.mutation.SetBugReportLink(s) + return bu +} + +// SetNillableBugReportLink sets the "bug_report_link" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableBugReportLink(s *string) *BrandingUpdate { + if s != nil { + bu.SetBugReportLink(*s) + } + return bu +} + +// ClearBugReportLink clears the value of the "bug_report_link" field. +func (bu *BrandingUpdate) ClearBugReportLink() *BrandingUpdate { + bu.mutation.ClearBugReportLink() + return bu +} + +// SetHelpLink sets the "help_link" field. +func (bu *BrandingUpdate) SetHelpLink(s string) *BrandingUpdate { + bu.mutation.SetHelpLink(s) + return bu +} + +// SetNillableHelpLink sets the "help_link" field if the given value is not nil. +func (bu *BrandingUpdate) SetNillableHelpLink(s *string) *BrandingUpdate { + if s != nil { + bu.SetHelpLink(*s) + } + return bu +} + +// ClearHelpLink clears the value of the "help_link" field. +func (bu *BrandingUpdate) ClearHelpLink() *BrandingUpdate { + bu.mutation.ClearHelpLink() + return bu +} + +// Mutation returns the BrandingMutation object of the builder. +func (bu *BrandingUpdate) Mutation() *BrandingMutation { + return bu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (bu *BrandingUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, bu.sqlSave, bu.mutation, bu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (bu *BrandingUpdate) SaveX(ctx context.Context) int { + affected, err := bu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (bu *BrandingUpdate) Exec(ctx context.Context) error { + _, err := bu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (bu *BrandingUpdate) ExecX(ctx context.Context) { + if err := bu.Exec(ctx); err != nil { + panic(err) + } +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (bu *BrandingUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *BrandingUpdate { + bu.modifiers = append(bu.modifiers, modifiers...) + return bu +} + +func (bu *BrandingUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := sqlgraph.NewUpdateSpec(branding.Table, branding.Columns, sqlgraph.NewFieldSpec(branding.FieldID, field.TypeInt)) + if ps := bu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := bu.mutation.LogoLight(); ok { + _spec.SetField(branding.FieldLogoLight, field.TypeString, value) + } + if bu.mutation.LogoLightCleared() { + _spec.ClearField(branding.FieldLogoLight, field.TypeString) + } + if value, ok := bu.mutation.LogoSmall(); ok { + _spec.SetField(branding.FieldLogoSmall, field.TypeString, value) + } + if bu.mutation.LogoSmallCleared() { + _spec.ClearField(branding.FieldLogoSmall, field.TypeString) + } + if value, ok := bu.mutation.PrimaryColor(); ok { + _spec.SetField(branding.FieldPrimaryColor, field.TypeString, value) + } + if bu.mutation.PrimaryColorCleared() { + _spec.ClearField(branding.FieldPrimaryColor, field.TypeString) + } + if value, ok := bu.mutation.ProductName(); ok { + _spec.SetField(branding.FieldProductName, field.TypeString, value) + } + if bu.mutation.ProductNameCleared() { + _spec.ClearField(branding.FieldProductName, field.TypeString) + } + if value, ok := bu.mutation.LoginBackgroundImage(); ok { + _spec.SetField(branding.FieldLoginBackgroundImage, field.TypeString, value) + } + if bu.mutation.LoginBackgroundImageCleared() { + _spec.ClearField(branding.FieldLoginBackgroundImage, field.TypeString) + } + if value, ok := bu.mutation.LoginWelcomeText(); ok { + _spec.SetField(branding.FieldLoginWelcomeText, field.TypeString, value) + } + if bu.mutation.LoginWelcomeTextCleared() { + _spec.ClearField(branding.FieldLoginWelcomeText, field.TypeString) + } + if value, ok := bu.mutation.ShowVersion(); ok { + _spec.SetField(branding.FieldShowVersion, field.TypeBool, value) + } + if bu.mutation.ShowVersionCleared() { + _spec.ClearField(branding.FieldShowVersion, field.TypeBool) + } + if value, ok := bu.mutation.BugReportLink(); ok { + _spec.SetField(branding.FieldBugReportLink, field.TypeString, value) + } + if bu.mutation.BugReportLinkCleared() { + _spec.ClearField(branding.FieldBugReportLink, field.TypeString) + } + if value, ok := bu.mutation.HelpLink(); ok { + _spec.SetField(branding.FieldHelpLink, field.TypeString, value) + } + if bu.mutation.HelpLinkCleared() { + _spec.ClearField(branding.FieldHelpLink, field.TypeString) + } + _spec.AddModifiers(bu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{branding.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + bu.mutation.done = true + return n, nil +} + +// BrandingUpdateOne is the builder for updating a single Branding entity. +type BrandingUpdateOne struct { + config + fields []string + hooks []Hook + mutation *BrandingMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetLogoLight sets the "logo_light" field. +func (buo *BrandingUpdateOne) SetLogoLight(s string) *BrandingUpdateOne { + buo.mutation.SetLogoLight(s) + return buo +} + +// SetNillableLogoLight sets the "logo_light" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableLogoLight(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetLogoLight(*s) + } + return buo +} + +// ClearLogoLight clears the value of the "logo_light" field. +func (buo *BrandingUpdateOne) ClearLogoLight() *BrandingUpdateOne { + buo.mutation.ClearLogoLight() + return buo +} + +// SetLogoSmall sets the "logo_small" field. +func (buo *BrandingUpdateOne) SetLogoSmall(s string) *BrandingUpdateOne { + buo.mutation.SetLogoSmall(s) + return buo +} + +// SetNillableLogoSmall sets the "logo_small" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableLogoSmall(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetLogoSmall(*s) + } + return buo +} + +// ClearLogoSmall clears the value of the "logo_small" field. +func (buo *BrandingUpdateOne) ClearLogoSmall() *BrandingUpdateOne { + buo.mutation.ClearLogoSmall() + return buo +} + +// SetPrimaryColor sets the "primary_color" field. +func (buo *BrandingUpdateOne) SetPrimaryColor(s string) *BrandingUpdateOne { + buo.mutation.SetPrimaryColor(s) + return buo +} + +// SetNillablePrimaryColor sets the "primary_color" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillablePrimaryColor(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetPrimaryColor(*s) + } + return buo +} + +// ClearPrimaryColor clears the value of the "primary_color" field. +func (buo *BrandingUpdateOne) ClearPrimaryColor() *BrandingUpdateOne { + buo.mutation.ClearPrimaryColor() + return buo +} + +// SetProductName sets the "product_name" field. +func (buo *BrandingUpdateOne) SetProductName(s string) *BrandingUpdateOne { + buo.mutation.SetProductName(s) + return buo +} + +// SetNillableProductName sets the "product_name" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableProductName(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetProductName(*s) + } + return buo +} + +// ClearProductName clears the value of the "product_name" field. +func (buo *BrandingUpdateOne) ClearProductName() *BrandingUpdateOne { + buo.mutation.ClearProductName() + return buo +} + +// SetLoginBackgroundImage sets the "login_background_image" field. +func (buo *BrandingUpdateOne) SetLoginBackgroundImage(s string) *BrandingUpdateOne { + buo.mutation.SetLoginBackgroundImage(s) + return buo +} + +// SetNillableLoginBackgroundImage sets the "login_background_image" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableLoginBackgroundImage(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetLoginBackgroundImage(*s) + } + return buo +} + +// ClearLoginBackgroundImage clears the value of the "login_background_image" field. +func (buo *BrandingUpdateOne) ClearLoginBackgroundImage() *BrandingUpdateOne { + buo.mutation.ClearLoginBackgroundImage() + return buo +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (buo *BrandingUpdateOne) SetLoginWelcomeText(s string) *BrandingUpdateOne { + buo.mutation.SetLoginWelcomeText(s) + return buo +} + +// SetNillableLoginWelcomeText sets the "login_welcome_text" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableLoginWelcomeText(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetLoginWelcomeText(*s) + } + return buo +} + +// ClearLoginWelcomeText clears the value of the "login_welcome_text" field. +func (buo *BrandingUpdateOne) ClearLoginWelcomeText() *BrandingUpdateOne { + buo.mutation.ClearLoginWelcomeText() + return buo +} + +// SetShowVersion sets the "show_version" field. +func (buo *BrandingUpdateOne) SetShowVersion(b bool) *BrandingUpdateOne { + buo.mutation.SetShowVersion(b) + return buo +} + +// SetNillableShowVersion sets the "show_version" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableShowVersion(b *bool) *BrandingUpdateOne { + if b != nil { + buo.SetShowVersion(*b) + } + return buo +} + +// ClearShowVersion clears the value of the "show_version" field. +func (buo *BrandingUpdateOne) ClearShowVersion() *BrandingUpdateOne { + buo.mutation.ClearShowVersion() + return buo +} + +// SetBugReportLink sets the "bug_report_link" field. +func (buo *BrandingUpdateOne) SetBugReportLink(s string) *BrandingUpdateOne { + buo.mutation.SetBugReportLink(s) + return buo +} + +// SetNillableBugReportLink sets the "bug_report_link" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableBugReportLink(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetBugReportLink(*s) + } + return buo +} + +// ClearBugReportLink clears the value of the "bug_report_link" field. +func (buo *BrandingUpdateOne) ClearBugReportLink() *BrandingUpdateOne { + buo.mutation.ClearBugReportLink() + return buo +} + +// SetHelpLink sets the "help_link" field. +func (buo *BrandingUpdateOne) SetHelpLink(s string) *BrandingUpdateOne { + buo.mutation.SetHelpLink(s) + return buo +} + +// SetNillableHelpLink sets the "help_link" field if the given value is not nil. +func (buo *BrandingUpdateOne) SetNillableHelpLink(s *string) *BrandingUpdateOne { + if s != nil { + buo.SetHelpLink(*s) + } + return buo +} + +// ClearHelpLink clears the value of the "help_link" field. +func (buo *BrandingUpdateOne) ClearHelpLink() *BrandingUpdateOne { + buo.mutation.ClearHelpLink() + return buo +} + +// Mutation returns the BrandingMutation object of the builder. +func (buo *BrandingUpdateOne) Mutation() *BrandingMutation { + return buo.mutation +} + +// Where appends a list predicates to the BrandingUpdate builder. +func (buo *BrandingUpdateOne) Where(ps ...predicate.Branding) *BrandingUpdateOne { + buo.mutation.Where(ps...) + return buo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (buo *BrandingUpdateOne) Select(field string, fields ...string) *BrandingUpdateOne { + buo.fields = append([]string{field}, fields...) + return buo +} + +// Save executes the query and returns the updated Branding entity. +func (buo *BrandingUpdateOne) Save(ctx context.Context) (*Branding, error) { + return withHooks(ctx, buo.sqlSave, buo.mutation, buo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (buo *BrandingUpdateOne) SaveX(ctx context.Context) *Branding { + node, err := buo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (buo *BrandingUpdateOne) Exec(ctx context.Context) error { + _, err := buo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (buo *BrandingUpdateOne) ExecX(ctx context.Context) { + if err := buo.Exec(ctx); err != nil { + panic(err) + } +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (buo *BrandingUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *BrandingUpdateOne { + buo.modifiers = append(buo.modifiers, modifiers...) + return buo +} + +func (buo *BrandingUpdateOne) sqlSave(ctx context.Context) (_node *Branding, err error) { + _spec := sqlgraph.NewUpdateSpec(branding.Table, branding.Columns, sqlgraph.NewFieldSpec(branding.FieldID, field.TypeInt)) + id, ok := buo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Branding.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := buo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, branding.FieldID) + for _, f := range fields { + if !branding.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != branding.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := buo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := buo.mutation.LogoLight(); ok { + _spec.SetField(branding.FieldLogoLight, field.TypeString, value) + } + if buo.mutation.LogoLightCleared() { + _spec.ClearField(branding.FieldLogoLight, field.TypeString) + } + if value, ok := buo.mutation.LogoSmall(); ok { + _spec.SetField(branding.FieldLogoSmall, field.TypeString, value) + } + if buo.mutation.LogoSmallCleared() { + _spec.ClearField(branding.FieldLogoSmall, field.TypeString) + } + if value, ok := buo.mutation.PrimaryColor(); ok { + _spec.SetField(branding.FieldPrimaryColor, field.TypeString, value) + } + if buo.mutation.PrimaryColorCleared() { + _spec.ClearField(branding.FieldPrimaryColor, field.TypeString) + } + if value, ok := buo.mutation.ProductName(); ok { + _spec.SetField(branding.FieldProductName, field.TypeString, value) + } + if buo.mutation.ProductNameCleared() { + _spec.ClearField(branding.FieldProductName, field.TypeString) + } + if value, ok := buo.mutation.LoginBackgroundImage(); ok { + _spec.SetField(branding.FieldLoginBackgroundImage, field.TypeString, value) + } + if buo.mutation.LoginBackgroundImageCleared() { + _spec.ClearField(branding.FieldLoginBackgroundImage, field.TypeString) + } + if value, ok := buo.mutation.LoginWelcomeText(); ok { + _spec.SetField(branding.FieldLoginWelcomeText, field.TypeString, value) + } + if buo.mutation.LoginWelcomeTextCleared() { + _spec.ClearField(branding.FieldLoginWelcomeText, field.TypeString) + } + if value, ok := buo.mutation.ShowVersion(); ok { + _spec.SetField(branding.FieldShowVersion, field.TypeBool, value) + } + if buo.mutation.ShowVersionCleared() { + _spec.ClearField(branding.FieldShowVersion, field.TypeBool) + } + if value, ok := buo.mutation.BugReportLink(); ok { + _spec.SetField(branding.FieldBugReportLink, field.TypeString, value) + } + if buo.mutation.BugReportLinkCleared() { + _spec.ClearField(branding.FieldBugReportLink, field.TypeString) + } + if value, ok := buo.mutation.HelpLink(); ok { + _spec.SetField(branding.FieldHelpLink, field.TypeString, value) + } + if buo.mutation.HelpLinkCleared() { + _spec.ClearField(branding.FieldHelpLink, field.TypeString) + } + _spec.AddModifiers(buo.modifiers...) + _node = &Branding{config: buo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{branding.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + buo.mutation.done = true + return _node, nil +} diff --git a/certificate.go b/certificate.go index 216cea5..0bb95af 100644 --- a/certificate.go +++ b/certificate.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/open-uem/ent/certificate" + "github.com/open-uem/ent/tenant" ) // Certificate is the model entity for the Certificate schema. @@ -24,16 +25,41 @@ type Certificate struct { // Expiry holds the value of the "expiry" field. Expiry time.Time `json:"expiry,omitempty"` // UID holds the value of the "uid" field. - UID string `json:"uid,omitempty"` + UID string `json:"uid,omitempty"` + // The tenant this certificate belongs to (nil for global/hoster certificates) + TenantID *int `json:"tenant_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the CertificateQuery when eager-loading is set. + Edges CertificateEdges `json:"edges"` selectValues sql.SelectValues } +// CertificateEdges holds the relations/edges for other nodes in the graph. +type CertificateEdges struct { + // Tenant holds the value of the tenant edge. + Tenant *Tenant `json:"tenant,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [1]bool +} + +// TenantOrErr returns the Tenant value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e CertificateEdges) TenantOrErr() (*Tenant, error) { + if e.Tenant != nil { + return e.Tenant, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: tenant.Label} + } + return nil, &NotLoadedError{edge: "tenant"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Certificate) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case certificate.FieldID: + case certificate.FieldID, certificate.FieldTenantID: values[i] = new(sql.NullInt64) case certificate.FieldType, certificate.FieldDescription, certificate.FieldUID: values[i] = new(sql.NullString) @@ -84,6 +110,13 @@ func (c *Certificate) assignValues(columns []string, values []any) error { } else if value.Valid { c.UID = value.String } + case certificate.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + c.TenantID = new(int) + *c.TenantID = int(value.Int64) + } default: c.selectValues.Set(columns[i], values[i]) } @@ -97,6 +130,11 @@ func (c *Certificate) Value(name string) (ent.Value, error) { return c.selectValues.Get(name) } +// QueryTenant queries the "tenant" edge of the Certificate entity. +func (c *Certificate) QueryTenant() *TenantQuery { + return NewCertificateClient(c.config).QueryTenant(c) +} + // Update returns a builder for updating this Certificate. // Note that you need to call Certificate.Unwrap() before calling this method if this Certificate // was returned from a transaction, and the transaction was committed or rolled back. @@ -131,6 +169,11 @@ func (c *Certificate) String() string { builder.WriteString(", ") builder.WriteString("uid=") builder.WriteString(c.UID) + builder.WriteString(", ") + if v := c.TenantID; v != nil { + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } builder.WriteByte(')') return builder.String() } diff --git a/certificate/certificate.go b/certificate/certificate.go index 90b05f2..a70ff7e 100644 --- a/certificate/certificate.go +++ b/certificate/certificate.go @@ -6,6 +6,7 @@ import ( "fmt" "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" ) const ( @@ -21,8 +22,21 @@ const ( FieldExpiry = "expiry" // FieldUID holds the string denoting the uid field in the database. FieldUID = "uid" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // EdgeTenant holds the string denoting the tenant edge name in mutations. + EdgeTenant = "tenant" + // TenantFieldID holds the string denoting the ID field of the Tenant. + TenantFieldID = "id" // Table holds the table name of the certificate in the database. Table = "certificates" + // TenantTable is the table that holds the tenant relation/edge. + TenantTable = "certificates" + // TenantInverseTable is the table name for the Tenant entity. + // It exists in this package in order to avoid circular dependency with the "tenant" package. + TenantInverseTable = "tenants" + // TenantColumn is the table column denoting the tenant relation/edge. + TenantColumn = "tenant_id" ) // Columns holds all SQL columns for certificate fields. @@ -32,6 +46,7 @@ var Columns = []string{ FieldDescription, FieldExpiry, FieldUID, + FieldTenantID, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -101,3 +116,22 @@ func ByExpiry(opts ...sql.OrderTermOption) OrderOption { func ByUID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUID, opts...).ToFunc() } + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByTenantField orders the results by tenant field. +func ByTenantField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTenantStep(), sql.OrderByField(field, opts...)) + } +} +func newTenantStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TenantInverseTable, TenantFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TenantTable, TenantColumn), + ) +} diff --git a/certificate/where.go b/certificate/where.go index eb8566b..084cffb 100644 --- a/certificate/where.go +++ b/certificate/where.go @@ -6,6 +6,7 @@ import ( "time" "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" "github.com/open-uem/ent/predicate" ) @@ -69,6 +70,11 @@ func UID(v string) predicate.Certificate { return predicate.Certificate(sql.FieldEQ(FieldUID, v)) } +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v int) predicate.Certificate { + return predicate.Certificate(sql.FieldEQ(FieldTenantID, v)) +} + // TypeEQ applies the EQ predicate on the "type" field. func TypeEQ(v Type) predicate.Certificate { return predicate.Certificate(sql.FieldEQ(FieldType, v)) @@ -289,6 +295,59 @@ func UIDContainsFold(v string) predicate.Certificate { return predicate.Certificate(sql.FieldContainsFold(FieldUID, v)) } +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v int) predicate.Certificate { + return predicate.Certificate(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v int) predicate.Certificate { + return predicate.Certificate(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...int) predicate.Certificate { + return predicate.Certificate(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...int) predicate.Certificate { + return predicate.Certificate(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDIsNil applies the IsNil predicate on the "tenant_id" field. +func TenantIDIsNil() predicate.Certificate { + return predicate.Certificate(sql.FieldIsNull(FieldTenantID)) +} + +// TenantIDNotNil applies the NotNil predicate on the "tenant_id" field. +func TenantIDNotNil() predicate.Certificate { + return predicate.Certificate(sql.FieldNotNull(FieldTenantID)) +} + +// HasTenant applies the HasEdge predicate on the "tenant" edge. +func HasTenant() predicate.Certificate { + return predicate.Certificate(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TenantTable, TenantColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTenantWith applies the HasEdge predicate on the "tenant" edge with a given conditions (other predicates). +func HasTenantWith(preds ...predicate.Tenant) predicate.Certificate { + return predicate.Certificate(func(s *sql.Selector) { + step := newTenantStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Certificate) predicate.Certificate { return predicate.Certificate(sql.AndPredicates(predicates...)) diff --git a/certificate_create.go b/certificate_create.go index d90798c..42baf96 100644 --- a/certificate_create.go +++ b/certificate_create.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/open-uem/ent/certificate" + "github.com/open-uem/ent/tenant" ) // CertificateCreate is the builder for creating a Certificate entity. @@ -70,12 +71,31 @@ func (cc *CertificateCreate) SetNillableUID(s *string) *CertificateCreate { return cc } +// SetTenantID sets the "tenant_id" field. +func (cc *CertificateCreate) SetTenantID(i int) *CertificateCreate { + cc.mutation.SetTenantID(i) + return cc +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (cc *CertificateCreate) SetNillableTenantID(i *int) *CertificateCreate { + if i != nil { + cc.SetTenantID(*i) + } + return cc +} + // SetID sets the "id" field. func (cc *CertificateCreate) SetID(i int64) *CertificateCreate { cc.mutation.SetID(i) return cc } +// SetTenant sets the "tenant" edge to the Tenant entity. +func (cc *CertificateCreate) SetTenant(t *Tenant) *CertificateCreate { + return cc.SetTenantID(t.ID) +} + // Mutation returns the CertificateMutation object of the builder. func (cc *CertificateCreate) Mutation() *CertificateMutation { return cc.mutation @@ -167,6 +187,23 @@ func (cc *CertificateCreate) createSpec() (*Certificate, *sqlgraph.CreateSpec) { _spec.SetField(certificate.FieldUID, field.TypeString, value) _node.UID = value } + if nodes := cc.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: certificate.TenantTable, + Columns: []string{certificate.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.TenantID = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } @@ -285,6 +322,24 @@ func (u *CertificateUpsert) ClearUID() *CertificateUpsert { return u } +// SetTenantID sets the "tenant_id" field. +func (u *CertificateUpsert) SetTenantID(v int) *CertificateUpsert { + u.Set(certificate.FieldTenantID, v) + return u +} + +// UpdateTenantID sets the "tenant_id" field to the value that was provided on create. +func (u *CertificateUpsert) UpdateTenantID() *CertificateUpsert { + u.SetExcluded(certificate.FieldTenantID) + return u +} + +// ClearTenantID clears the value of the "tenant_id" field. +func (u *CertificateUpsert) ClearTenantID() *CertificateUpsert { + u.SetNull(certificate.FieldTenantID) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -410,6 +465,27 @@ func (u *CertificateUpsertOne) ClearUID() *CertificateUpsertOne { }) } +// SetTenantID sets the "tenant_id" field. +func (u *CertificateUpsertOne) SetTenantID(v int) *CertificateUpsertOne { + return u.Update(func(s *CertificateUpsert) { + s.SetTenantID(v) + }) +} + +// UpdateTenantID sets the "tenant_id" field to the value that was provided on create. +func (u *CertificateUpsertOne) UpdateTenantID() *CertificateUpsertOne { + return u.Update(func(s *CertificateUpsert) { + s.UpdateTenantID() + }) +} + +// ClearTenantID clears the value of the "tenant_id" field. +func (u *CertificateUpsertOne) ClearTenantID() *CertificateUpsertOne { + return u.Update(func(s *CertificateUpsert) { + s.ClearTenantID() + }) +} + // Exec executes the query. func (u *CertificateUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -700,6 +776,27 @@ func (u *CertificateUpsertBulk) ClearUID() *CertificateUpsertBulk { }) } +// SetTenantID sets the "tenant_id" field. +func (u *CertificateUpsertBulk) SetTenantID(v int) *CertificateUpsertBulk { + return u.Update(func(s *CertificateUpsert) { + s.SetTenantID(v) + }) +} + +// UpdateTenantID sets the "tenant_id" field to the value that was provided on create. +func (u *CertificateUpsertBulk) UpdateTenantID() *CertificateUpsertBulk { + return u.Update(func(s *CertificateUpsert) { + s.UpdateTenantID() + }) +} + +// ClearTenantID clears the value of the "tenant_id" field. +func (u *CertificateUpsertBulk) ClearTenantID() *CertificateUpsertBulk { + return u.Update(func(s *CertificateUpsert) { + s.ClearTenantID() + }) +} + // Exec executes the query. func (u *CertificateUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/certificate_query.go b/certificate_query.go index 58bacf6..af4afee 100644 --- a/certificate_query.go +++ b/certificate_query.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/open-uem/ent/certificate" "github.com/open-uem/ent/predicate" + "github.com/open-uem/ent/tenant" ) // CertificateQuery is the builder for querying Certificate entities. @@ -22,6 +23,7 @@ type CertificateQuery struct { order []certificate.OrderOption inters []Interceptor predicates []predicate.Certificate + withTenant *TenantQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -59,6 +61,28 @@ func (cq *CertificateQuery) Order(o ...certificate.OrderOption) *CertificateQuer return cq } +// QueryTenant chains the current query on the "tenant" edge. +func (cq *CertificateQuery) QueryTenant() *TenantQuery { + query := (&TenantClient{config: cq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := cq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := cq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(certificate.Table, certificate.FieldID, selector), + sqlgraph.To(tenant.Table, tenant.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, certificate.TenantTable, certificate.TenantColumn), + ) + fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Certificate entity from the query. // Returns a *NotFoundError when no Certificate was found. func (cq *CertificateQuery) First(ctx context.Context) (*Certificate, error) { @@ -251,6 +275,7 @@ func (cq *CertificateQuery) Clone() *CertificateQuery { order: append([]certificate.OrderOption{}, cq.order...), inters: append([]Interceptor{}, cq.inters...), predicates: append([]predicate.Certificate{}, cq.predicates...), + withTenant: cq.withTenant.Clone(), // clone intermediate query. sql: cq.sql.Clone(), path: cq.path, @@ -258,6 +283,17 @@ func (cq *CertificateQuery) Clone() *CertificateQuery { } } +// WithTenant tells the query-builder to eager-load the nodes that are connected to +// the "tenant" edge. The optional arguments are used to configure the query builder of the edge. +func (cq *CertificateQuery) WithTenant(opts ...func(*TenantQuery)) *CertificateQuery { + query := (&TenantClient{config: cq.config}).Query() + for _, opt := range opts { + opt(query) + } + cq.withTenant = query + return cq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -334,8 +370,11 @@ func (cq *CertificateQuery) prepareQuery(ctx context.Context) error { func (cq *CertificateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Certificate, error) { var ( - nodes = []*Certificate{} - _spec = cq.querySpec() + nodes = []*Certificate{} + _spec = cq.querySpec() + loadedTypes = [1]bool{ + cq.withTenant != nil, + } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Certificate).scanValues(nil, columns) @@ -343,6 +382,7 @@ func (cq *CertificateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* _spec.Assign = func(columns []string, values []any) error { node := &Certificate{config: cq.config} nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } if len(cq.modifiers) > 0 { @@ -357,9 +397,48 @@ func (cq *CertificateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* if len(nodes) == 0 { return nodes, nil } + if query := cq.withTenant; query != nil { + if err := cq.loadTenant(ctx, query, nodes, nil, + func(n *Certificate, e *Tenant) { n.Edges.Tenant = e }); err != nil { + return nil, err + } + } return nodes, nil } +func (cq *CertificateQuery) loadTenant(ctx context.Context, query *TenantQuery, nodes []*Certificate, init func(*Certificate), assign func(*Certificate, *Tenant)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*Certificate) + for i := range nodes { + if nodes[i].TenantID == nil { + continue + } + fk := *nodes[i].TenantID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(tenant.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "tenant_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + func (cq *CertificateQuery) sqlCount(ctx context.Context) (int, error) { _spec := cq.querySpec() if len(cq.modifiers) > 0 { @@ -388,6 +467,9 @@ func (cq *CertificateQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } + if cq.withTenant != nil { + _spec.Node.AddColumnOnce(certificate.FieldTenantID) + } } if ps := cq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { diff --git a/certificate_update.go b/certificate_update.go index fcbe30d..2761488 100644 --- a/certificate_update.go +++ b/certificate_update.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/schema/field" "github.com/open-uem/ent/certificate" "github.com/open-uem/ent/predicate" + "github.com/open-uem/ent/tenant" ) // CertificateUpdate is the builder for updating Certificate entities. @@ -103,11 +104,42 @@ func (cu *CertificateUpdate) ClearUID() *CertificateUpdate { return cu } +// SetTenantID sets the "tenant_id" field. +func (cu *CertificateUpdate) SetTenantID(i int) *CertificateUpdate { + cu.mutation.SetTenantID(i) + return cu +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (cu *CertificateUpdate) SetNillableTenantID(i *int) *CertificateUpdate { + if i != nil { + cu.SetTenantID(*i) + } + return cu +} + +// ClearTenantID clears the value of the "tenant_id" field. +func (cu *CertificateUpdate) ClearTenantID() *CertificateUpdate { + cu.mutation.ClearTenantID() + return cu +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (cu *CertificateUpdate) SetTenant(t *Tenant) *CertificateUpdate { + return cu.SetTenantID(t.ID) +} + // Mutation returns the CertificateMutation object of the builder. func (cu *CertificateUpdate) Mutation() *CertificateMutation { return cu.mutation } +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (cu *CertificateUpdate) ClearTenant() *CertificateUpdate { + cu.mutation.ClearTenant() + return cu +} + // Save executes the query and returns the number of nodes affected by the update operation. func (cu *CertificateUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks) @@ -184,6 +216,35 @@ func (cu *CertificateUpdate) sqlSave(ctx context.Context) (n int, err error) { if cu.mutation.UIDCleared() { _spec.ClearField(certificate.FieldUID, field.TypeString) } + if cu.mutation.TenantCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: certificate.TenantTable, + Columns: []string{certificate.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cu.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: certificate.TenantTable, + Columns: []string{certificate.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(cu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -280,11 +341,42 @@ func (cuo *CertificateUpdateOne) ClearUID() *CertificateUpdateOne { return cuo } +// SetTenantID sets the "tenant_id" field. +func (cuo *CertificateUpdateOne) SetTenantID(i int) *CertificateUpdateOne { + cuo.mutation.SetTenantID(i) + return cuo +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (cuo *CertificateUpdateOne) SetNillableTenantID(i *int) *CertificateUpdateOne { + if i != nil { + cuo.SetTenantID(*i) + } + return cuo +} + +// ClearTenantID clears the value of the "tenant_id" field. +func (cuo *CertificateUpdateOne) ClearTenantID() *CertificateUpdateOne { + cuo.mutation.ClearTenantID() + return cuo +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (cuo *CertificateUpdateOne) SetTenant(t *Tenant) *CertificateUpdateOne { + return cuo.SetTenantID(t.ID) +} + // Mutation returns the CertificateMutation object of the builder. func (cuo *CertificateUpdateOne) Mutation() *CertificateMutation { return cuo.mutation } +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (cuo *CertificateUpdateOne) ClearTenant() *CertificateUpdateOne { + cuo.mutation.ClearTenant() + return cuo +} + // Where appends a list predicates to the CertificateUpdate builder. func (cuo *CertificateUpdateOne) Where(ps ...predicate.Certificate) *CertificateUpdateOne { cuo.mutation.Where(ps...) @@ -391,6 +483,35 @@ func (cuo *CertificateUpdateOne) sqlSave(ctx context.Context) (_node *Certificat if cuo.mutation.UIDCleared() { _spec.ClearField(certificate.FieldUID, field.TypeString) } + if cuo.mutation.TenantCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: certificate.TenantTable, + Columns: []string{certificate.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := cuo.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: certificate.TenantTable, + Columns: []string{certificate.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(cuo.modifiers...) _node = &Certificate{config: cuo.config} _spec.Assign = _node.assignValues diff --git a/client.go b/client.go index d274811..8d6d11d 100644 --- a/client.go +++ b/client.go @@ -19,9 +19,11 @@ import ( "github.com/open-uem/ent/antivirus" "github.com/open-uem/ent/app" "github.com/open-uem/ent/authentication" + "github.com/open-uem/ent/branding" "github.com/open-uem/ent/certificate" "github.com/open-uem/ent/computer" "github.com/open-uem/ent/deployment" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/logicaldisk" "github.com/open-uem/ent/memoryslot" "github.com/open-uem/ent/metadata" @@ -50,6 +52,7 @@ import ( "github.com/open-uem/ent/tenant" "github.com/open-uem/ent/update" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" "github.com/open-uem/ent/wingetconfigexclusion" ) @@ -66,12 +69,16 @@ type Client struct { App *AppClient // Authentication is the client for interacting with the Authentication builders. Authentication *AuthenticationClient + // Branding is the client for interacting with the Branding builders. + Branding *BrandingClient // Certificate is the client for interacting with the Certificate builders. Certificate *CertificateClient // Computer is the client for interacting with the Computer builders. Computer *ComputerClient // Deployment is the client for interacting with the Deployment builders. Deployment *DeploymentClient + // EnrollmentToken is the client for interacting with the EnrollmentToken builders. + EnrollmentToken *EnrollmentTokenClient // LogicalDisk is the client for interacting with the LogicalDisk builders. LogicalDisk *LogicalDiskClient // MemorySlot is the client for interacting with the MemorySlot builders. @@ -128,6 +135,8 @@ type Client struct { Update *UpdateClient // User is the client for interacting with the User builders. User *UserClient + // UserTenant is the client for interacting with the UserTenant builders. + UserTenant *UserTenantClient // WingetConfigExclusion is the client for interacting with the WingetConfigExclusion builders. WingetConfigExclusion *WingetConfigExclusionClient } @@ -145,9 +154,11 @@ func (c *Client) init() { c.Antivirus = NewAntivirusClient(c.config) c.App = NewAppClient(c.config) c.Authentication = NewAuthenticationClient(c.config) + c.Branding = NewBrandingClient(c.config) c.Certificate = NewCertificateClient(c.config) c.Computer = NewComputerClient(c.config) c.Deployment = NewDeploymentClient(c.config) + c.EnrollmentToken = NewEnrollmentTokenClient(c.config) c.LogicalDisk = NewLogicalDiskClient(c.config) c.MemorySlot = NewMemorySlotClient(c.config) c.Metadata = NewMetadataClient(c.config) @@ -176,6 +187,7 @@ func (c *Client) init() { c.Tenant = NewTenantClient(c.config) c.Update = NewUpdateClient(c.config) c.User = NewUserClient(c.config) + c.UserTenant = NewUserTenantClient(c.config) c.WingetConfigExclusion = NewWingetConfigExclusionClient(c.config) } @@ -273,9 +285,11 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Antivirus: NewAntivirusClient(cfg), App: NewAppClient(cfg), Authentication: NewAuthenticationClient(cfg), + Branding: NewBrandingClient(cfg), Certificate: NewCertificateClient(cfg), Computer: NewComputerClient(cfg), Deployment: NewDeploymentClient(cfg), + EnrollmentToken: NewEnrollmentTokenClient(cfg), LogicalDisk: NewLogicalDiskClient(cfg), MemorySlot: NewMemorySlotClient(cfg), Metadata: NewMetadataClient(cfg), @@ -304,6 +318,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Tenant: NewTenantClient(cfg), Update: NewUpdateClient(cfg), User: NewUserClient(cfg), + UserTenant: NewUserTenantClient(cfg), WingetConfigExclusion: NewWingetConfigExclusionClient(cfg), }, nil } @@ -328,9 +343,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Antivirus: NewAntivirusClient(cfg), App: NewAppClient(cfg), Authentication: NewAuthenticationClient(cfg), + Branding: NewBrandingClient(cfg), Certificate: NewCertificateClient(cfg), Computer: NewComputerClient(cfg), Deployment: NewDeploymentClient(cfg), + EnrollmentToken: NewEnrollmentTokenClient(cfg), LogicalDisk: NewLogicalDiskClient(cfg), MemorySlot: NewMemorySlotClient(cfg), Metadata: NewMetadataClient(cfg), @@ -359,6 +376,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Tenant: NewTenantClient(cfg), Update: NewUpdateClient(cfg), User: NewUserClient(cfg), + UserTenant: NewUserTenantClient(cfg), WingetConfigExclusion: NewWingetConfigExclusionClient(cfg), }, nil } @@ -389,13 +407,13 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Agent, c.Antivirus, c.App, c.Authentication, c.Certificate, c.Computer, - c.Deployment, c.LogicalDisk, c.MemorySlot, c.Metadata, c.Monitor, c.Netbird, - c.NetbirdSettings, c.NetworkAdapter, c.OperatingSystem, c.OrgMetadata, - c.PhysicalDisk, c.Printer, c.Profile, c.ProfileIssue, c.RecoveryCode, - c.Release, c.Revocation, c.Rustdesk, c.Server, c.Sessions, c.Settings, c.Share, - c.Site, c.SystemUpdate, c.Tag, c.Task, c.Tenant, c.Update, c.User, - c.WingetConfigExclusion, + c.Agent, c.Antivirus, c.App, c.Authentication, c.Branding, c.Certificate, + c.Computer, c.Deployment, c.EnrollmentToken, c.LogicalDisk, c.MemorySlot, + c.Metadata, c.Monitor, c.Netbird, c.NetbirdSettings, c.NetworkAdapter, + c.OperatingSystem, c.OrgMetadata, c.PhysicalDisk, c.Printer, c.Profile, + c.ProfileIssue, c.RecoveryCode, c.Release, c.Revocation, c.Rustdesk, c.Server, + c.Sessions, c.Settings, c.Share, c.Site, c.SystemUpdate, c.Tag, c.Task, + c.Tenant, c.Update, c.User, c.UserTenant, c.WingetConfigExclusion, } { n.Use(hooks...) } @@ -405,13 +423,13 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Agent, c.Antivirus, c.App, c.Authentication, c.Certificate, c.Computer, - c.Deployment, c.LogicalDisk, c.MemorySlot, c.Metadata, c.Monitor, c.Netbird, - c.NetbirdSettings, c.NetworkAdapter, c.OperatingSystem, c.OrgMetadata, - c.PhysicalDisk, c.Printer, c.Profile, c.ProfileIssue, c.RecoveryCode, - c.Release, c.Revocation, c.Rustdesk, c.Server, c.Sessions, c.Settings, c.Share, - c.Site, c.SystemUpdate, c.Tag, c.Task, c.Tenant, c.Update, c.User, - c.WingetConfigExclusion, + c.Agent, c.Antivirus, c.App, c.Authentication, c.Branding, c.Certificate, + c.Computer, c.Deployment, c.EnrollmentToken, c.LogicalDisk, c.MemorySlot, + c.Metadata, c.Monitor, c.Netbird, c.NetbirdSettings, c.NetworkAdapter, + c.OperatingSystem, c.OrgMetadata, c.PhysicalDisk, c.Printer, c.Profile, + c.ProfileIssue, c.RecoveryCode, c.Release, c.Revocation, c.Rustdesk, c.Server, + c.Sessions, c.Settings, c.Share, c.Site, c.SystemUpdate, c.Tag, c.Task, + c.Tenant, c.Update, c.User, c.UserTenant, c.WingetConfigExclusion, } { n.Intercept(interceptors...) } @@ -428,12 +446,16 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.App.mutate(ctx, m) case *AuthenticationMutation: return c.Authentication.mutate(ctx, m) + case *BrandingMutation: + return c.Branding.mutate(ctx, m) case *CertificateMutation: return c.Certificate.mutate(ctx, m) case *ComputerMutation: return c.Computer.mutate(ctx, m) case *DeploymentMutation: return c.Deployment.mutate(ctx, m) + case *EnrollmentTokenMutation: + return c.EnrollmentToken.mutate(ctx, m) case *LogicalDiskMutation: return c.LogicalDisk.mutate(ctx, m) case *MemorySlotMutation: @@ -490,6 +512,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Update.mutate(ctx, m) case *UserMutation: return c.User.mutate(ctx, m) + case *UserTenantMutation: + return c.UserTenant.mutate(ctx, m) case *WingetConfigExclusionMutation: return c.WingetConfigExclusion.mutate(ctx, m) default: @@ -1397,6 +1421,139 @@ func (c *AuthenticationClient) mutate(ctx context.Context, m *AuthenticationMuta } } +// BrandingClient is a client for the Branding schema. +type BrandingClient struct { + config +} + +// NewBrandingClient returns a client for the Branding from the given config. +func NewBrandingClient(c config) *BrandingClient { + return &BrandingClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `branding.Hooks(f(g(h())))`. +func (c *BrandingClient) Use(hooks ...Hook) { + c.hooks.Branding = append(c.hooks.Branding, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `branding.Intercept(f(g(h())))`. +func (c *BrandingClient) Intercept(interceptors ...Interceptor) { + c.inters.Branding = append(c.inters.Branding, interceptors...) +} + +// Create returns a builder for creating a Branding entity. +func (c *BrandingClient) Create() *BrandingCreate { + mutation := newBrandingMutation(c.config, OpCreate) + return &BrandingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Branding entities. +func (c *BrandingClient) CreateBulk(builders ...*BrandingCreate) *BrandingCreateBulk { + return &BrandingCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *BrandingClient) MapCreateBulk(slice any, setFunc func(*BrandingCreate, int)) *BrandingCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &BrandingCreateBulk{err: fmt.Errorf("calling to BrandingClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*BrandingCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &BrandingCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Branding. +func (c *BrandingClient) Update() *BrandingUpdate { + mutation := newBrandingMutation(c.config, OpUpdate) + return &BrandingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BrandingClient) UpdateOne(b *Branding) *BrandingUpdateOne { + mutation := newBrandingMutation(c.config, OpUpdateOne, withBranding(b)) + return &BrandingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BrandingClient) UpdateOneID(id int) *BrandingUpdateOne { + mutation := newBrandingMutation(c.config, OpUpdateOne, withBrandingID(id)) + return &BrandingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Branding. +func (c *BrandingClient) Delete() *BrandingDelete { + mutation := newBrandingMutation(c.config, OpDelete) + return &BrandingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BrandingClient) DeleteOne(b *Branding) *BrandingDeleteOne { + return c.DeleteOneID(b.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *BrandingClient) DeleteOneID(id int) *BrandingDeleteOne { + builder := c.Delete().Where(branding.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &BrandingDeleteOne{builder} +} + +// Query returns a query builder for Branding. +func (c *BrandingClient) Query() *BrandingQuery { + return &BrandingQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeBranding}, + inters: c.Interceptors(), + } +} + +// Get returns a Branding entity by its id. +func (c *BrandingClient) Get(ctx context.Context, id int) (*Branding, error) { + return c.Query().Where(branding.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BrandingClient) GetX(ctx context.Context, id int) *Branding { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *BrandingClient) Hooks() []Hook { + return c.hooks.Branding +} + +// Interceptors returns the client interceptors. +func (c *BrandingClient) Interceptors() []Interceptor { + return c.inters.Branding +} + +func (c *BrandingClient) mutate(ctx context.Context, m *BrandingMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&BrandingCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&BrandingUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&BrandingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&BrandingDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Branding mutation op: %q", m.Op()) + } +} + // CertificateClient is a client for the Certificate schema. type CertificateClient struct { config @@ -1505,6 +1662,22 @@ func (c *CertificateClient) GetX(ctx context.Context, id int64) *Certificate { return obj } +// QueryTenant queries the tenant edge of a Certificate. +func (c *CertificateClient) QueryTenant(ce *Certificate) *TenantQuery { + query := (&TenantClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := ce.ID + step := sqlgraph.NewStep( + sqlgraph.From(certificate.Table, certificate.FieldID, id), + sqlgraph.To(tenant.Table, tenant.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, certificate.TenantTable, certificate.TenantColumn), + ) + fromV = sqlgraph.Neighbors(ce.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *CertificateClient) Hooks() []Hook { return c.hooks.Certificate @@ -1828,6 +2001,171 @@ func (c *DeploymentClient) mutate(ctx context.Context, m *DeploymentMutation) (V } } +// EnrollmentTokenClient is a client for the EnrollmentToken schema. +type EnrollmentTokenClient struct { + config +} + +// NewEnrollmentTokenClient returns a client for the EnrollmentToken from the given config. +func NewEnrollmentTokenClient(c config) *EnrollmentTokenClient { + return &EnrollmentTokenClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `enrollmenttoken.Hooks(f(g(h())))`. +func (c *EnrollmentTokenClient) Use(hooks ...Hook) { + c.hooks.EnrollmentToken = append(c.hooks.EnrollmentToken, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `enrollmenttoken.Intercept(f(g(h())))`. +func (c *EnrollmentTokenClient) Intercept(interceptors ...Interceptor) { + c.inters.EnrollmentToken = append(c.inters.EnrollmentToken, interceptors...) +} + +// Create returns a builder for creating a EnrollmentToken entity. +func (c *EnrollmentTokenClient) Create() *EnrollmentTokenCreate { + mutation := newEnrollmentTokenMutation(c.config, OpCreate) + return &EnrollmentTokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of EnrollmentToken entities. +func (c *EnrollmentTokenClient) CreateBulk(builders ...*EnrollmentTokenCreate) *EnrollmentTokenCreateBulk { + return &EnrollmentTokenCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *EnrollmentTokenClient) MapCreateBulk(slice any, setFunc func(*EnrollmentTokenCreate, int)) *EnrollmentTokenCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &EnrollmentTokenCreateBulk{err: fmt.Errorf("calling to EnrollmentTokenClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*EnrollmentTokenCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &EnrollmentTokenCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for EnrollmentToken. +func (c *EnrollmentTokenClient) Update() *EnrollmentTokenUpdate { + mutation := newEnrollmentTokenMutation(c.config, OpUpdate) + return &EnrollmentTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *EnrollmentTokenClient) UpdateOne(et *EnrollmentToken) *EnrollmentTokenUpdateOne { + mutation := newEnrollmentTokenMutation(c.config, OpUpdateOne, withEnrollmentToken(et)) + return &EnrollmentTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *EnrollmentTokenClient) UpdateOneID(id int) *EnrollmentTokenUpdateOne { + mutation := newEnrollmentTokenMutation(c.config, OpUpdateOne, withEnrollmentTokenID(id)) + return &EnrollmentTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for EnrollmentToken. +func (c *EnrollmentTokenClient) Delete() *EnrollmentTokenDelete { + mutation := newEnrollmentTokenMutation(c.config, OpDelete) + return &EnrollmentTokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *EnrollmentTokenClient) DeleteOne(et *EnrollmentToken) *EnrollmentTokenDeleteOne { + return c.DeleteOneID(et.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *EnrollmentTokenClient) DeleteOneID(id int) *EnrollmentTokenDeleteOne { + builder := c.Delete().Where(enrollmenttoken.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &EnrollmentTokenDeleteOne{builder} +} + +// Query returns a query builder for EnrollmentToken. +func (c *EnrollmentTokenClient) Query() *EnrollmentTokenQuery { + return &EnrollmentTokenQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeEnrollmentToken}, + inters: c.Interceptors(), + } +} + +// Get returns a EnrollmentToken entity by its id. +func (c *EnrollmentTokenClient) Get(ctx context.Context, id int) (*EnrollmentToken, error) { + return c.Query().Where(enrollmenttoken.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *EnrollmentTokenClient) GetX(ctx context.Context, id int) *EnrollmentToken { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryTenant queries the tenant edge of a EnrollmentToken. +func (c *EnrollmentTokenClient) QueryTenant(et *EnrollmentToken) *TenantQuery { + query := (&TenantClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := et.ID + step := sqlgraph.NewStep( + sqlgraph.From(enrollmenttoken.Table, enrollmenttoken.FieldID, id), + sqlgraph.To(tenant.Table, tenant.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, enrollmenttoken.TenantTable, enrollmenttoken.TenantColumn), + ) + fromV = sqlgraph.Neighbors(et.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QuerySite queries the site edge of a EnrollmentToken. +func (c *EnrollmentTokenClient) QuerySite(et *EnrollmentToken) *SiteQuery { + query := (&SiteClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := et.ID + step := sqlgraph.NewStep( + sqlgraph.From(enrollmenttoken.Table, enrollmenttoken.FieldID, id), + sqlgraph.To(site.Table, site.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, enrollmenttoken.SiteTable, enrollmenttoken.SiteColumn), + ) + fromV = sqlgraph.Neighbors(et.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *EnrollmentTokenClient) Hooks() []Hook { + return c.hooks.EnrollmentToken +} + +// Interceptors returns the client interceptors. +func (c *EnrollmentTokenClient) Interceptors() []Interceptor { + return c.inters.EnrollmentToken +} + +func (c *EnrollmentTokenClient) mutate(ctx context.Context, m *EnrollmentTokenMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&EnrollmentTokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&EnrollmentTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&EnrollmentTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&EnrollmentTokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown EnrollmentToken mutation op: %q", m.Op()) + } +} + // LogicalDiskClient is a client for the LogicalDisk schema. type LogicalDiskClient struct { config @@ -5193,6 +5531,22 @@ func (c *SiteClient) QueryProfiles(s *Site) *ProfileQuery { return query } +// QueryEnrollmentTokens queries the enrollment_tokens edge of a Site. +func (c *SiteClient) QueryEnrollmentTokens(s *Site) *EnrollmentTokenQuery { + query := (&EnrollmentTokenClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := s.ID + step := sqlgraph.NewStep( + sqlgraph.From(site.Table, site.FieldID, id), + sqlgraph.To(enrollmenttoken.Table, enrollmenttoken.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, site.EnrollmentTokensTable, site.EnrollmentTokensColumn), + ) + fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *SiteClient) Hooks() []Hook { return c.hooks.Site @@ -5949,6 +6303,38 @@ func (c *TenantClient) QueryNetbird(t *Tenant) *NetbirdSettingsQuery { return query } +// QueryUserTenants queries the user_tenants edge of a Tenant. +func (c *TenantClient) QueryUserTenants(t *Tenant) *UserTenantQuery { + query := (&UserTenantClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tenant.Table, tenant.FieldID, id), + sqlgraph.To(usertenant.Table, usertenant.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, tenant.UserTenantsTable, tenant.UserTenantsColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryEnrollmentTokens queries the enrollment_tokens edge of a Tenant. +func (c *TenantClient) QueryEnrollmentTokens(t *Tenant) *EnrollmentTokenQuery { + query := (&EnrollmentTokenClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(tenant.Table, tenant.FieldID, id), + sqlgraph.To(enrollmenttoken.Table, enrollmenttoken.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, tenant.EnrollmentTokensTable, tenant.EnrollmentTokensColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *TenantClient) Hooks() []Hook { return c.hooks.Tenant @@ -6263,6 +6649,22 @@ func (c *UserClient) QueryRecoverycodes(u *User) *RecoveryCodeQuery { return query } +// QueryUserTenants queries the user_tenants edge of a User. +func (c *UserClient) QueryUserTenants(u *User) *UserTenantQuery { + query := (&UserTenantClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := u.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(usertenant.Table, usertenant.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, user.UserTenantsTable, user.UserTenantsColumn), + ) + fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *UserClient) Hooks() []Hook { return c.hooks.User @@ -6288,6 +6690,171 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) } } +// UserTenantClient is a client for the UserTenant schema. +type UserTenantClient struct { + config +} + +// NewUserTenantClient returns a client for the UserTenant from the given config. +func NewUserTenantClient(c config) *UserTenantClient { + return &UserTenantClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `usertenant.Hooks(f(g(h())))`. +func (c *UserTenantClient) Use(hooks ...Hook) { + c.hooks.UserTenant = append(c.hooks.UserTenant, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `usertenant.Intercept(f(g(h())))`. +func (c *UserTenantClient) Intercept(interceptors ...Interceptor) { + c.inters.UserTenant = append(c.inters.UserTenant, interceptors...) +} + +// Create returns a builder for creating a UserTenant entity. +func (c *UserTenantClient) Create() *UserTenantCreate { + mutation := newUserTenantMutation(c.config, OpCreate) + return &UserTenantCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserTenant entities. +func (c *UserTenantClient) CreateBulk(builders ...*UserTenantCreate) *UserTenantCreateBulk { + return &UserTenantCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserTenantClient) MapCreateBulk(slice any, setFunc func(*UserTenantCreate, int)) *UserTenantCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserTenantCreateBulk{err: fmt.Errorf("calling to UserTenantClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserTenantCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserTenantCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserTenant. +func (c *UserTenantClient) Update() *UserTenantUpdate { + mutation := newUserTenantMutation(c.config, OpUpdate) + return &UserTenantUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserTenantClient) UpdateOne(ut *UserTenant) *UserTenantUpdateOne { + mutation := newUserTenantMutation(c.config, OpUpdateOne, withUserTenant(ut)) + return &UserTenantUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserTenantClient) UpdateOneID(id int) *UserTenantUpdateOne { + mutation := newUserTenantMutation(c.config, OpUpdateOne, withUserTenantID(id)) + return &UserTenantUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserTenant. +func (c *UserTenantClient) Delete() *UserTenantDelete { + mutation := newUserTenantMutation(c.config, OpDelete) + return &UserTenantDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserTenantClient) DeleteOne(ut *UserTenant) *UserTenantDeleteOne { + return c.DeleteOneID(ut.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserTenantClient) DeleteOneID(id int) *UserTenantDeleteOne { + builder := c.Delete().Where(usertenant.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserTenantDeleteOne{builder} +} + +// Query returns a query builder for UserTenant. +func (c *UserTenantClient) Query() *UserTenantQuery { + return &UserTenantQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserTenant}, + inters: c.Interceptors(), + } +} + +// Get returns a UserTenant entity by its id. +func (c *UserTenantClient) Get(ctx context.Context, id int) (*UserTenant, error) { + return c.Query().Where(usertenant.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserTenantClient) GetX(ctx context.Context, id int) *UserTenant { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUser queries the user edge of a UserTenant. +func (c *UserTenantClient) QueryUser(ut *UserTenant) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := ut.ID + step := sqlgraph.NewStep( + sqlgraph.From(usertenant.Table, usertenant.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, usertenant.UserTable, usertenant.UserColumn), + ) + fromV = sqlgraph.Neighbors(ut.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTenant queries the tenant edge of a UserTenant. +func (c *UserTenantClient) QueryTenant(ut *UserTenant) *TenantQuery { + query := (&TenantClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := ut.ID + step := sqlgraph.NewStep( + sqlgraph.From(usertenant.Table, usertenant.FieldID, id), + sqlgraph.To(tenant.Table, tenant.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, usertenant.TenantTable, usertenant.TenantColumn), + ) + fromV = sqlgraph.Neighbors(ut.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UserTenantClient) Hooks() []Hook { + return c.hooks.UserTenant +} + +// Interceptors returns the client interceptors. +func (c *UserTenantClient) Interceptors() []Interceptor { + return c.inters.UserTenant +} + +func (c *UserTenantClient) mutate(ctx context.Context, m *UserTenantMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserTenantCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserTenantUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserTenantUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserTenantDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserTenant mutation op: %q", m.Op()) + } +} + // WingetConfigExclusionClient is a client for the WingetConfigExclusion schema. type WingetConfigExclusionClient struct { config @@ -6440,19 +7007,20 @@ func (c *WingetConfigExclusionClient) mutate(ctx context.Context, m *WingetConfi // hooks and interceptors per client, for fast access. type ( hooks struct { - Agent, Antivirus, App, Authentication, Certificate, Computer, Deployment, - LogicalDisk, MemorySlot, Metadata, Monitor, Netbird, NetbirdSettings, - NetworkAdapter, OperatingSystem, OrgMetadata, PhysicalDisk, Printer, Profile, - ProfileIssue, RecoveryCode, Release, Revocation, Rustdesk, Server, Sessions, - Settings, Share, Site, SystemUpdate, Tag, Task, Tenant, Update, User, - WingetConfigExclusion []ent.Hook + Agent, Antivirus, App, Authentication, Branding, Certificate, Computer, + Deployment, EnrollmentToken, LogicalDisk, MemorySlot, Metadata, Monitor, + Netbird, NetbirdSettings, NetworkAdapter, OperatingSystem, OrgMetadata, + PhysicalDisk, Printer, Profile, ProfileIssue, RecoveryCode, Release, + Revocation, Rustdesk, Server, Sessions, Settings, Share, Site, SystemUpdate, + Tag, Task, Tenant, Update, User, UserTenant, WingetConfigExclusion []ent.Hook } inters struct { - Agent, Antivirus, App, Authentication, Certificate, Computer, Deployment, - LogicalDisk, MemorySlot, Metadata, Monitor, Netbird, NetbirdSettings, - NetworkAdapter, OperatingSystem, OrgMetadata, PhysicalDisk, Printer, Profile, - ProfileIssue, RecoveryCode, Release, Revocation, Rustdesk, Server, Sessions, - Settings, Share, Site, SystemUpdate, Tag, Task, Tenant, Update, User, + Agent, Antivirus, App, Authentication, Branding, Certificate, Computer, + Deployment, EnrollmentToken, LogicalDisk, MemorySlot, Metadata, Monitor, + Netbird, NetbirdSettings, NetworkAdapter, OperatingSystem, OrgMetadata, + PhysicalDisk, Printer, Profile, ProfileIssue, RecoveryCode, Release, + Revocation, Rustdesk, Server, Sessions, Settings, Share, Site, SystemUpdate, + Tag, Task, Tenant, Update, User, UserTenant, WingetConfigExclusion []ent.Interceptor } ) diff --git a/enrollmenttoken.go b/enrollmenttoken.go new file mode 100644 index 0000000..3b7cb1e --- /dev/null +++ b/enrollmenttoken.go @@ -0,0 +1,256 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/open-uem/ent/enrollmenttoken" + "github.com/open-uem/ent/site" + "github.com/open-uem/ent/tenant" +) + +// EnrollmentToken is the model entity for the EnrollmentToken schema. +type EnrollmentToken struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // The enrollment token value (UUID) + Token string `json:"token,omitempty"` + // Human-readable description for this token + Description string `json:"description,omitempty"` + // Maximum number of times this token can be used (0 = unlimited) + MaxUses int `json:"max_uses,omitempty"` + // Number of times this token has been used + CurrentUses int `json:"current_uses,omitempty"` + // When this token expires (nil = never) + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // Whether this token is currently active + Active bool `json:"active,omitempty"` + // Created holds the value of the "created" field. + Created time.Time `json:"created,omitempty"` + // Modified holds the value of the "modified" field. + Modified time.Time `json:"modified,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the EnrollmentTokenQuery when eager-loading is set. + Edges EnrollmentTokenEdges `json:"edges"` + site_enrollment_tokens *int + tenant_enrollment_tokens *int + selectValues sql.SelectValues +} + +// EnrollmentTokenEdges holds the relations/edges for other nodes in the graph. +type EnrollmentTokenEdges struct { + // Tenant holds the value of the tenant edge. + Tenant *Tenant `json:"tenant,omitempty"` + // Site holds the value of the site edge. + Site *Site `json:"site,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// TenantOrErr returns the Tenant value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e EnrollmentTokenEdges) TenantOrErr() (*Tenant, error) { + if e.Tenant != nil { + return e.Tenant, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: tenant.Label} + } + return nil, &NotLoadedError{edge: "tenant"} +} + +// SiteOrErr returns the Site value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e EnrollmentTokenEdges) SiteOrErr() (*Site, error) { + if e.Site != nil { + return e.Site, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: site.Label} + } + return nil, &NotLoadedError{edge: "site"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*EnrollmentToken) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case enrollmenttoken.FieldActive: + values[i] = new(sql.NullBool) + case enrollmenttoken.FieldID, enrollmenttoken.FieldMaxUses, enrollmenttoken.FieldCurrentUses: + values[i] = new(sql.NullInt64) + case enrollmenttoken.FieldToken, enrollmenttoken.FieldDescription: + values[i] = new(sql.NullString) + case enrollmenttoken.FieldExpiresAt, enrollmenttoken.FieldCreated, enrollmenttoken.FieldModified: + values[i] = new(sql.NullTime) + case enrollmenttoken.ForeignKeys[0]: // site_enrollment_tokens + values[i] = new(sql.NullInt64) + case enrollmenttoken.ForeignKeys[1]: // tenant_enrollment_tokens + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the EnrollmentToken fields. +func (et *EnrollmentToken) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case enrollmenttoken.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + et.ID = int(value.Int64) + case enrollmenttoken.FieldToken: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field token", values[i]) + } else if value.Valid { + et.Token = value.String + } + case enrollmenttoken.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + et.Description = value.String + } + case enrollmenttoken.FieldMaxUses: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field max_uses", values[i]) + } else if value.Valid { + et.MaxUses = int(value.Int64) + } + case enrollmenttoken.FieldCurrentUses: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field current_uses", values[i]) + } else if value.Valid { + et.CurrentUses = int(value.Int64) + } + case enrollmenttoken.FieldExpiresAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field expires_at", values[i]) + } else if value.Valid { + et.ExpiresAt = new(time.Time) + *et.ExpiresAt = value.Time + } + case enrollmenttoken.FieldActive: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field active", values[i]) + } else if value.Valid { + et.Active = value.Bool + } + case enrollmenttoken.FieldCreated: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created", values[i]) + } else if value.Valid { + et.Created = value.Time + } + case enrollmenttoken.FieldModified: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field modified", values[i]) + } else if value.Valid { + et.Modified = value.Time + } + case enrollmenttoken.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field site_enrollment_tokens", value) + } else if value.Valid { + et.site_enrollment_tokens = new(int) + *et.site_enrollment_tokens = int(value.Int64) + } + case enrollmenttoken.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field tenant_enrollment_tokens", value) + } else if value.Valid { + et.tenant_enrollment_tokens = new(int) + *et.tenant_enrollment_tokens = int(value.Int64) + } + default: + et.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the EnrollmentToken. +// This includes values selected through modifiers, order, etc. +func (et *EnrollmentToken) Value(name string) (ent.Value, error) { + return et.selectValues.Get(name) +} + +// QueryTenant queries the "tenant" edge of the EnrollmentToken entity. +func (et *EnrollmentToken) QueryTenant() *TenantQuery { + return NewEnrollmentTokenClient(et.config).QueryTenant(et) +} + +// QuerySite queries the "site" edge of the EnrollmentToken entity. +func (et *EnrollmentToken) QuerySite() *SiteQuery { + return NewEnrollmentTokenClient(et.config).QuerySite(et) +} + +// Update returns a builder for updating this EnrollmentToken. +// Note that you need to call EnrollmentToken.Unwrap() before calling this method if this EnrollmentToken +// was returned from a transaction, and the transaction was committed or rolled back. +func (et *EnrollmentToken) Update() *EnrollmentTokenUpdateOne { + return NewEnrollmentTokenClient(et.config).UpdateOne(et) +} + +// Unwrap unwraps the EnrollmentToken entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (et *EnrollmentToken) Unwrap() *EnrollmentToken { + _tx, ok := et.config.driver.(*txDriver) + if !ok { + panic("ent: EnrollmentToken is not a transactional entity") + } + et.config.driver = _tx.drv + return et +} + +// String implements the fmt.Stringer. +func (et *EnrollmentToken) String() string { + var builder strings.Builder + builder.WriteString("EnrollmentToken(") + builder.WriteString(fmt.Sprintf("id=%v, ", et.ID)) + builder.WriteString("token=") + builder.WriteString(et.Token) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(et.Description) + builder.WriteString(", ") + builder.WriteString("max_uses=") + builder.WriteString(fmt.Sprintf("%v", et.MaxUses)) + builder.WriteString(", ") + builder.WriteString("current_uses=") + builder.WriteString(fmt.Sprintf("%v", et.CurrentUses)) + builder.WriteString(", ") + if v := et.ExpiresAt; v != nil { + builder.WriteString("expires_at=") + builder.WriteString(v.Format(time.ANSIC)) + } + builder.WriteString(", ") + builder.WriteString("active=") + builder.WriteString(fmt.Sprintf("%v", et.Active)) + builder.WriteString(", ") + builder.WriteString("created=") + builder.WriteString(et.Created.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("modified=") + builder.WriteString(et.Modified.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// EnrollmentTokens is a parsable slice of EnrollmentToken. +type EnrollmentTokens []*EnrollmentToken diff --git a/enrollmenttoken/enrollmenttoken.go b/enrollmenttoken/enrollmenttoken.go new file mode 100644 index 0000000..8db32e5 --- /dev/null +++ b/enrollmenttoken/enrollmenttoken.go @@ -0,0 +1,181 @@ +// Code generated by ent, DO NOT EDIT. + +package enrollmenttoken + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the enrollmenttoken type in the database. + Label = "enrollment_token" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldToken holds the string denoting the token field in the database. + FieldToken = "token" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldMaxUses holds the string denoting the max_uses field in the database. + FieldMaxUses = "max_uses" + // FieldCurrentUses holds the string denoting the current_uses field in the database. + FieldCurrentUses = "current_uses" + // FieldExpiresAt holds the string denoting the expires_at field in the database. + FieldExpiresAt = "expires_at" + // FieldActive holds the string denoting the active field in the database. + FieldActive = "active" + // FieldCreated holds the string denoting the created field in the database. + FieldCreated = "created" + // FieldModified holds the string denoting the modified field in the database. + FieldModified = "modified" + // EdgeTenant holds the string denoting the tenant edge name in mutations. + EdgeTenant = "tenant" + // EdgeSite holds the string denoting the site edge name in mutations. + EdgeSite = "site" + // Table holds the table name of the enrollmenttoken in the database. + Table = "enrollment_tokens" + // TenantTable is the table that holds the tenant relation/edge. + TenantTable = "enrollment_tokens" + // TenantInverseTable is the table name for the Tenant entity. + // It exists in this package in order to avoid circular dependency with the "tenant" package. + TenantInverseTable = "tenants" + // TenantColumn is the table column denoting the tenant relation/edge. + TenantColumn = "tenant_enrollment_tokens" + // SiteTable is the table that holds the site relation/edge. + SiteTable = "enrollment_tokens" + // SiteInverseTable is the table name for the Site entity. + // It exists in this package in order to avoid circular dependency with the "site" package. + SiteInverseTable = "sites" + // SiteColumn is the table column denoting the site relation/edge. + SiteColumn = "site_enrollment_tokens" +) + +// Columns holds all SQL columns for enrollmenttoken fields. +var Columns = []string{ + FieldID, + FieldToken, + FieldDescription, + FieldMaxUses, + FieldCurrentUses, + FieldExpiresAt, + FieldActive, + FieldCreated, + FieldModified, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "enrollment_tokens" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "site_enrollment_tokens", + "tenant_enrollment_tokens", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +var ( + // TokenValidator is a validator for the "token" field. It is called by the builders before save. + TokenValidator func(string) error + // DefaultMaxUses holds the default value on creation for the "max_uses" field. + DefaultMaxUses int + // DefaultCurrentUses holds the default value on creation for the "current_uses" field. + DefaultCurrentUses int + // DefaultActive holds the default value on creation for the "active" field. + DefaultActive bool + // DefaultCreated holds the default value on creation for the "created" field. + DefaultCreated func() time.Time + // DefaultModified holds the default value on creation for the "modified" field. + DefaultModified func() time.Time + // UpdateDefaultModified holds the default value on update for the "modified" field. + UpdateDefaultModified func() time.Time +) + +// OrderOption defines the ordering options for the EnrollmentToken queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByToken orders the results by the token field. +func ByToken(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldToken, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByMaxUses orders the results by the max_uses field. +func ByMaxUses(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMaxUses, opts...).ToFunc() +} + +// ByCurrentUses orders the results by the current_uses field. +func ByCurrentUses(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCurrentUses, opts...).ToFunc() +} + +// ByExpiresAt orders the results by the expires_at field. +func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExpiresAt, opts...).ToFunc() +} + +// ByActive orders the results by the active field. +func ByActive(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldActive, opts...).ToFunc() +} + +// ByCreated orders the results by the created field. +func ByCreated(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreated, opts...).ToFunc() +} + +// ByModified orders the results by the modified field. +func ByModified(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModified, opts...).ToFunc() +} + +// ByTenantField orders the results by tenant field. +func ByTenantField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTenantStep(), sql.OrderByField(field, opts...)) + } +} + +// BySiteField orders the results by site field. +func BySiteField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newSiteStep(), sql.OrderByField(field, opts...)) + } +} +func newTenantStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TenantInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TenantTable, TenantColumn), + ) +} +func newSiteStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(SiteInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SiteTable, SiteColumn), + ) +} diff --git a/enrollmenttoken/where.go b/enrollmenttoken/where.go new file mode 100644 index 0000000..de1d38b --- /dev/null +++ b/enrollmenttoken/where.go @@ -0,0 +1,537 @@ +// Code generated by ent, DO NOT EDIT. + +package enrollmenttoken + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/open-uem/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldID, id)) +} + +// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. +func Token(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldToken, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldDescription, v)) +} + +// MaxUses applies equality check predicate on the "max_uses" field. It's identical to MaxUsesEQ. +func MaxUses(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldMaxUses, v)) +} + +// CurrentUses applies equality check predicate on the "current_uses" field. It's identical to CurrentUsesEQ. +func CurrentUses(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldCurrentUses, v)) +} + +// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ. +func ExpiresAt(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldExpiresAt, v)) +} + +// Active applies equality check predicate on the "active" field. It's identical to ActiveEQ. +func Active(v bool) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldActive, v)) +} + +// Created applies equality check predicate on the "created" field. It's identical to CreatedEQ. +func Created(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldCreated, v)) +} + +// Modified applies equality check predicate on the "modified" field. It's identical to ModifiedEQ. +func Modified(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldModified, v)) +} + +// TokenEQ applies the EQ predicate on the "token" field. +func TokenEQ(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldToken, v)) +} + +// TokenNEQ applies the NEQ predicate on the "token" field. +func TokenNEQ(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldToken, v)) +} + +// TokenIn applies the In predicate on the "token" field. +func TokenIn(vs ...string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldToken, vs...)) +} + +// TokenNotIn applies the NotIn predicate on the "token" field. +func TokenNotIn(vs ...string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldToken, vs...)) +} + +// TokenGT applies the GT predicate on the "token" field. +func TokenGT(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldToken, v)) +} + +// TokenGTE applies the GTE predicate on the "token" field. +func TokenGTE(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldToken, v)) +} + +// TokenLT applies the LT predicate on the "token" field. +func TokenLT(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldToken, v)) +} + +// TokenLTE applies the LTE predicate on the "token" field. +func TokenLTE(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldToken, v)) +} + +// TokenContains applies the Contains predicate on the "token" field. +func TokenContains(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldContains(FieldToken, v)) +} + +// TokenHasPrefix applies the HasPrefix predicate on the "token" field. +func TokenHasPrefix(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldHasPrefix(FieldToken, v)) +} + +// TokenHasSuffix applies the HasSuffix predicate on the "token" field. +func TokenHasSuffix(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldHasSuffix(FieldToken, v)) +} + +// TokenEqualFold applies the EqualFold predicate on the "token" field. +func TokenEqualFold(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEqualFold(FieldToken, v)) +} + +// TokenContainsFold applies the ContainsFold predicate on the "token" field. +func TokenContainsFold(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldContainsFold(FieldToken, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldContainsFold(FieldDescription, v)) +} + +// MaxUsesEQ applies the EQ predicate on the "max_uses" field. +func MaxUsesEQ(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldMaxUses, v)) +} + +// MaxUsesNEQ applies the NEQ predicate on the "max_uses" field. +func MaxUsesNEQ(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldMaxUses, v)) +} + +// MaxUsesIn applies the In predicate on the "max_uses" field. +func MaxUsesIn(vs ...int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldMaxUses, vs...)) +} + +// MaxUsesNotIn applies the NotIn predicate on the "max_uses" field. +func MaxUsesNotIn(vs ...int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldMaxUses, vs...)) +} + +// MaxUsesGT applies the GT predicate on the "max_uses" field. +func MaxUsesGT(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldMaxUses, v)) +} + +// MaxUsesGTE applies the GTE predicate on the "max_uses" field. +func MaxUsesGTE(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldMaxUses, v)) +} + +// MaxUsesLT applies the LT predicate on the "max_uses" field. +func MaxUsesLT(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldMaxUses, v)) +} + +// MaxUsesLTE applies the LTE predicate on the "max_uses" field. +func MaxUsesLTE(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldMaxUses, v)) +} + +// CurrentUsesEQ applies the EQ predicate on the "current_uses" field. +func CurrentUsesEQ(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldCurrentUses, v)) +} + +// CurrentUsesNEQ applies the NEQ predicate on the "current_uses" field. +func CurrentUsesNEQ(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldCurrentUses, v)) +} + +// CurrentUsesIn applies the In predicate on the "current_uses" field. +func CurrentUsesIn(vs ...int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldCurrentUses, vs...)) +} + +// CurrentUsesNotIn applies the NotIn predicate on the "current_uses" field. +func CurrentUsesNotIn(vs ...int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldCurrentUses, vs...)) +} + +// CurrentUsesGT applies the GT predicate on the "current_uses" field. +func CurrentUsesGT(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldCurrentUses, v)) +} + +// CurrentUsesGTE applies the GTE predicate on the "current_uses" field. +func CurrentUsesGTE(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldCurrentUses, v)) +} + +// CurrentUsesLT applies the LT predicate on the "current_uses" field. +func CurrentUsesLT(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldCurrentUses, v)) +} + +// CurrentUsesLTE applies the LTE predicate on the "current_uses" field. +func CurrentUsesLTE(v int) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldCurrentUses, v)) +} + +// ExpiresAtEQ applies the EQ predicate on the "expires_at" field. +func ExpiresAtEQ(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldExpiresAt, v)) +} + +// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field. +func ExpiresAtNEQ(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldExpiresAt, v)) +} + +// ExpiresAtIn applies the In predicate on the "expires_at" field. +func ExpiresAtIn(vs ...time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldExpiresAt, vs...)) +} + +// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field. +func ExpiresAtNotIn(vs ...time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldExpiresAt, vs...)) +} + +// ExpiresAtGT applies the GT predicate on the "expires_at" field. +func ExpiresAtGT(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldExpiresAt, v)) +} + +// ExpiresAtGTE applies the GTE predicate on the "expires_at" field. +func ExpiresAtGTE(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldExpiresAt, v)) +} + +// ExpiresAtLT applies the LT predicate on the "expires_at" field. +func ExpiresAtLT(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldExpiresAt, v)) +} + +// ExpiresAtLTE applies the LTE predicate on the "expires_at" field. +func ExpiresAtLTE(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldExpiresAt, v)) +} + +// ExpiresAtIsNil applies the IsNil predicate on the "expires_at" field. +func ExpiresAtIsNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIsNull(FieldExpiresAt)) +} + +// ExpiresAtNotNil applies the NotNil predicate on the "expires_at" field. +func ExpiresAtNotNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotNull(FieldExpiresAt)) +} + +// ActiveEQ applies the EQ predicate on the "active" field. +func ActiveEQ(v bool) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldActive, v)) +} + +// ActiveNEQ applies the NEQ predicate on the "active" field. +func ActiveNEQ(v bool) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldActive, v)) +} + +// CreatedEQ applies the EQ predicate on the "created" field. +func CreatedEQ(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldCreated, v)) +} + +// CreatedNEQ applies the NEQ predicate on the "created" field. +func CreatedNEQ(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldCreated, v)) +} + +// CreatedIn applies the In predicate on the "created" field. +func CreatedIn(vs ...time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldCreated, vs...)) +} + +// CreatedNotIn applies the NotIn predicate on the "created" field. +func CreatedNotIn(vs ...time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldCreated, vs...)) +} + +// CreatedGT applies the GT predicate on the "created" field. +func CreatedGT(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldCreated, v)) +} + +// CreatedGTE applies the GTE predicate on the "created" field. +func CreatedGTE(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldCreated, v)) +} + +// CreatedLT applies the LT predicate on the "created" field. +func CreatedLT(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldCreated, v)) +} + +// CreatedLTE applies the LTE predicate on the "created" field. +func CreatedLTE(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldCreated, v)) +} + +// CreatedIsNil applies the IsNil predicate on the "created" field. +func CreatedIsNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIsNull(FieldCreated)) +} + +// CreatedNotNil applies the NotNil predicate on the "created" field. +func CreatedNotNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotNull(FieldCreated)) +} + +// ModifiedEQ applies the EQ predicate on the "modified" field. +func ModifiedEQ(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldEQ(FieldModified, v)) +} + +// ModifiedNEQ applies the NEQ predicate on the "modified" field. +func ModifiedNEQ(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNEQ(FieldModified, v)) +} + +// ModifiedIn applies the In predicate on the "modified" field. +func ModifiedIn(vs ...time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIn(FieldModified, vs...)) +} + +// ModifiedNotIn applies the NotIn predicate on the "modified" field. +func ModifiedNotIn(vs ...time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotIn(FieldModified, vs...)) +} + +// ModifiedGT applies the GT predicate on the "modified" field. +func ModifiedGT(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGT(FieldModified, v)) +} + +// ModifiedGTE applies the GTE predicate on the "modified" field. +func ModifiedGTE(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldGTE(FieldModified, v)) +} + +// ModifiedLT applies the LT predicate on the "modified" field. +func ModifiedLT(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLT(FieldModified, v)) +} + +// ModifiedLTE applies the LTE predicate on the "modified" field. +func ModifiedLTE(v time.Time) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldLTE(FieldModified, v)) +} + +// ModifiedIsNil applies the IsNil predicate on the "modified" field. +func ModifiedIsNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldIsNull(FieldModified)) +} + +// ModifiedNotNil applies the NotNil predicate on the "modified" field. +func ModifiedNotNil() predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.FieldNotNull(FieldModified)) +} + +// HasTenant applies the HasEdge predicate on the "tenant" edge. +func HasTenant() predicate.EnrollmentToken { + return predicate.EnrollmentToken(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TenantTable, TenantColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTenantWith applies the HasEdge predicate on the "tenant" edge with a given conditions (other predicates). +func HasTenantWith(preds ...predicate.Tenant) predicate.EnrollmentToken { + return predicate.EnrollmentToken(func(s *sql.Selector) { + step := newTenantStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasSite applies the HasEdge predicate on the "site" edge. +func HasSite() predicate.EnrollmentToken { + return predicate.EnrollmentToken(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, SiteTable, SiteColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasSiteWith applies the HasEdge predicate on the "site" edge with a given conditions (other predicates). +func HasSiteWith(preds ...predicate.Site) predicate.EnrollmentToken { + return predicate.EnrollmentToken(func(s *sql.Selector) { + step := newSiteStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.EnrollmentToken) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.EnrollmentToken) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.EnrollmentToken) predicate.EnrollmentToken { + return predicate.EnrollmentToken(sql.NotPredicates(p)) +} diff --git a/enrollmenttoken_create.go b/enrollmenttoken_create.go new file mode 100644 index 0000000..a9d2a82 --- /dev/null +++ b/enrollmenttoken_create.go @@ -0,0 +1,1090 @@ +// 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/open-uem/ent/enrollmenttoken" + "github.com/open-uem/ent/site" + "github.com/open-uem/ent/tenant" +) + +// EnrollmentTokenCreate is the builder for creating a EnrollmentToken entity. +type EnrollmentTokenCreate struct { + config + mutation *EnrollmentTokenMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetToken sets the "token" field. +func (etc *EnrollmentTokenCreate) SetToken(s string) *EnrollmentTokenCreate { + etc.mutation.SetToken(s) + return etc +} + +// SetDescription sets the "description" field. +func (etc *EnrollmentTokenCreate) SetDescription(s string) *EnrollmentTokenCreate { + etc.mutation.SetDescription(s) + return etc +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableDescription(s *string) *EnrollmentTokenCreate { + if s != nil { + etc.SetDescription(*s) + } + return etc +} + +// SetMaxUses sets the "max_uses" field. +func (etc *EnrollmentTokenCreate) SetMaxUses(i int) *EnrollmentTokenCreate { + etc.mutation.SetMaxUses(i) + return etc +} + +// SetNillableMaxUses sets the "max_uses" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableMaxUses(i *int) *EnrollmentTokenCreate { + if i != nil { + etc.SetMaxUses(*i) + } + return etc +} + +// SetCurrentUses sets the "current_uses" field. +func (etc *EnrollmentTokenCreate) SetCurrentUses(i int) *EnrollmentTokenCreate { + etc.mutation.SetCurrentUses(i) + return etc +} + +// SetNillableCurrentUses sets the "current_uses" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableCurrentUses(i *int) *EnrollmentTokenCreate { + if i != nil { + etc.SetCurrentUses(*i) + } + return etc +} + +// SetExpiresAt sets the "expires_at" field. +func (etc *EnrollmentTokenCreate) SetExpiresAt(t time.Time) *EnrollmentTokenCreate { + etc.mutation.SetExpiresAt(t) + return etc +} + +// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableExpiresAt(t *time.Time) *EnrollmentTokenCreate { + if t != nil { + etc.SetExpiresAt(*t) + } + return etc +} + +// SetActive sets the "active" field. +func (etc *EnrollmentTokenCreate) SetActive(b bool) *EnrollmentTokenCreate { + etc.mutation.SetActive(b) + return etc +} + +// SetNillableActive sets the "active" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableActive(b *bool) *EnrollmentTokenCreate { + if b != nil { + etc.SetActive(*b) + } + return etc +} + +// SetCreated sets the "created" field. +func (etc *EnrollmentTokenCreate) SetCreated(t time.Time) *EnrollmentTokenCreate { + etc.mutation.SetCreated(t) + return etc +} + +// SetNillableCreated sets the "created" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableCreated(t *time.Time) *EnrollmentTokenCreate { + if t != nil { + etc.SetCreated(*t) + } + return etc +} + +// SetModified sets the "modified" field. +func (etc *EnrollmentTokenCreate) SetModified(t time.Time) *EnrollmentTokenCreate { + etc.mutation.SetModified(t) + return etc +} + +// SetNillableModified sets the "modified" field if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableModified(t *time.Time) *EnrollmentTokenCreate { + if t != nil { + etc.SetModified(*t) + } + return etc +} + +// SetTenantID sets the "tenant" edge to the Tenant entity by ID. +func (etc *EnrollmentTokenCreate) SetTenantID(id int) *EnrollmentTokenCreate { + etc.mutation.SetTenantID(id) + return etc +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (etc *EnrollmentTokenCreate) SetTenant(t *Tenant) *EnrollmentTokenCreate { + return etc.SetTenantID(t.ID) +} + +// SetSiteID sets the "site" edge to the Site entity by ID. +func (etc *EnrollmentTokenCreate) SetSiteID(id int) *EnrollmentTokenCreate { + etc.mutation.SetSiteID(id) + return etc +} + +// SetNillableSiteID sets the "site" edge to the Site entity by ID if the given value is not nil. +func (etc *EnrollmentTokenCreate) SetNillableSiteID(id *int) *EnrollmentTokenCreate { + if id != nil { + etc = etc.SetSiteID(*id) + } + return etc +} + +// SetSite sets the "site" edge to the Site entity. +func (etc *EnrollmentTokenCreate) SetSite(s *Site) *EnrollmentTokenCreate { + return etc.SetSiteID(s.ID) +} + +// Mutation returns the EnrollmentTokenMutation object of the builder. +func (etc *EnrollmentTokenCreate) Mutation() *EnrollmentTokenMutation { + return etc.mutation +} + +// Save creates the EnrollmentToken in the database. +func (etc *EnrollmentTokenCreate) Save(ctx context.Context) (*EnrollmentToken, error) { + etc.defaults() + return withHooks(ctx, etc.sqlSave, etc.mutation, etc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (etc *EnrollmentTokenCreate) SaveX(ctx context.Context) *EnrollmentToken { + v, err := etc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (etc *EnrollmentTokenCreate) Exec(ctx context.Context) error { + _, err := etc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (etc *EnrollmentTokenCreate) ExecX(ctx context.Context) { + if err := etc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (etc *EnrollmentTokenCreate) defaults() { + if _, ok := etc.mutation.MaxUses(); !ok { + v := enrollmenttoken.DefaultMaxUses + etc.mutation.SetMaxUses(v) + } + if _, ok := etc.mutation.CurrentUses(); !ok { + v := enrollmenttoken.DefaultCurrentUses + etc.mutation.SetCurrentUses(v) + } + if _, ok := etc.mutation.Active(); !ok { + v := enrollmenttoken.DefaultActive + etc.mutation.SetActive(v) + } + if _, ok := etc.mutation.Created(); !ok { + v := enrollmenttoken.DefaultCreated() + etc.mutation.SetCreated(v) + } + if _, ok := etc.mutation.Modified(); !ok { + v := enrollmenttoken.DefaultModified() + etc.mutation.SetModified(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (etc *EnrollmentTokenCreate) check() error { + if _, ok := etc.mutation.Token(); !ok { + return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "EnrollmentToken.token"`)} + } + if v, ok := etc.mutation.Token(); ok { + if err := enrollmenttoken.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "EnrollmentToken.token": %w`, err)} + } + } + if _, ok := etc.mutation.MaxUses(); !ok { + return &ValidationError{Name: "max_uses", err: errors.New(`ent: missing required field "EnrollmentToken.max_uses"`)} + } + if _, ok := etc.mutation.CurrentUses(); !ok { + return &ValidationError{Name: "current_uses", err: errors.New(`ent: missing required field "EnrollmentToken.current_uses"`)} + } + if _, ok := etc.mutation.Active(); !ok { + return &ValidationError{Name: "active", err: errors.New(`ent: missing required field "EnrollmentToken.active"`)} + } + if len(etc.mutation.TenantIDs()) == 0 { + return &ValidationError{Name: "tenant", err: errors.New(`ent: missing required edge "EnrollmentToken.tenant"`)} + } + return nil +} + +func (etc *EnrollmentTokenCreate) sqlSave(ctx context.Context) (*EnrollmentToken, error) { + if err := etc.check(); err != nil { + return nil, err + } + _node, _spec := etc.createSpec() + if err := sqlgraph.CreateNode(ctx, etc.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 = int(id) + etc.mutation.id = &_node.ID + etc.mutation.done = true + return _node, nil +} + +func (etc *EnrollmentTokenCreate) createSpec() (*EnrollmentToken, *sqlgraph.CreateSpec) { + var ( + _node = &EnrollmentToken{config: etc.config} + _spec = sqlgraph.NewCreateSpec(enrollmenttoken.Table, sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt)) + ) + _spec.OnConflict = etc.conflict + if value, ok := etc.mutation.Token(); ok { + _spec.SetField(enrollmenttoken.FieldToken, field.TypeString, value) + _node.Token = value + } + if value, ok := etc.mutation.Description(); ok { + _spec.SetField(enrollmenttoken.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := etc.mutation.MaxUses(); ok { + _spec.SetField(enrollmenttoken.FieldMaxUses, field.TypeInt, value) + _node.MaxUses = value + } + if value, ok := etc.mutation.CurrentUses(); ok { + _spec.SetField(enrollmenttoken.FieldCurrentUses, field.TypeInt, value) + _node.CurrentUses = value + } + if value, ok := etc.mutation.ExpiresAt(); ok { + _spec.SetField(enrollmenttoken.FieldExpiresAt, field.TypeTime, value) + _node.ExpiresAt = &value + } + if value, ok := etc.mutation.Active(); ok { + _spec.SetField(enrollmenttoken.FieldActive, field.TypeBool, value) + _node.Active = value + } + if value, ok := etc.mutation.Created(); ok { + _spec.SetField(enrollmenttoken.FieldCreated, field.TypeTime, value) + _node.Created = value + } + if value, ok := etc.mutation.Modified(); ok { + _spec.SetField(enrollmenttoken.FieldModified, field.TypeTime, value) + _node.Modified = value + } + if nodes := etc.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.TenantTable, + Columns: []string{enrollmenttoken.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.tenant_enrollment_tokens = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := etc.mutation.SiteIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.SiteTable, + Columns: []string{enrollmenttoken.SiteColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(site.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.site_enrollment_tokens = &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.EnrollmentToken.Create(). +// SetToken(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.EnrollmentTokenUpsert) { +// SetToken(v+v). +// }). +// Exec(ctx) +func (etc *EnrollmentTokenCreate) OnConflict(opts ...sql.ConflictOption) *EnrollmentTokenUpsertOne { + etc.conflict = opts + return &EnrollmentTokenUpsertOne{ + create: etc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.EnrollmentToken.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (etc *EnrollmentTokenCreate) OnConflictColumns(columns ...string) *EnrollmentTokenUpsertOne { + etc.conflict = append(etc.conflict, sql.ConflictColumns(columns...)) + return &EnrollmentTokenUpsertOne{ + create: etc, + } +} + +type ( + // EnrollmentTokenUpsertOne is the builder for "upsert"-ing + // one EnrollmentToken node. + EnrollmentTokenUpsertOne struct { + create *EnrollmentTokenCreate + } + + // EnrollmentTokenUpsert is the "OnConflict" setter. + EnrollmentTokenUpsert struct { + *sql.UpdateSet + } +) + +// SetToken sets the "token" field. +func (u *EnrollmentTokenUpsert) SetToken(v string) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldToken, v) + return u +} + +// UpdateToken sets the "token" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateToken() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldToken) + return u +} + +// SetDescription sets the "description" field. +func (u *EnrollmentTokenUpsert) SetDescription(v string) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldDescription, v) + return u +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateDescription() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldDescription) + return u +} + +// ClearDescription clears the value of the "description" field. +func (u *EnrollmentTokenUpsert) ClearDescription() *EnrollmentTokenUpsert { + u.SetNull(enrollmenttoken.FieldDescription) + return u +} + +// SetMaxUses sets the "max_uses" field. +func (u *EnrollmentTokenUpsert) SetMaxUses(v int) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldMaxUses, v) + return u +} + +// UpdateMaxUses sets the "max_uses" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateMaxUses() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldMaxUses) + return u +} + +// AddMaxUses adds v to the "max_uses" field. +func (u *EnrollmentTokenUpsert) AddMaxUses(v int) *EnrollmentTokenUpsert { + u.Add(enrollmenttoken.FieldMaxUses, v) + return u +} + +// SetCurrentUses sets the "current_uses" field. +func (u *EnrollmentTokenUpsert) SetCurrentUses(v int) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldCurrentUses, v) + return u +} + +// UpdateCurrentUses sets the "current_uses" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateCurrentUses() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldCurrentUses) + return u +} + +// AddCurrentUses adds v to the "current_uses" field. +func (u *EnrollmentTokenUpsert) AddCurrentUses(v int) *EnrollmentTokenUpsert { + u.Add(enrollmenttoken.FieldCurrentUses, v) + return u +} + +// SetExpiresAt sets the "expires_at" field. +func (u *EnrollmentTokenUpsert) SetExpiresAt(v time.Time) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldExpiresAt, v) + return u +} + +// UpdateExpiresAt sets the "expires_at" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateExpiresAt() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldExpiresAt) + return u +} + +// ClearExpiresAt clears the value of the "expires_at" field. +func (u *EnrollmentTokenUpsert) ClearExpiresAt() *EnrollmentTokenUpsert { + u.SetNull(enrollmenttoken.FieldExpiresAt) + return u +} + +// SetActive sets the "active" field. +func (u *EnrollmentTokenUpsert) SetActive(v bool) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldActive, v) + return u +} + +// UpdateActive sets the "active" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateActive() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldActive) + return u +} + +// SetCreated sets the "created" field. +func (u *EnrollmentTokenUpsert) SetCreated(v time.Time) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldCreated, v) + return u +} + +// UpdateCreated sets the "created" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateCreated() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldCreated) + return u +} + +// ClearCreated clears the value of the "created" field. +func (u *EnrollmentTokenUpsert) ClearCreated() *EnrollmentTokenUpsert { + u.SetNull(enrollmenttoken.FieldCreated) + return u +} + +// SetModified sets the "modified" field. +func (u *EnrollmentTokenUpsert) SetModified(v time.Time) *EnrollmentTokenUpsert { + u.Set(enrollmenttoken.FieldModified, v) + return u +} + +// UpdateModified sets the "modified" field to the value that was provided on create. +func (u *EnrollmentTokenUpsert) UpdateModified() *EnrollmentTokenUpsert { + u.SetExcluded(enrollmenttoken.FieldModified) + return u +} + +// ClearModified clears the value of the "modified" field. +func (u *EnrollmentTokenUpsert) ClearModified() *EnrollmentTokenUpsert { + u.SetNull(enrollmenttoken.FieldModified) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.EnrollmentToken.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *EnrollmentTokenUpsertOne) UpdateNewValues() *EnrollmentTokenUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.EnrollmentToken.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *EnrollmentTokenUpsertOne) Ignore() *EnrollmentTokenUpsertOne { + 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 *EnrollmentTokenUpsertOne) DoNothing() *EnrollmentTokenUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the EnrollmentTokenCreate.OnConflict +// documentation for more info. +func (u *EnrollmentTokenUpsertOne) Update(set func(*EnrollmentTokenUpsert)) *EnrollmentTokenUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&EnrollmentTokenUpsert{UpdateSet: update}) + })) + return u +} + +// SetToken sets the "token" field. +func (u *EnrollmentTokenUpsertOne) SetToken(v string) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetToken(v) + }) +} + +// UpdateToken sets the "token" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateToken() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateToken() + }) +} + +// SetDescription sets the "description" field. +func (u *EnrollmentTokenUpsertOne) SetDescription(v string) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateDescription() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *EnrollmentTokenUpsertOne) ClearDescription() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearDescription() + }) +} + +// SetMaxUses sets the "max_uses" field. +func (u *EnrollmentTokenUpsertOne) SetMaxUses(v int) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetMaxUses(v) + }) +} + +// AddMaxUses adds v to the "max_uses" field. +func (u *EnrollmentTokenUpsertOne) AddMaxUses(v int) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.AddMaxUses(v) + }) +} + +// UpdateMaxUses sets the "max_uses" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateMaxUses() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateMaxUses() + }) +} + +// SetCurrentUses sets the "current_uses" field. +func (u *EnrollmentTokenUpsertOne) SetCurrentUses(v int) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetCurrentUses(v) + }) +} + +// AddCurrentUses adds v to the "current_uses" field. +func (u *EnrollmentTokenUpsertOne) AddCurrentUses(v int) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.AddCurrentUses(v) + }) +} + +// UpdateCurrentUses sets the "current_uses" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateCurrentUses() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateCurrentUses() + }) +} + +// SetExpiresAt sets the "expires_at" field. +func (u *EnrollmentTokenUpsertOne) SetExpiresAt(v time.Time) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetExpiresAt(v) + }) +} + +// UpdateExpiresAt sets the "expires_at" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateExpiresAt() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateExpiresAt() + }) +} + +// ClearExpiresAt clears the value of the "expires_at" field. +func (u *EnrollmentTokenUpsertOne) ClearExpiresAt() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearExpiresAt() + }) +} + +// SetActive sets the "active" field. +func (u *EnrollmentTokenUpsertOne) SetActive(v bool) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetActive(v) + }) +} + +// UpdateActive sets the "active" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateActive() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateActive() + }) +} + +// SetCreated sets the "created" field. +func (u *EnrollmentTokenUpsertOne) SetCreated(v time.Time) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetCreated(v) + }) +} + +// UpdateCreated sets the "created" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateCreated() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateCreated() + }) +} + +// ClearCreated clears the value of the "created" field. +func (u *EnrollmentTokenUpsertOne) ClearCreated() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearCreated() + }) +} + +// SetModified sets the "modified" field. +func (u *EnrollmentTokenUpsertOne) SetModified(v time.Time) *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetModified(v) + }) +} + +// UpdateModified sets the "modified" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertOne) UpdateModified() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateModified() + }) +} + +// ClearModified clears the value of the "modified" field. +func (u *EnrollmentTokenUpsertOne) ClearModified() *EnrollmentTokenUpsertOne { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearModified() + }) +} + +// Exec executes the query. +func (u *EnrollmentTokenUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for EnrollmentTokenCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *EnrollmentTokenUpsertOne) 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 *EnrollmentTokenUpsertOne) ID(ctx context.Context) (id int, 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 *EnrollmentTokenUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// EnrollmentTokenCreateBulk is the builder for creating many EnrollmentToken entities in bulk. +type EnrollmentTokenCreateBulk struct { + config + err error + builders []*EnrollmentTokenCreate + conflict []sql.ConflictOption +} + +// Save creates the EnrollmentToken entities in the database. +func (etcb *EnrollmentTokenCreateBulk) Save(ctx context.Context) ([]*EnrollmentToken, error) { + if etcb.err != nil { + return nil, etcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(etcb.builders)) + nodes := make([]*EnrollmentToken, len(etcb.builders)) + mutators := make([]Mutator, len(etcb.builders)) + for i := range etcb.builders { + func(i int, root context.Context) { + builder := etcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*EnrollmentTokenMutation) + 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, etcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = etcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, etcb.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 = int(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, etcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (etcb *EnrollmentTokenCreateBulk) SaveX(ctx context.Context) []*EnrollmentToken { + v, err := etcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (etcb *EnrollmentTokenCreateBulk) Exec(ctx context.Context) error { + _, err := etcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (etcb *EnrollmentTokenCreateBulk) ExecX(ctx context.Context) { + if err := etcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.EnrollmentToken.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.EnrollmentTokenUpsert) { +// SetToken(v+v). +// }). +// Exec(ctx) +func (etcb *EnrollmentTokenCreateBulk) OnConflict(opts ...sql.ConflictOption) *EnrollmentTokenUpsertBulk { + etcb.conflict = opts + return &EnrollmentTokenUpsertBulk{ + create: etcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.EnrollmentToken.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (etcb *EnrollmentTokenCreateBulk) OnConflictColumns(columns ...string) *EnrollmentTokenUpsertBulk { + etcb.conflict = append(etcb.conflict, sql.ConflictColumns(columns...)) + return &EnrollmentTokenUpsertBulk{ + create: etcb, + } +} + +// EnrollmentTokenUpsertBulk is the builder for "upsert"-ing +// a bulk of EnrollmentToken nodes. +type EnrollmentTokenUpsertBulk struct { + create *EnrollmentTokenCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.EnrollmentToken.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *EnrollmentTokenUpsertBulk) UpdateNewValues() *EnrollmentTokenUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.EnrollmentToken.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *EnrollmentTokenUpsertBulk) Ignore() *EnrollmentTokenUpsertBulk { + 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 *EnrollmentTokenUpsertBulk) DoNothing() *EnrollmentTokenUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the EnrollmentTokenCreateBulk.OnConflict +// documentation for more info. +func (u *EnrollmentTokenUpsertBulk) Update(set func(*EnrollmentTokenUpsert)) *EnrollmentTokenUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&EnrollmentTokenUpsert{UpdateSet: update}) + })) + return u +} + +// SetToken sets the "token" field. +func (u *EnrollmentTokenUpsertBulk) SetToken(v string) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetToken(v) + }) +} + +// UpdateToken sets the "token" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateToken() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateToken() + }) +} + +// SetDescription sets the "description" field. +func (u *EnrollmentTokenUpsertBulk) SetDescription(v string) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetDescription(v) + }) +} + +// UpdateDescription sets the "description" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateDescription() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateDescription() + }) +} + +// ClearDescription clears the value of the "description" field. +func (u *EnrollmentTokenUpsertBulk) ClearDescription() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearDescription() + }) +} + +// SetMaxUses sets the "max_uses" field. +func (u *EnrollmentTokenUpsertBulk) SetMaxUses(v int) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetMaxUses(v) + }) +} + +// AddMaxUses adds v to the "max_uses" field. +func (u *EnrollmentTokenUpsertBulk) AddMaxUses(v int) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.AddMaxUses(v) + }) +} + +// UpdateMaxUses sets the "max_uses" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateMaxUses() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateMaxUses() + }) +} + +// SetCurrentUses sets the "current_uses" field. +func (u *EnrollmentTokenUpsertBulk) SetCurrentUses(v int) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetCurrentUses(v) + }) +} + +// AddCurrentUses adds v to the "current_uses" field. +func (u *EnrollmentTokenUpsertBulk) AddCurrentUses(v int) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.AddCurrentUses(v) + }) +} + +// UpdateCurrentUses sets the "current_uses" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateCurrentUses() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateCurrentUses() + }) +} + +// SetExpiresAt sets the "expires_at" field. +func (u *EnrollmentTokenUpsertBulk) SetExpiresAt(v time.Time) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetExpiresAt(v) + }) +} + +// UpdateExpiresAt sets the "expires_at" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateExpiresAt() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateExpiresAt() + }) +} + +// ClearExpiresAt clears the value of the "expires_at" field. +func (u *EnrollmentTokenUpsertBulk) ClearExpiresAt() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearExpiresAt() + }) +} + +// SetActive sets the "active" field. +func (u *EnrollmentTokenUpsertBulk) SetActive(v bool) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetActive(v) + }) +} + +// UpdateActive sets the "active" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateActive() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateActive() + }) +} + +// SetCreated sets the "created" field. +func (u *EnrollmentTokenUpsertBulk) SetCreated(v time.Time) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetCreated(v) + }) +} + +// UpdateCreated sets the "created" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateCreated() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateCreated() + }) +} + +// ClearCreated clears the value of the "created" field. +func (u *EnrollmentTokenUpsertBulk) ClearCreated() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearCreated() + }) +} + +// SetModified sets the "modified" field. +func (u *EnrollmentTokenUpsertBulk) SetModified(v time.Time) *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.SetModified(v) + }) +} + +// UpdateModified sets the "modified" field to the value that was provided on create. +func (u *EnrollmentTokenUpsertBulk) UpdateModified() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.UpdateModified() + }) +} + +// ClearModified clears the value of the "modified" field. +func (u *EnrollmentTokenUpsertBulk) ClearModified() *EnrollmentTokenUpsertBulk { + return u.Update(func(s *EnrollmentTokenUpsert) { + s.ClearModified() + }) +} + +// Exec executes the query. +func (u *EnrollmentTokenUpsertBulk) 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 EnrollmentTokenCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for EnrollmentTokenCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *EnrollmentTokenUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/enrollmenttoken_delete.go b/enrollmenttoken_delete.go new file mode 100644 index 0000000..e57694b --- /dev/null +++ b/enrollmenttoken_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/enrollmenttoken" + "github.com/open-uem/ent/predicate" +) + +// EnrollmentTokenDelete is the builder for deleting a EnrollmentToken entity. +type EnrollmentTokenDelete struct { + config + hooks []Hook + mutation *EnrollmentTokenMutation +} + +// Where appends a list predicates to the EnrollmentTokenDelete builder. +func (etd *EnrollmentTokenDelete) Where(ps ...predicate.EnrollmentToken) *EnrollmentTokenDelete { + etd.mutation.Where(ps...) + return etd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (etd *EnrollmentTokenDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, etd.sqlExec, etd.mutation, etd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (etd *EnrollmentTokenDelete) ExecX(ctx context.Context) int { + n, err := etd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (etd *EnrollmentTokenDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(enrollmenttoken.Table, sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt)) + if ps := etd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, etd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + etd.mutation.done = true + return affected, err +} + +// EnrollmentTokenDeleteOne is the builder for deleting a single EnrollmentToken entity. +type EnrollmentTokenDeleteOne struct { + etd *EnrollmentTokenDelete +} + +// Where appends a list predicates to the EnrollmentTokenDelete builder. +func (etdo *EnrollmentTokenDeleteOne) Where(ps ...predicate.EnrollmentToken) *EnrollmentTokenDeleteOne { + etdo.etd.mutation.Where(ps...) + return etdo +} + +// Exec executes the deletion query. +func (etdo *EnrollmentTokenDeleteOne) Exec(ctx context.Context) error { + n, err := etdo.etd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{enrollmenttoken.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (etdo *EnrollmentTokenDeleteOne) ExecX(ctx context.Context) { + if err := etdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/enrollmenttoken_query.go b/enrollmenttoken_query.go new file mode 100644 index 0000000..92e26e6 --- /dev/null +++ b/enrollmenttoken_query.go @@ -0,0 +1,712 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/enrollmenttoken" + "github.com/open-uem/ent/predicate" + "github.com/open-uem/ent/site" + "github.com/open-uem/ent/tenant" +) + +// EnrollmentTokenQuery is the builder for querying EnrollmentToken entities. +type EnrollmentTokenQuery struct { + config + ctx *QueryContext + order []enrollmenttoken.OrderOption + inters []Interceptor + predicates []predicate.EnrollmentToken + withTenant *TenantQuery + withSite *SiteQuery + withFKs bool + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the EnrollmentTokenQuery builder. +func (etq *EnrollmentTokenQuery) Where(ps ...predicate.EnrollmentToken) *EnrollmentTokenQuery { + etq.predicates = append(etq.predicates, ps...) + return etq +} + +// Limit the number of records to be returned by this query. +func (etq *EnrollmentTokenQuery) Limit(limit int) *EnrollmentTokenQuery { + etq.ctx.Limit = &limit + return etq +} + +// Offset to start from. +func (etq *EnrollmentTokenQuery) Offset(offset int) *EnrollmentTokenQuery { + etq.ctx.Offset = &offset + return etq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (etq *EnrollmentTokenQuery) Unique(unique bool) *EnrollmentTokenQuery { + etq.ctx.Unique = &unique + return etq +} + +// Order specifies how the records should be ordered. +func (etq *EnrollmentTokenQuery) Order(o ...enrollmenttoken.OrderOption) *EnrollmentTokenQuery { + etq.order = append(etq.order, o...) + return etq +} + +// QueryTenant chains the current query on the "tenant" edge. +func (etq *EnrollmentTokenQuery) QueryTenant() *TenantQuery { + query := (&TenantClient{config: etq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := etq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := etq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(enrollmenttoken.Table, enrollmenttoken.FieldID, selector), + sqlgraph.To(tenant.Table, tenant.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, enrollmenttoken.TenantTable, enrollmenttoken.TenantColumn), + ) + fromU = sqlgraph.SetNeighbors(etq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QuerySite chains the current query on the "site" edge. +func (etq *EnrollmentTokenQuery) QuerySite() *SiteQuery { + query := (&SiteClient{config: etq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := etq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := etq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(enrollmenttoken.Table, enrollmenttoken.FieldID, selector), + sqlgraph.To(site.Table, site.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, enrollmenttoken.SiteTable, enrollmenttoken.SiteColumn), + ) + fromU = sqlgraph.SetNeighbors(etq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first EnrollmentToken entity from the query. +// Returns a *NotFoundError when no EnrollmentToken was found. +func (etq *EnrollmentTokenQuery) First(ctx context.Context) (*EnrollmentToken, error) { + nodes, err := etq.Limit(1).All(setContextOp(ctx, etq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{enrollmenttoken.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) FirstX(ctx context.Context) *EnrollmentToken { + node, err := etq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first EnrollmentToken ID from the query. +// Returns a *NotFoundError when no EnrollmentToken ID was found. +func (etq *EnrollmentTokenQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = etq.Limit(1).IDs(setContextOp(ctx, etq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{enrollmenttoken.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) FirstIDX(ctx context.Context) int { + id, err := etq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single EnrollmentToken entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one EnrollmentToken entity is found. +// Returns a *NotFoundError when no EnrollmentToken entities are found. +func (etq *EnrollmentTokenQuery) Only(ctx context.Context) (*EnrollmentToken, error) { + nodes, err := etq.Limit(2).All(setContextOp(ctx, etq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{enrollmenttoken.Label} + default: + return nil, &NotSingularError{enrollmenttoken.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) OnlyX(ctx context.Context) *EnrollmentToken { + node, err := etq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only EnrollmentToken ID in the query. +// Returns a *NotSingularError when more than one EnrollmentToken ID is found. +// Returns a *NotFoundError when no entities are found. +func (etq *EnrollmentTokenQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = etq.Limit(2).IDs(setContextOp(ctx, etq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{enrollmenttoken.Label} + default: + err = &NotSingularError{enrollmenttoken.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) OnlyIDX(ctx context.Context) int { + id, err := etq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of EnrollmentTokens. +func (etq *EnrollmentTokenQuery) All(ctx context.Context) ([]*EnrollmentToken, error) { + ctx = setContextOp(ctx, etq.ctx, ent.OpQueryAll) + if err := etq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*EnrollmentToken, *EnrollmentTokenQuery]() + return withInterceptors[[]*EnrollmentToken](ctx, etq, qr, etq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) AllX(ctx context.Context) []*EnrollmentToken { + nodes, err := etq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of EnrollmentToken IDs. +func (etq *EnrollmentTokenQuery) IDs(ctx context.Context) (ids []int, err error) { + if etq.ctx.Unique == nil && etq.path != nil { + etq.Unique(true) + } + ctx = setContextOp(ctx, etq.ctx, ent.OpQueryIDs) + if err = etq.Select(enrollmenttoken.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) IDsX(ctx context.Context) []int { + ids, err := etq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (etq *EnrollmentTokenQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, etq.ctx, ent.OpQueryCount) + if err := etq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, etq, querierCount[*EnrollmentTokenQuery](), etq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) CountX(ctx context.Context) int { + count, err := etq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (etq *EnrollmentTokenQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, etq.ctx, ent.OpQueryExist) + switch _, err := etq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (etq *EnrollmentTokenQuery) ExistX(ctx context.Context) bool { + exist, err := etq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the EnrollmentTokenQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (etq *EnrollmentTokenQuery) Clone() *EnrollmentTokenQuery { + if etq == nil { + return nil + } + return &EnrollmentTokenQuery{ + config: etq.config, + ctx: etq.ctx.Clone(), + order: append([]enrollmenttoken.OrderOption{}, etq.order...), + inters: append([]Interceptor{}, etq.inters...), + predicates: append([]predicate.EnrollmentToken{}, etq.predicates...), + withTenant: etq.withTenant.Clone(), + withSite: etq.withSite.Clone(), + // clone intermediate query. + sql: etq.sql.Clone(), + path: etq.path, + modifiers: append([]func(*sql.Selector){}, etq.modifiers...), + } +} + +// WithTenant tells the query-builder to eager-load the nodes that are connected to +// the "tenant" edge. The optional arguments are used to configure the query builder of the edge. +func (etq *EnrollmentTokenQuery) WithTenant(opts ...func(*TenantQuery)) *EnrollmentTokenQuery { + query := (&TenantClient{config: etq.config}).Query() + for _, opt := range opts { + opt(query) + } + etq.withTenant = query + return etq +} + +// WithSite tells the query-builder to eager-load the nodes that are connected to +// the "site" edge. The optional arguments are used to configure the query builder of the edge. +func (etq *EnrollmentTokenQuery) WithSite(opts ...func(*SiteQuery)) *EnrollmentTokenQuery { + query := (&SiteClient{config: etq.config}).Query() + for _, opt := range opts { + opt(query) + } + etq.withSite = query + return etq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Token string `json:"token,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.EnrollmentToken.Query(). +// GroupBy(enrollmenttoken.FieldToken). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (etq *EnrollmentTokenQuery) GroupBy(field string, fields ...string) *EnrollmentTokenGroupBy { + etq.ctx.Fields = append([]string{field}, fields...) + grbuild := &EnrollmentTokenGroupBy{build: etq} + grbuild.flds = &etq.ctx.Fields + grbuild.label = enrollmenttoken.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Token string `json:"token,omitempty"` +// } +// +// client.EnrollmentToken.Query(). +// Select(enrollmenttoken.FieldToken). +// Scan(ctx, &v) +func (etq *EnrollmentTokenQuery) Select(fields ...string) *EnrollmentTokenSelect { + etq.ctx.Fields = append(etq.ctx.Fields, fields...) + sbuild := &EnrollmentTokenSelect{EnrollmentTokenQuery: etq} + sbuild.label = enrollmenttoken.Label + sbuild.flds, sbuild.scan = &etq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a EnrollmentTokenSelect configured with the given aggregations. +func (etq *EnrollmentTokenQuery) Aggregate(fns ...AggregateFunc) *EnrollmentTokenSelect { + return etq.Select().Aggregate(fns...) +} + +func (etq *EnrollmentTokenQuery) prepareQuery(ctx context.Context) error { + for _, inter := range etq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, etq); err != nil { + return err + } + } + } + for _, f := range etq.ctx.Fields { + if !enrollmenttoken.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if etq.path != nil { + prev, err := etq.path(ctx) + if err != nil { + return err + } + etq.sql = prev + } + return nil +} + +func (etq *EnrollmentTokenQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*EnrollmentToken, error) { + var ( + nodes = []*EnrollmentToken{} + withFKs = etq.withFKs + _spec = etq.querySpec() + loadedTypes = [2]bool{ + etq.withTenant != nil, + etq.withSite != nil, + } + ) + if etq.withTenant != nil || etq.withSite != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, enrollmenttoken.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*EnrollmentToken).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &EnrollmentToken{config: etq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(etq.modifiers) > 0 { + _spec.Modifiers = etq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, etq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := etq.withTenant; query != nil { + if err := etq.loadTenant(ctx, query, nodes, nil, + func(n *EnrollmentToken, e *Tenant) { n.Edges.Tenant = e }); err != nil { + return nil, err + } + } + if query := etq.withSite; query != nil { + if err := etq.loadSite(ctx, query, nodes, nil, + func(n *EnrollmentToken, e *Site) { n.Edges.Site = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (etq *EnrollmentTokenQuery) loadTenant(ctx context.Context, query *TenantQuery, nodes []*EnrollmentToken, init func(*EnrollmentToken), assign func(*EnrollmentToken, *Tenant)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*EnrollmentToken) + for i := range nodes { + if nodes[i].tenant_enrollment_tokens == nil { + continue + } + fk := *nodes[i].tenant_enrollment_tokens + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(tenant.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "tenant_enrollment_tokens" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (etq *EnrollmentTokenQuery) loadSite(ctx context.Context, query *SiteQuery, nodes []*EnrollmentToken, init func(*EnrollmentToken), assign func(*EnrollmentToken, *Site)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*EnrollmentToken) + for i := range nodes { + if nodes[i].site_enrollment_tokens == nil { + continue + } + fk := *nodes[i].site_enrollment_tokens + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(site.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "site_enrollment_tokens" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (etq *EnrollmentTokenQuery) sqlCount(ctx context.Context) (int, error) { + _spec := etq.querySpec() + if len(etq.modifiers) > 0 { + _spec.Modifiers = etq.modifiers + } + _spec.Node.Columns = etq.ctx.Fields + if len(etq.ctx.Fields) > 0 { + _spec.Unique = etq.ctx.Unique != nil && *etq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, etq.driver, _spec) +} + +func (etq *EnrollmentTokenQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(enrollmenttoken.Table, enrollmenttoken.Columns, sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt)) + _spec.From = etq.sql + if unique := etq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if etq.path != nil { + _spec.Unique = true + } + if fields := etq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, enrollmenttoken.FieldID) + for i := range fields { + if fields[i] != enrollmenttoken.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := etq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := etq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := etq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := etq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (etq *EnrollmentTokenQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(etq.driver.Dialect()) + t1 := builder.Table(enrollmenttoken.Table) + columns := etq.ctx.Fields + if len(columns) == 0 { + columns = enrollmenttoken.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if etq.sql != nil { + selector = etq.sql + selector.Select(selector.Columns(columns...)...) + } + if etq.ctx.Unique != nil && *etq.ctx.Unique { + selector.Distinct() + } + for _, m := range etq.modifiers { + m(selector) + } + for _, p := range etq.predicates { + p(selector) + } + for _, p := range etq.order { + p(selector) + } + if offset := etq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := etq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (etq *EnrollmentTokenQuery) Modify(modifiers ...func(s *sql.Selector)) *EnrollmentTokenSelect { + etq.modifiers = append(etq.modifiers, modifiers...) + return etq.Select() +} + +// EnrollmentTokenGroupBy is the group-by builder for EnrollmentToken entities. +type EnrollmentTokenGroupBy struct { + selector + build *EnrollmentTokenQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (etgb *EnrollmentTokenGroupBy) Aggregate(fns ...AggregateFunc) *EnrollmentTokenGroupBy { + etgb.fns = append(etgb.fns, fns...) + return etgb +} + +// Scan applies the selector query and scans the result into the given value. +func (etgb *EnrollmentTokenGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, etgb.build.ctx, ent.OpQueryGroupBy) + if err := etgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EnrollmentTokenQuery, *EnrollmentTokenGroupBy](ctx, etgb.build, etgb, etgb.build.inters, v) +} + +func (etgb *EnrollmentTokenGroupBy) sqlScan(ctx context.Context, root *EnrollmentTokenQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(etgb.fns)) + for _, fn := range etgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*etgb.flds)+len(etgb.fns)) + for _, f := range *etgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*etgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := etgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// EnrollmentTokenSelect is the builder for selecting fields of EnrollmentToken entities. +type EnrollmentTokenSelect struct { + *EnrollmentTokenQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ets *EnrollmentTokenSelect) Aggregate(fns ...AggregateFunc) *EnrollmentTokenSelect { + ets.fns = append(ets.fns, fns...) + return ets +} + +// Scan applies the selector query and scans the result into the given value. +func (ets *EnrollmentTokenSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ets.ctx, ent.OpQuerySelect) + if err := ets.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*EnrollmentTokenQuery, *EnrollmentTokenSelect](ctx, ets.EnrollmentTokenQuery, ets, ets.inters, v) +} + +func (ets *EnrollmentTokenSelect) sqlScan(ctx context.Context, root *EnrollmentTokenQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ets.fns)) + for _, fn := range ets.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ets.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ets.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (ets *EnrollmentTokenSelect) Modify(modifiers ...func(s *sql.Selector)) *EnrollmentTokenSelect { + ets.modifiers = append(ets.modifiers, modifiers...) + return ets +} diff --git a/enrollmenttoken_update.go b/enrollmenttoken_update.go new file mode 100644 index 0000000..9d1b896 --- /dev/null +++ b/enrollmenttoken_update.go @@ -0,0 +1,812 @@ +// 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/open-uem/ent/enrollmenttoken" + "github.com/open-uem/ent/predicate" + "github.com/open-uem/ent/site" + "github.com/open-uem/ent/tenant" +) + +// EnrollmentTokenUpdate is the builder for updating EnrollmentToken entities. +type EnrollmentTokenUpdate struct { + config + hooks []Hook + mutation *EnrollmentTokenMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the EnrollmentTokenUpdate builder. +func (etu *EnrollmentTokenUpdate) Where(ps ...predicate.EnrollmentToken) *EnrollmentTokenUpdate { + etu.mutation.Where(ps...) + return etu +} + +// SetToken sets the "token" field. +func (etu *EnrollmentTokenUpdate) SetToken(s string) *EnrollmentTokenUpdate { + etu.mutation.SetToken(s) + return etu +} + +// SetNillableToken sets the "token" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableToken(s *string) *EnrollmentTokenUpdate { + if s != nil { + etu.SetToken(*s) + } + return etu +} + +// SetDescription sets the "description" field. +func (etu *EnrollmentTokenUpdate) SetDescription(s string) *EnrollmentTokenUpdate { + etu.mutation.SetDescription(s) + return etu +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableDescription(s *string) *EnrollmentTokenUpdate { + if s != nil { + etu.SetDescription(*s) + } + return etu +} + +// ClearDescription clears the value of the "description" field. +func (etu *EnrollmentTokenUpdate) ClearDescription() *EnrollmentTokenUpdate { + etu.mutation.ClearDescription() + return etu +} + +// SetMaxUses sets the "max_uses" field. +func (etu *EnrollmentTokenUpdate) SetMaxUses(i int) *EnrollmentTokenUpdate { + etu.mutation.ResetMaxUses() + etu.mutation.SetMaxUses(i) + return etu +} + +// SetNillableMaxUses sets the "max_uses" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableMaxUses(i *int) *EnrollmentTokenUpdate { + if i != nil { + etu.SetMaxUses(*i) + } + return etu +} + +// AddMaxUses adds i to the "max_uses" field. +func (etu *EnrollmentTokenUpdate) AddMaxUses(i int) *EnrollmentTokenUpdate { + etu.mutation.AddMaxUses(i) + return etu +} + +// SetCurrentUses sets the "current_uses" field. +func (etu *EnrollmentTokenUpdate) SetCurrentUses(i int) *EnrollmentTokenUpdate { + etu.mutation.ResetCurrentUses() + etu.mutation.SetCurrentUses(i) + return etu +} + +// SetNillableCurrentUses sets the "current_uses" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableCurrentUses(i *int) *EnrollmentTokenUpdate { + if i != nil { + etu.SetCurrentUses(*i) + } + return etu +} + +// AddCurrentUses adds i to the "current_uses" field. +func (etu *EnrollmentTokenUpdate) AddCurrentUses(i int) *EnrollmentTokenUpdate { + etu.mutation.AddCurrentUses(i) + return etu +} + +// SetExpiresAt sets the "expires_at" field. +func (etu *EnrollmentTokenUpdate) SetExpiresAt(t time.Time) *EnrollmentTokenUpdate { + etu.mutation.SetExpiresAt(t) + return etu +} + +// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableExpiresAt(t *time.Time) *EnrollmentTokenUpdate { + if t != nil { + etu.SetExpiresAt(*t) + } + return etu +} + +// ClearExpiresAt clears the value of the "expires_at" field. +func (etu *EnrollmentTokenUpdate) ClearExpiresAt() *EnrollmentTokenUpdate { + etu.mutation.ClearExpiresAt() + return etu +} + +// SetActive sets the "active" field. +func (etu *EnrollmentTokenUpdate) SetActive(b bool) *EnrollmentTokenUpdate { + etu.mutation.SetActive(b) + return etu +} + +// SetNillableActive sets the "active" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableActive(b *bool) *EnrollmentTokenUpdate { + if b != nil { + etu.SetActive(*b) + } + return etu +} + +// SetCreated sets the "created" field. +func (etu *EnrollmentTokenUpdate) SetCreated(t time.Time) *EnrollmentTokenUpdate { + etu.mutation.SetCreated(t) + return etu +} + +// SetNillableCreated sets the "created" field if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableCreated(t *time.Time) *EnrollmentTokenUpdate { + if t != nil { + etu.SetCreated(*t) + } + return etu +} + +// ClearCreated clears the value of the "created" field. +func (etu *EnrollmentTokenUpdate) ClearCreated() *EnrollmentTokenUpdate { + etu.mutation.ClearCreated() + return etu +} + +// SetModified sets the "modified" field. +func (etu *EnrollmentTokenUpdate) SetModified(t time.Time) *EnrollmentTokenUpdate { + etu.mutation.SetModified(t) + return etu +} + +// ClearModified clears the value of the "modified" field. +func (etu *EnrollmentTokenUpdate) ClearModified() *EnrollmentTokenUpdate { + etu.mutation.ClearModified() + return etu +} + +// SetTenantID sets the "tenant" edge to the Tenant entity by ID. +func (etu *EnrollmentTokenUpdate) SetTenantID(id int) *EnrollmentTokenUpdate { + etu.mutation.SetTenantID(id) + return etu +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (etu *EnrollmentTokenUpdate) SetTenant(t *Tenant) *EnrollmentTokenUpdate { + return etu.SetTenantID(t.ID) +} + +// SetSiteID sets the "site" edge to the Site entity by ID. +func (etu *EnrollmentTokenUpdate) SetSiteID(id int) *EnrollmentTokenUpdate { + etu.mutation.SetSiteID(id) + return etu +} + +// SetNillableSiteID sets the "site" edge to the Site entity by ID if the given value is not nil. +func (etu *EnrollmentTokenUpdate) SetNillableSiteID(id *int) *EnrollmentTokenUpdate { + if id != nil { + etu = etu.SetSiteID(*id) + } + return etu +} + +// SetSite sets the "site" edge to the Site entity. +func (etu *EnrollmentTokenUpdate) SetSite(s *Site) *EnrollmentTokenUpdate { + return etu.SetSiteID(s.ID) +} + +// Mutation returns the EnrollmentTokenMutation object of the builder. +func (etu *EnrollmentTokenUpdate) Mutation() *EnrollmentTokenMutation { + return etu.mutation +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (etu *EnrollmentTokenUpdate) ClearTenant() *EnrollmentTokenUpdate { + etu.mutation.ClearTenant() + return etu +} + +// ClearSite clears the "site" edge to the Site entity. +func (etu *EnrollmentTokenUpdate) ClearSite() *EnrollmentTokenUpdate { + etu.mutation.ClearSite() + return etu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (etu *EnrollmentTokenUpdate) Save(ctx context.Context) (int, error) { + etu.defaults() + return withHooks(ctx, etu.sqlSave, etu.mutation, etu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (etu *EnrollmentTokenUpdate) SaveX(ctx context.Context) int { + affected, err := etu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (etu *EnrollmentTokenUpdate) Exec(ctx context.Context) error { + _, err := etu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (etu *EnrollmentTokenUpdate) ExecX(ctx context.Context) { + if err := etu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (etu *EnrollmentTokenUpdate) defaults() { + if _, ok := etu.mutation.Modified(); !ok && !etu.mutation.ModifiedCleared() { + v := enrollmenttoken.UpdateDefaultModified() + etu.mutation.SetModified(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (etu *EnrollmentTokenUpdate) check() error { + if v, ok := etu.mutation.Token(); ok { + if err := enrollmenttoken.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "EnrollmentToken.token": %w`, err)} + } + } + if etu.mutation.TenantCleared() && len(etu.mutation.TenantIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "EnrollmentToken.tenant"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (etu *EnrollmentTokenUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EnrollmentTokenUpdate { + etu.modifiers = append(etu.modifiers, modifiers...) + return etu +} + +func (etu *EnrollmentTokenUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := etu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(enrollmenttoken.Table, enrollmenttoken.Columns, sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt)) + if ps := etu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := etu.mutation.Token(); ok { + _spec.SetField(enrollmenttoken.FieldToken, field.TypeString, value) + } + if value, ok := etu.mutation.Description(); ok { + _spec.SetField(enrollmenttoken.FieldDescription, field.TypeString, value) + } + if etu.mutation.DescriptionCleared() { + _spec.ClearField(enrollmenttoken.FieldDescription, field.TypeString) + } + if value, ok := etu.mutation.MaxUses(); ok { + _spec.SetField(enrollmenttoken.FieldMaxUses, field.TypeInt, value) + } + if value, ok := etu.mutation.AddedMaxUses(); ok { + _spec.AddField(enrollmenttoken.FieldMaxUses, field.TypeInt, value) + } + if value, ok := etu.mutation.CurrentUses(); ok { + _spec.SetField(enrollmenttoken.FieldCurrentUses, field.TypeInt, value) + } + if value, ok := etu.mutation.AddedCurrentUses(); ok { + _spec.AddField(enrollmenttoken.FieldCurrentUses, field.TypeInt, value) + } + if value, ok := etu.mutation.ExpiresAt(); ok { + _spec.SetField(enrollmenttoken.FieldExpiresAt, field.TypeTime, value) + } + if etu.mutation.ExpiresAtCleared() { + _spec.ClearField(enrollmenttoken.FieldExpiresAt, field.TypeTime) + } + if value, ok := etu.mutation.Active(); ok { + _spec.SetField(enrollmenttoken.FieldActive, field.TypeBool, value) + } + if value, ok := etu.mutation.Created(); ok { + _spec.SetField(enrollmenttoken.FieldCreated, field.TypeTime, value) + } + if etu.mutation.CreatedCleared() { + _spec.ClearField(enrollmenttoken.FieldCreated, field.TypeTime) + } + if value, ok := etu.mutation.Modified(); ok { + _spec.SetField(enrollmenttoken.FieldModified, field.TypeTime, value) + } + if etu.mutation.ModifiedCleared() { + _spec.ClearField(enrollmenttoken.FieldModified, field.TypeTime) + } + if etu.mutation.TenantCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.TenantTable, + Columns: []string{enrollmenttoken.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := etu.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.TenantTable, + Columns: []string{enrollmenttoken.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if etu.mutation.SiteCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.SiteTable, + Columns: []string{enrollmenttoken.SiteColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(site.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := etu.mutation.SiteIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.SiteTable, + Columns: []string{enrollmenttoken.SiteColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(site.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(etu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, etu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{enrollmenttoken.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + etu.mutation.done = true + return n, nil +} + +// EnrollmentTokenUpdateOne is the builder for updating a single EnrollmentToken entity. +type EnrollmentTokenUpdateOne struct { + config + fields []string + hooks []Hook + mutation *EnrollmentTokenMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetToken sets the "token" field. +func (etuo *EnrollmentTokenUpdateOne) SetToken(s string) *EnrollmentTokenUpdateOne { + etuo.mutation.SetToken(s) + return etuo +} + +// SetNillableToken sets the "token" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableToken(s *string) *EnrollmentTokenUpdateOne { + if s != nil { + etuo.SetToken(*s) + } + return etuo +} + +// SetDescription sets the "description" field. +func (etuo *EnrollmentTokenUpdateOne) SetDescription(s string) *EnrollmentTokenUpdateOne { + etuo.mutation.SetDescription(s) + return etuo +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableDescription(s *string) *EnrollmentTokenUpdateOne { + if s != nil { + etuo.SetDescription(*s) + } + return etuo +} + +// ClearDescription clears the value of the "description" field. +func (etuo *EnrollmentTokenUpdateOne) ClearDescription() *EnrollmentTokenUpdateOne { + etuo.mutation.ClearDescription() + return etuo +} + +// SetMaxUses sets the "max_uses" field. +func (etuo *EnrollmentTokenUpdateOne) SetMaxUses(i int) *EnrollmentTokenUpdateOne { + etuo.mutation.ResetMaxUses() + etuo.mutation.SetMaxUses(i) + return etuo +} + +// SetNillableMaxUses sets the "max_uses" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableMaxUses(i *int) *EnrollmentTokenUpdateOne { + if i != nil { + etuo.SetMaxUses(*i) + } + return etuo +} + +// AddMaxUses adds i to the "max_uses" field. +func (etuo *EnrollmentTokenUpdateOne) AddMaxUses(i int) *EnrollmentTokenUpdateOne { + etuo.mutation.AddMaxUses(i) + return etuo +} + +// SetCurrentUses sets the "current_uses" field. +func (etuo *EnrollmentTokenUpdateOne) SetCurrentUses(i int) *EnrollmentTokenUpdateOne { + etuo.mutation.ResetCurrentUses() + etuo.mutation.SetCurrentUses(i) + return etuo +} + +// SetNillableCurrentUses sets the "current_uses" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableCurrentUses(i *int) *EnrollmentTokenUpdateOne { + if i != nil { + etuo.SetCurrentUses(*i) + } + return etuo +} + +// AddCurrentUses adds i to the "current_uses" field. +func (etuo *EnrollmentTokenUpdateOne) AddCurrentUses(i int) *EnrollmentTokenUpdateOne { + etuo.mutation.AddCurrentUses(i) + return etuo +} + +// SetExpiresAt sets the "expires_at" field. +func (etuo *EnrollmentTokenUpdateOne) SetExpiresAt(t time.Time) *EnrollmentTokenUpdateOne { + etuo.mutation.SetExpiresAt(t) + return etuo +} + +// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableExpiresAt(t *time.Time) *EnrollmentTokenUpdateOne { + if t != nil { + etuo.SetExpiresAt(*t) + } + return etuo +} + +// ClearExpiresAt clears the value of the "expires_at" field. +func (etuo *EnrollmentTokenUpdateOne) ClearExpiresAt() *EnrollmentTokenUpdateOne { + etuo.mutation.ClearExpiresAt() + return etuo +} + +// SetActive sets the "active" field. +func (etuo *EnrollmentTokenUpdateOne) SetActive(b bool) *EnrollmentTokenUpdateOne { + etuo.mutation.SetActive(b) + return etuo +} + +// SetNillableActive sets the "active" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableActive(b *bool) *EnrollmentTokenUpdateOne { + if b != nil { + etuo.SetActive(*b) + } + return etuo +} + +// SetCreated sets the "created" field. +func (etuo *EnrollmentTokenUpdateOne) SetCreated(t time.Time) *EnrollmentTokenUpdateOne { + etuo.mutation.SetCreated(t) + return etuo +} + +// SetNillableCreated sets the "created" field if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableCreated(t *time.Time) *EnrollmentTokenUpdateOne { + if t != nil { + etuo.SetCreated(*t) + } + return etuo +} + +// ClearCreated clears the value of the "created" field. +func (etuo *EnrollmentTokenUpdateOne) ClearCreated() *EnrollmentTokenUpdateOne { + etuo.mutation.ClearCreated() + return etuo +} + +// SetModified sets the "modified" field. +func (etuo *EnrollmentTokenUpdateOne) SetModified(t time.Time) *EnrollmentTokenUpdateOne { + etuo.mutation.SetModified(t) + return etuo +} + +// ClearModified clears the value of the "modified" field. +func (etuo *EnrollmentTokenUpdateOne) ClearModified() *EnrollmentTokenUpdateOne { + etuo.mutation.ClearModified() + return etuo +} + +// SetTenantID sets the "tenant" edge to the Tenant entity by ID. +func (etuo *EnrollmentTokenUpdateOne) SetTenantID(id int) *EnrollmentTokenUpdateOne { + etuo.mutation.SetTenantID(id) + return etuo +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (etuo *EnrollmentTokenUpdateOne) SetTenant(t *Tenant) *EnrollmentTokenUpdateOne { + return etuo.SetTenantID(t.ID) +} + +// SetSiteID sets the "site" edge to the Site entity by ID. +func (etuo *EnrollmentTokenUpdateOne) SetSiteID(id int) *EnrollmentTokenUpdateOne { + etuo.mutation.SetSiteID(id) + return etuo +} + +// SetNillableSiteID sets the "site" edge to the Site entity by ID if the given value is not nil. +func (etuo *EnrollmentTokenUpdateOne) SetNillableSiteID(id *int) *EnrollmentTokenUpdateOne { + if id != nil { + etuo = etuo.SetSiteID(*id) + } + return etuo +} + +// SetSite sets the "site" edge to the Site entity. +func (etuo *EnrollmentTokenUpdateOne) SetSite(s *Site) *EnrollmentTokenUpdateOne { + return etuo.SetSiteID(s.ID) +} + +// Mutation returns the EnrollmentTokenMutation object of the builder. +func (etuo *EnrollmentTokenUpdateOne) Mutation() *EnrollmentTokenMutation { + return etuo.mutation +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (etuo *EnrollmentTokenUpdateOne) ClearTenant() *EnrollmentTokenUpdateOne { + etuo.mutation.ClearTenant() + return etuo +} + +// ClearSite clears the "site" edge to the Site entity. +func (etuo *EnrollmentTokenUpdateOne) ClearSite() *EnrollmentTokenUpdateOne { + etuo.mutation.ClearSite() + return etuo +} + +// Where appends a list predicates to the EnrollmentTokenUpdate builder. +func (etuo *EnrollmentTokenUpdateOne) Where(ps ...predicate.EnrollmentToken) *EnrollmentTokenUpdateOne { + etuo.mutation.Where(ps...) + return etuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (etuo *EnrollmentTokenUpdateOne) Select(field string, fields ...string) *EnrollmentTokenUpdateOne { + etuo.fields = append([]string{field}, fields...) + return etuo +} + +// Save executes the query and returns the updated EnrollmentToken entity. +func (etuo *EnrollmentTokenUpdateOne) Save(ctx context.Context) (*EnrollmentToken, error) { + etuo.defaults() + return withHooks(ctx, etuo.sqlSave, etuo.mutation, etuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (etuo *EnrollmentTokenUpdateOne) SaveX(ctx context.Context) *EnrollmentToken { + node, err := etuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (etuo *EnrollmentTokenUpdateOne) Exec(ctx context.Context) error { + _, err := etuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (etuo *EnrollmentTokenUpdateOne) ExecX(ctx context.Context) { + if err := etuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (etuo *EnrollmentTokenUpdateOne) defaults() { + if _, ok := etuo.mutation.Modified(); !ok && !etuo.mutation.ModifiedCleared() { + v := enrollmenttoken.UpdateDefaultModified() + etuo.mutation.SetModified(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (etuo *EnrollmentTokenUpdateOne) check() error { + if v, ok := etuo.mutation.Token(); ok { + if err := enrollmenttoken.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "EnrollmentToken.token": %w`, err)} + } + } + if etuo.mutation.TenantCleared() && len(etuo.mutation.TenantIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "EnrollmentToken.tenant"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (etuo *EnrollmentTokenUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EnrollmentTokenUpdateOne { + etuo.modifiers = append(etuo.modifiers, modifiers...) + return etuo +} + +func (etuo *EnrollmentTokenUpdateOne) sqlSave(ctx context.Context) (_node *EnrollmentToken, err error) { + if err := etuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(enrollmenttoken.Table, enrollmenttoken.Columns, sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt)) + id, ok := etuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EnrollmentToken.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := etuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, enrollmenttoken.FieldID) + for _, f := range fields { + if !enrollmenttoken.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != enrollmenttoken.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := etuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := etuo.mutation.Token(); ok { + _spec.SetField(enrollmenttoken.FieldToken, field.TypeString, value) + } + if value, ok := etuo.mutation.Description(); ok { + _spec.SetField(enrollmenttoken.FieldDescription, field.TypeString, value) + } + if etuo.mutation.DescriptionCleared() { + _spec.ClearField(enrollmenttoken.FieldDescription, field.TypeString) + } + if value, ok := etuo.mutation.MaxUses(); ok { + _spec.SetField(enrollmenttoken.FieldMaxUses, field.TypeInt, value) + } + if value, ok := etuo.mutation.AddedMaxUses(); ok { + _spec.AddField(enrollmenttoken.FieldMaxUses, field.TypeInt, value) + } + if value, ok := etuo.mutation.CurrentUses(); ok { + _spec.SetField(enrollmenttoken.FieldCurrentUses, field.TypeInt, value) + } + if value, ok := etuo.mutation.AddedCurrentUses(); ok { + _spec.AddField(enrollmenttoken.FieldCurrentUses, field.TypeInt, value) + } + if value, ok := etuo.mutation.ExpiresAt(); ok { + _spec.SetField(enrollmenttoken.FieldExpiresAt, field.TypeTime, value) + } + if etuo.mutation.ExpiresAtCleared() { + _spec.ClearField(enrollmenttoken.FieldExpiresAt, field.TypeTime) + } + if value, ok := etuo.mutation.Active(); ok { + _spec.SetField(enrollmenttoken.FieldActive, field.TypeBool, value) + } + if value, ok := etuo.mutation.Created(); ok { + _spec.SetField(enrollmenttoken.FieldCreated, field.TypeTime, value) + } + if etuo.mutation.CreatedCleared() { + _spec.ClearField(enrollmenttoken.FieldCreated, field.TypeTime) + } + if value, ok := etuo.mutation.Modified(); ok { + _spec.SetField(enrollmenttoken.FieldModified, field.TypeTime, value) + } + if etuo.mutation.ModifiedCleared() { + _spec.ClearField(enrollmenttoken.FieldModified, field.TypeTime) + } + if etuo.mutation.TenantCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.TenantTable, + Columns: []string{enrollmenttoken.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := etuo.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.TenantTable, + Columns: []string{enrollmenttoken.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if etuo.mutation.SiteCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.SiteTable, + Columns: []string{enrollmenttoken.SiteColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(site.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := etuo.mutation.SiteIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: enrollmenttoken.SiteTable, + Columns: []string{enrollmenttoken.SiteColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(site.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(etuo.modifiers...) + _node = &EnrollmentToken{config: etuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, etuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{enrollmenttoken.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + etuo.mutation.done = true + return _node, nil +} diff --git a/ent.go b/ent.go index fa7c005..ff613c6 100644 --- a/ent.go +++ b/ent.go @@ -16,9 +16,11 @@ import ( "github.com/open-uem/ent/antivirus" "github.com/open-uem/ent/app" "github.com/open-uem/ent/authentication" + "github.com/open-uem/ent/branding" "github.com/open-uem/ent/certificate" "github.com/open-uem/ent/computer" "github.com/open-uem/ent/deployment" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/logicaldisk" "github.com/open-uem/ent/memoryslot" "github.com/open-uem/ent/metadata" @@ -47,6 +49,7 @@ import ( "github.com/open-uem/ent/tenant" "github.com/open-uem/ent/update" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" "github.com/open-uem/ent/wingetconfigexclusion" ) @@ -112,9 +115,11 @@ func checkColumn(table, column string) error { antivirus.Table: antivirus.ValidColumn, app.Table: app.ValidColumn, authentication.Table: authentication.ValidColumn, + branding.Table: branding.ValidColumn, certificate.Table: certificate.ValidColumn, computer.Table: computer.ValidColumn, deployment.Table: deployment.ValidColumn, + enrollmenttoken.Table: enrollmenttoken.ValidColumn, logicaldisk.Table: logicaldisk.ValidColumn, memoryslot.Table: memoryslot.ValidColumn, metadata.Table: metadata.ValidColumn, @@ -143,6 +148,7 @@ func checkColumn(table, column string) error { tenant.Table: tenant.ValidColumn, update.Table: update.ValidColumn, user.Table: user.ValidColumn, + usertenant.Table: usertenant.ValidColumn, wingetconfigexclusion.Table: wingetconfigexclusion.ValidColumn, }) }) diff --git a/hook/hook.go b/hook/hook.go index cb7bc5f..4986cb9 100644 --- a/hook/hook.go +++ b/hook/hook.go @@ -57,6 +57,18 @@ func (f AuthenticationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Val return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthenticationMutation", m) } +// The BrandingFunc type is an adapter to allow the use of ordinary +// function as Branding mutator. +type BrandingFunc func(context.Context, *ent.BrandingMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f BrandingFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.BrandingMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BrandingMutation", m) +} + // The CertificateFunc type is an adapter to allow the use of ordinary // function as Certificate mutator. type CertificateFunc func(context.Context, *ent.CertificateMutation) (ent.Value, error) @@ -93,6 +105,18 @@ func (f DeploymentFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DeploymentMutation", m) } +// The EnrollmentTokenFunc type is an adapter to allow the use of ordinary +// function as EnrollmentToken mutator. +type EnrollmentTokenFunc func(context.Context, *ent.EnrollmentTokenMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f EnrollmentTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.EnrollmentTokenMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EnrollmentTokenMutation", m) +} + // The LogicalDiskFunc type is an adapter to allow the use of ordinary // function as LogicalDisk mutator. type LogicalDiskFunc func(context.Context, *ent.LogicalDiskMutation) (ent.Value, error) @@ -429,6 +453,18 @@ func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) } +// The UserTenantFunc type is an adapter to allow the use of ordinary +// function as UserTenant mutator. +type UserTenantFunc func(context.Context, *ent.UserTenantMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserTenantFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserTenantMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserTenantMutation", m) +} + // The WingetConfigExclusionFunc type is an adapter to allow the use of ordinary // function as WingetConfigExclusion mutator. type WingetConfigExclusionFunc func(context.Context, *ent.WingetConfigExclusionMutation) (ent.Value, error) diff --git a/migrate/schema.go b/migrate/schema.go index dc03d62..7263f95 100644 --- a/migrate/schema.go +++ b/migrate/schema.go @@ -118,7 +118,9 @@ var ( {Name: "oidc_provider", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "oidc_issuer_url", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "oidc_client_id", Type: field.TypeString, Nullable: true, Default: ""}, - {Name: "oidc_role", Type: field.TypeString, Nullable: true, Default: ""}, + {Name: "oidc_role_admin", Type: field.TypeString, Nullable: true, Default: ""}, + {Name: "oidc_role_operator", Type: field.TypeString, Nullable: true, Default: ""}, + {Name: "oidc_role_user", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "oidc_cookie_encription_key", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "oidc_keycloak_public_key", Type: field.TypeString, Nullable: true, Default: ""}, {Name: "oidc_auto_create_account", Type: field.TypeBool, Nullable: true, Default: true}, @@ -131,6 +133,25 @@ var ( Columns: AuthenticationsColumns, PrimaryKey: []*schema.Column{AuthenticationsColumns[0]}, } + // BrandingsColumns holds the columns for the "brandings" table. + BrandingsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "logo_light", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "logo_small", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "primary_color", Type: field.TypeString, Nullable: true, Default: "#16a34a"}, + {Name: "product_name", Type: field.TypeString, Nullable: true, Default: "OpenUEM"}, + {Name: "login_background_image", Type: field.TypeString, Nullable: true, Size: 2147483647}, + {Name: "login_welcome_text", Type: field.TypeString, Nullable: true}, + {Name: "show_version", Type: field.TypeBool, Nullable: true, Default: true}, + {Name: "bug_report_link", Type: field.TypeString, Nullable: true, Default: "https://github.com/open-uem/openuem-console/issues/new/choose"}, + {Name: "help_link", Type: field.TypeString, Nullable: true, Default: "https://openuem.eu/docs/intro"}, + } + // BrandingsTable holds the schema information for the "brandings" table. + BrandingsTable = &schema.Table{ + Name: "brandings", + Columns: BrandingsColumns, + PrimaryKey: []*schema.Column{BrandingsColumns[0]}, + } // CertificatesColumns holds the columns for the "certificates" table. CertificatesColumns = []*schema.Column{ {Name: "serial", Type: field.TypeInt64, Increment: true}, @@ -138,12 +159,21 @@ var ( {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "expiry", Type: field.TypeTime, Nullable: true}, {Name: "uid", Type: field.TypeString, Nullable: true}, + {Name: "tenant_id", Type: field.TypeInt, Nullable: true}, } // CertificatesTable holds the schema information for the "certificates" table. CertificatesTable = &schema.Table{ Name: "certificates", Columns: CertificatesColumns, PrimaryKey: []*schema.Column{CertificatesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "certificates_tenants_tenant", + Columns: []*schema.Column{CertificatesColumns[5]}, + RefColumns: []*schema.Column{TenantsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, } // ComputersColumns holds the columns for the "computers" table. ComputersColumns = []*schema.Column{ @@ -197,6 +227,40 @@ var ( }, }, } + // EnrollmentTokensColumns holds the columns for the "enrollment_tokens" table. + EnrollmentTokensColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "token", Type: field.TypeString, Unique: true}, + {Name: "description", Type: field.TypeString, Nullable: true}, + {Name: "max_uses", Type: field.TypeInt, Default: 0}, + {Name: "current_uses", Type: field.TypeInt, Default: 0}, + {Name: "expires_at", Type: field.TypeTime, Nullable: true}, + {Name: "active", Type: field.TypeBool, Default: true}, + {Name: "created", Type: field.TypeTime, Nullable: true}, + {Name: "modified", Type: field.TypeTime, Nullable: true}, + {Name: "site_enrollment_tokens", Type: field.TypeInt, Nullable: true}, + {Name: "tenant_enrollment_tokens", Type: field.TypeInt}, + } + // EnrollmentTokensTable holds the schema information for the "enrollment_tokens" table. + EnrollmentTokensTable = &schema.Table{ + Name: "enrollment_tokens", + Columns: EnrollmentTokensColumns, + PrimaryKey: []*schema.Column{EnrollmentTokensColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "enrollment_tokens_sites_enrollment_tokens", + Columns: []*schema.Column{EnrollmentTokensColumns[9]}, + RefColumns: []*schema.Column{SitesColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "enrollment_tokens_tenants_enrollment_tokens", + Columns: []*schema.Column{EnrollmentTokensColumns[10]}, + RefColumns: []*schema.Column{TenantsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // LogicalDisksColumns holds the columns for the "logical_disks" table. LogicalDisksColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -484,8 +548,8 @@ var ( {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString}, {Name: "apply_to_all", Type: field.TypeBool, Default: false}, - {Name: "type", Type: field.TypeEnum, Nullable: true, Enums: []string{"winget"}, Default: "winget"}, {Name: "disabled", Type: field.TypeBool, Default: false}, + {Name: "type", Type: field.TypeEnum, Nullable: true, Enums: []string{"winget"}, Default: "winget"}, {Name: "site_profiles", Type: field.TypeInt, Nullable: true}, } // ProfilesTable holds the schema information for the "profiles" table. @@ -951,6 +1015,8 @@ var ( {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "is_default", Type: field.TypeBool, Nullable: true}, + {Name: "oidc_org_id", Type: field.TypeString, Nullable: true}, + {Name: "oidc_default_role", Type: field.TypeEnum, Nullable: true, Enums: []string{"admin", "operator", "user"}, Default: "user"}, {Name: "created", Type: field.TypeTime, Nullable: true}, {Name: "modified", Type: field.TypeTime, Nullable: true}, {Name: "tenant_netbird", Type: field.TypeInt, Nullable: true}, @@ -963,7 +1029,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "tenants_netbird_settings_netbird", - Columns: []*schema.Column{TenantsColumns[5]}, + Columns: []*schema.Column{TenantsColumns[7]}, RefColumns: []*schema.Column{NetbirdSettingsColumns[0]}, OnDelete: schema.Cascade, }, @@ -1032,6 +1098,43 @@ var ( }, }, } + // UserTenantsColumns holds the columns for the "user_tenants" table. + UserTenantsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "role", Type: field.TypeEnum, Enums: []string{"admin", "operator", "user"}, Default: "user"}, + {Name: "is_default", Type: field.TypeBool, Default: false}, + {Name: "created", Type: field.TypeTime, Nullable: true}, + {Name: "modified", Type: field.TypeTime, Nullable: true}, + {Name: "user_id", Type: field.TypeString}, + {Name: "tenant_id", Type: field.TypeInt}, + } + // UserTenantsTable holds the schema information for the "user_tenants" table. + UserTenantsTable = &schema.Table{ + Name: "user_tenants", + Columns: UserTenantsColumns, + PrimaryKey: []*schema.Column{UserTenantsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "user_tenants_users_user", + Columns: []*schema.Column{UserTenantsColumns[5]}, + RefColumns: []*schema.Column{UsersColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "user_tenants_tenants_tenant", + Columns: []*schema.Column{UserTenantsColumns[6]}, + RefColumns: []*schema.Column{TenantsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "usertenant_user_id_tenant_id", + Unique: true, + Columns: []*schema.Column{UserTenantsColumns[5], UserTenantsColumns[6]}, + }, + }, + } // WingetConfigExclusionsColumns holds the columns for the "winget_config_exclusions" table. WingetConfigExclusionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -1159,9 +1262,11 @@ var ( AntiviriTable, AppsTable, AuthenticationsTable, + BrandingsTable, CertificatesTable, ComputersTable, DeploymentsTable, + EnrollmentTokensTable, LogicalDisksTable, MemorySlotsTable, MetadataTable, @@ -1190,6 +1295,7 @@ var ( TenantsTable, UpdatesTable, UsersTable, + UserTenantsTable, WingetConfigExclusionsTable, AgentTagsTable, ProfileTagsTable, @@ -1202,8 +1308,11 @@ func init() { AgentsTable.ForeignKeys[0].RefTable = ReleasesTable AntiviriTable.ForeignKeys[0].RefTable = AgentsTable AppsTable.ForeignKeys[0].RefTable = AgentsTable + CertificatesTable.ForeignKeys[0].RefTable = TenantsTable ComputersTable.ForeignKeys[0].RefTable = AgentsTable DeploymentsTable.ForeignKeys[0].RefTable = AgentsTable + EnrollmentTokensTable.ForeignKeys[0].RefTable = SitesTable + EnrollmentTokensTable.ForeignKeys[1].RefTable = TenantsTable LogicalDisksTable.ForeignKeys[0].RefTable = AgentsTable MemorySlotsTable.ForeignKeys[0].RefTable = AgentsTable MetadataTable.ForeignKeys[0].RefTable = AgentsTable @@ -1231,6 +1340,8 @@ func init() { TasksTable.ForeignKeys[0].RefTable = ProfilesTable TenantsTable.ForeignKeys[0].RefTable = NetbirdSettingsTable UpdatesTable.ForeignKeys[0].RefTable = AgentsTable + UserTenantsTable.ForeignKeys[0].RefTable = UsersTable + UserTenantsTable.ForeignKeys[1].RefTable = TenantsTable WingetConfigExclusionsTable.ForeignKeys[0].RefTable = AgentsTable AgentTagsTable.ForeignKeys[0].RefTable = AgentsTable AgentTagsTable.ForeignKeys[1].RefTable = TagsTable diff --git a/mutation.go b/mutation.go index f8e3170..f13225e 100644 --- a/mutation.go +++ b/mutation.go @@ -15,9 +15,11 @@ import ( "github.com/open-uem/ent/antivirus" "github.com/open-uem/ent/app" "github.com/open-uem/ent/authentication" + "github.com/open-uem/ent/branding" "github.com/open-uem/ent/certificate" "github.com/open-uem/ent/computer" "github.com/open-uem/ent/deployment" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/logicaldisk" "github.com/open-uem/ent/memoryslot" "github.com/open-uem/ent/metadata" @@ -47,6 +49,7 @@ import ( "github.com/open-uem/ent/tenant" "github.com/open-uem/ent/update" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" "github.com/open-uem/ent/wingetconfigexclusion" ) @@ -63,9 +66,11 @@ const ( TypeAntivirus = "Antivirus" TypeApp = "App" TypeAuthentication = "Authentication" + TypeBranding = "Branding" TypeCertificate = "Certificate" TypeComputer = "Computer" TypeDeployment = "Deployment" + TypeEnrollmentToken = "EnrollmentToken" TypeLogicalDisk = "LogicalDisk" TypeMemorySlot = "MemorySlot" TypeMetadata = "Metadata" @@ -94,6 +99,7 @@ const ( TypeTenant = "Tenant" TypeUpdate = "Update" TypeUser = "User" + TypeUserTenant = "UserTenant" TypeWingetConfigExclusion = "WingetConfigExclusion" ) @@ -5191,7 +5197,9 @@ type AuthenticationMutation struct { _OIDC_provider *string _OIDC_issuer_url *string _OIDC_client_id *string - _OIDC_role *string + _OIDC_role_admin *string + _OIDC_role_operator *string + _OIDC_role_user *string _OIDC_cookie_encription_key *string _OIDC_keycloak_public_key *string _OIDC_auto_create_account *bool @@ -5595,53 +5603,151 @@ func (m *AuthenticationMutation) ResetOIDCClientID() { delete(m.clearedFields, authentication.FieldOIDCClientID) } -// SetOIDCRole sets the "OIDC_role" field. -func (m *AuthenticationMutation) SetOIDCRole(s string) { - m._OIDC_role = &s +// SetOIDCRoleAdmin sets the "OIDC_role_admin" field. +func (m *AuthenticationMutation) SetOIDCRoleAdmin(s string) { + m._OIDC_role_admin = &s } -// OIDCRole returns the value of the "OIDC_role" field in the mutation. -func (m *AuthenticationMutation) OIDCRole() (r string, exists bool) { - v := m._OIDC_role +// OIDCRoleAdmin returns the value of the "OIDC_role_admin" field in the mutation. +func (m *AuthenticationMutation) OIDCRoleAdmin() (r string, exists bool) { + v := m._OIDC_role_admin if v == nil { return } return *v, true } -// OldOIDCRole returns the old "OIDC_role" field's value of the Authentication entity. +// OldOIDCRoleAdmin returns the old "OIDC_role_admin" field's value of the Authentication entity. // If the Authentication object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *AuthenticationMutation) OldOIDCRole(ctx context.Context) (v string, err error) { +func (m *AuthenticationMutation) OldOIDCRoleAdmin(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOIDCRole is only allowed on UpdateOne operations") + return v, errors.New("OldOIDCRoleAdmin is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOIDCRole requires an ID field in the mutation") + return v, errors.New("OldOIDCRoleAdmin requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOIDCRole: %w", err) + return v, fmt.Errorf("querying old value for OldOIDCRoleAdmin: %w", err) } - return oldValue.OIDCRole, nil + return oldValue.OIDCRoleAdmin, nil } -// ClearOIDCRole clears the value of the "OIDC_role" field. -func (m *AuthenticationMutation) ClearOIDCRole() { - m._OIDC_role = nil - m.clearedFields[authentication.FieldOIDCRole] = struct{}{} +// ClearOIDCRoleAdmin clears the value of the "OIDC_role_admin" field. +func (m *AuthenticationMutation) ClearOIDCRoleAdmin() { + m._OIDC_role_admin = nil + m.clearedFields[authentication.FieldOIDCRoleAdmin] = struct{}{} } -// OIDCRoleCleared returns if the "OIDC_role" field was cleared in this mutation. -func (m *AuthenticationMutation) OIDCRoleCleared() bool { - _, ok := m.clearedFields[authentication.FieldOIDCRole] +// OIDCRoleAdminCleared returns if the "OIDC_role_admin" field was cleared in this mutation. +func (m *AuthenticationMutation) OIDCRoleAdminCleared() bool { + _, ok := m.clearedFields[authentication.FieldOIDCRoleAdmin] return ok } -// ResetOIDCRole resets all changes to the "OIDC_role" field. -func (m *AuthenticationMutation) ResetOIDCRole() { - m._OIDC_role = nil - delete(m.clearedFields, authentication.FieldOIDCRole) +// ResetOIDCRoleAdmin resets all changes to the "OIDC_role_admin" field. +func (m *AuthenticationMutation) ResetOIDCRoleAdmin() { + m._OIDC_role_admin = nil + delete(m.clearedFields, authentication.FieldOIDCRoleAdmin) +} + +// SetOIDCRoleOperator sets the "OIDC_role_operator" field. +func (m *AuthenticationMutation) SetOIDCRoleOperator(s string) { + m._OIDC_role_operator = &s +} + +// OIDCRoleOperator returns the value of the "OIDC_role_operator" field in the mutation. +func (m *AuthenticationMutation) OIDCRoleOperator() (r string, exists bool) { + v := m._OIDC_role_operator + if v == nil { + return + } + return *v, true +} + +// OldOIDCRoleOperator returns the old "OIDC_role_operator" field's value of the Authentication entity. +// If the Authentication object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthenticationMutation) OldOIDCRoleOperator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOIDCRoleOperator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOIDCRoleOperator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOIDCRoleOperator: %w", err) + } + return oldValue.OIDCRoleOperator, nil +} + +// ClearOIDCRoleOperator clears the value of the "OIDC_role_operator" field. +func (m *AuthenticationMutation) ClearOIDCRoleOperator() { + m._OIDC_role_operator = nil + m.clearedFields[authentication.FieldOIDCRoleOperator] = struct{}{} +} + +// OIDCRoleOperatorCleared returns if the "OIDC_role_operator" field was cleared in this mutation. +func (m *AuthenticationMutation) OIDCRoleOperatorCleared() bool { + _, ok := m.clearedFields[authentication.FieldOIDCRoleOperator] + return ok +} + +// ResetOIDCRoleOperator resets all changes to the "OIDC_role_operator" field. +func (m *AuthenticationMutation) ResetOIDCRoleOperator() { + m._OIDC_role_operator = nil + delete(m.clearedFields, authentication.FieldOIDCRoleOperator) +} + +// SetOIDCRoleUser sets the "OIDC_role_user" field. +func (m *AuthenticationMutation) SetOIDCRoleUser(s string) { + m._OIDC_role_user = &s +} + +// OIDCRoleUser returns the value of the "OIDC_role_user" field in the mutation. +func (m *AuthenticationMutation) OIDCRoleUser() (r string, exists bool) { + v := m._OIDC_role_user + if v == nil { + return + } + return *v, true +} + +// OldOIDCRoleUser returns the old "OIDC_role_user" field's value of the Authentication entity. +// If the Authentication object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthenticationMutation) OldOIDCRoleUser(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOIDCRoleUser is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOIDCRoleUser requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOIDCRoleUser: %w", err) + } + return oldValue.OIDCRoleUser, nil +} + +// ClearOIDCRoleUser clears the value of the "OIDC_role_user" field. +func (m *AuthenticationMutation) ClearOIDCRoleUser() { + m._OIDC_role_user = nil + m.clearedFields[authentication.FieldOIDCRoleUser] = struct{}{} +} + +// OIDCRoleUserCleared returns if the "OIDC_role_user" field was cleared in this mutation. +func (m *AuthenticationMutation) OIDCRoleUserCleared() bool { + _, ok := m.clearedFields[authentication.FieldOIDCRoleUser] + return ok +} + +// ResetOIDCRoleUser resets all changes to the "OIDC_role_user" field. +func (m *AuthenticationMutation) ResetOIDCRoleUser() { + m._OIDC_role_user = nil + delete(m.clearedFields, authentication.FieldOIDCRoleUser) } // SetOIDCCookieEncriptionKey sets the "OIDC_cookie_encription_key" field. @@ -5923,7 +6029,7 @@ func (m *AuthenticationMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *AuthenticationMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 14) if m.use_certificates != nil { fields = append(fields, authentication.FieldUseCertificates) } @@ -5942,8 +6048,14 @@ func (m *AuthenticationMutation) Fields() []string { if m._OIDC_client_id != nil { fields = append(fields, authentication.FieldOIDCClientID) } - if m._OIDC_role != nil { - fields = append(fields, authentication.FieldOIDCRole) + if m._OIDC_role_admin != nil { + fields = append(fields, authentication.FieldOIDCRoleAdmin) + } + if m._OIDC_role_operator != nil { + fields = append(fields, authentication.FieldOIDCRoleOperator) + } + if m._OIDC_role_user != nil { + fields = append(fields, authentication.FieldOIDCRoleUser) } if m._OIDC_cookie_encription_key != nil { fields = append(fields, authentication.FieldOIDCCookieEncriptionKey) @@ -5980,8 +6092,12 @@ func (m *AuthenticationMutation) Field(name string) (ent.Value, bool) { return m.OIDCIssuerURL() case authentication.FieldOIDCClientID: return m.OIDCClientID() - case authentication.FieldOIDCRole: - return m.OIDCRole() + case authentication.FieldOIDCRoleAdmin: + return m.OIDCRoleAdmin() + case authentication.FieldOIDCRoleOperator: + return m.OIDCRoleOperator() + case authentication.FieldOIDCRoleUser: + return m.OIDCRoleUser() case authentication.FieldOIDCCookieEncriptionKey: return m.OIDCCookieEncriptionKey() case authentication.FieldOIDCKeycloakPublicKey: @@ -6013,8 +6129,12 @@ func (m *AuthenticationMutation) OldField(ctx context.Context, name string) (ent return m.OldOIDCIssuerURL(ctx) case authentication.FieldOIDCClientID: return m.OldOIDCClientID(ctx) - case authentication.FieldOIDCRole: - return m.OldOIDCRole(ctx) + case authentication.FieldOIDCRoleAdmin: + return m.OldOIDCRoleAdmin(ctx) + case authentication.FieldOIDCRoleOperator: + return m.OldOIDCRoleOperator(ctx) + case authentication.FieldOIDCRoleUser: + return m.OldOIDCRoleUser(ctx) case authentication.FieldOIDCCookieEncriptionKey: return m.OldOIDCCookieEncriptionKey(ctx) case authentication.FieldOIDCKeycloakPublicKey: @@ -6076,12 +6196,26 @@ func (m *AuthenticationMutation) SetField(name string, value ent.Value) error { } m.SetOIDCClientID(v) return nil - case authentication.FieldOIDCRole: + case authentication.FieldOIDCRoleAdmin: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOIDCRoleAdmin(v) + return nil + case authentication.FieldOIDCRoleOperator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOIDCRoleOperator(v) + return nil + case authentication.FieldOIDCRoleUser: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOIDCRole(v) + m.SetOIDCRoleUser(v) return nil case authentication.FieldOIDCCookieEncriptionKey: v, ok := value.(string) @@ -6166,8 +6300,14 @@ func (m *AuthenticationMutation) ClearedFields() []string { if m.FieldCleared(authentication.FieldOIDCClientID) { fields = append(fields, authentication.FieldOIDCClientID) } - if m.FieldCleared(authentication.FieldOIDCRole) { - fields = append(fields, authentication.FieldOIDCRole) + if m.FieldCleared(authentication.FieldOIDCRoleAdmin) { + fields = append(fields, authentication.FieldOIDCRoleAdmin) + } + if m.FieldCleared(authentication.FieldOIDCRoleOperator) { + fields = append(fields, authentication.FieldOIDCRoleOperator) + } + if m.FieldCleared(authentication.FieldOIDCRoleUser) { + fields = append(fields, authentication.FieldOIDCRoleUser) } if m.FieldCleared(authentication.FieldOIDCCookieEncriptionKey) { fields = append(fields, authentication.FieldOIDCCookieEncriptionKey) @@ -6216,8 +6356,14 @@ func (m *AuthenticationMutation) ClearField(name string) error { case authentication.FieldOIDCClientID: m.ClearOIDCClientID() return nil - case authentication.FieldOIDCRole: - m.ClearOIDCRole() + case authentication.FieldOIDCRoleAdmin: + m.ClearOIDCRoleAdmin() + return nil + case authentication.FieldOIDCRoleOperator: + m.ClearOIDCRoleOperator() + return nil + case authentication.FieldOIDCRoleUser: + m.ClearOIDCRoleUser() return nil case authentication.FieldOIDCCookieEncriptionKey: m.ClearOIDCCookieEncriptionKey() @@ -6260,8 +6406,14 @@ func (m *AuthenticationMutation) ResetField(name string) error { case authentication.FieldOIDCClientID: m.ResetOIDCClientID() return nil - case authentication.FieldOIDCRole: - m.ResetOIDCRole() + case authentication.FieldOIDCRoleAdmin: + m.ResetOIDCRoleAdmin() + return nil + case authentication.FieldOIDCRoleOperator: + m.ResetOIDCRoleOperator() + return nil + case authentication.FieldOIDCRoleUser: + m.ResetOIDCRoleUser() return nil case authentication.FieldOIDCCookieEncriptionKey: m.ResetOIDCCookieEncriptionKey() @@ -6330,33 +6482,38 @@ func (m *AuthenticationMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Authentication edge %s", name) } -// CertificateMutation represents an operation that mutates the Certificate nodes in the graph. -type CertificateMutation struct { +// BrandingMutation represents an operation that mutates the Branding nodes in the graph. +type BrandingMutation struct { config - op Op - typ string - id *int64 - _type *certificate.Type - description *string - expiry *time.Time - uid *string - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*Certificate, error) - predicates []predicate.Certificate -} - -var _ ent.Mutation = (*CertificateMutation)(nil) - -// certificateOption allows management of the mutation configuration using functional options. -type certificateOption func(*CertificateMutation) - -// newCertificateMutation creates new mutation for the Certificate entity. -func newCertificateMutation(c config, op Op, opts ...certificateOption) *CertificateMutation { - m := &CertificateMutation{ + op Op + typ string + id *int + logo_light *string + logo_small *string + primary_color *string + product_name *string + login_background_image *string + login_welcome_text *string + show_version *bool + bug_report_link *string + help_link *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Branding, error) + predicates []predicate.Branding +} + +var _ ent.Mutation = (*BrandingMutation)(nil) + +// brandingOption allows management of the mutation configuration using functional options. +type brandingOption func(*BrandingMutation) + +// newBrandingMutation creates new mutation for the Branding entity. +func newBrandingMutation(c config, op Op, opts ...brandingOption) *BrandingMutation { + m := &BrandingMutation{ config: c, op: op, - typ: TypeCertificate, + typ: TypeBranding, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -6365,20 +6522,20 @@ func newCertificateMutation(c config, op Op, opts ...certificateOption) *Certifi return m } -// withCertificateID sets the ID field of the mutation. -func withCertificateID(id int64) certificateOption { - return func(m *CertificateMutation) { +// withBrandingID sets the ID field of the mutation. +func withBrandingID(id int) brandingOption { + return func(m *BrandingMutation) { var ( err error once sync.Once - value *Certificate + value *Branding ) - m.oldValue = func(ctx context.Context) (*Certificate, error) { + m.oldValue = func(ctx context.Context) (*Branding, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Certificate.Get(ctx, id) + value, err = m.Client().Branding.Get(ctx, id) } }) return value, err @@ -6387,10 +6544,10 @@ func withCertificateID(id int64) certificateOption { } } -// withCertificate sets the old Certificate of the mutation. -func withCertificate(node *Certificate) certificateOption { - return func(m *CertificateMutation) { - m.oldValue = func(context.Context) (*Certificate, error) { +// withBranding sets the old Branding of the mutation. +func withBranding(node *Branding) brandingOption { + return func(m *BrandingMutation) { + m.oldValue = func(context.Context) (*Branding, error) { return node, nil } m.id = &node.ID @@ -6399,7 +6556,7 @@ func withCertificate(node *Certificate) certificateOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m CertificateMutation) Client() *Client { +func (m BrandingMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -6407,7 +6564,7 @@ func (m CertificateMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m CertificateMutation) Tx() (*Tx, error) { +func (m BrandingMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -6416,15 +6573,9 @@ func (m CertificateMutation) Tx() (*Tx, error) { return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Certificate entities. -func (m *CertificateMutation) SetID(id int64) { - m.id = &id -} - // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *CertificateMutation) ID() (id int64, exists bool) { +func (m *BrandingMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -6435,213 +6586,471 @@ func (m *CertificateMutation) ID() (id int64, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *CertificateMutation) IDs(ctx context.Context) ([]int64, error) { +func (m *BrandingMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int64{id}, nil + return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Certificate.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Branding.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetType sets the "type" field. -func (m *CertificateMutation) SetType(c certificate.Type) { - m._type = &c +// SetLogoLight sets the "logo_light" field. +func (m *BrandingMutation) SetLogoLight(s string) { + m.logo_light = &s } -// GetType returns the value of the "type" field in the mutation. -func (m *CertificateMutation) GetType() (r certificate.Type, exists bool) { - v := m._type +// LogoLight returns the value of the "logo_light" field in the mutation. +func (m *BrandingMutation) LogoLight() (r string, exists bool) { + v := m.logo_light if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the Certificate entity. -// If the Certificate object wasn't provided to the builder, the object is fetched from the database. +// OldLogoLight returns the old "logo_light" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CertificateMutation) OldType(ctx context.Context) (v certificate.Type, err error) { +func (m *BrandingMutation) OldLogoLight(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldLogoLight is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldLogoLight requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldLogoLight: %w", err) } - return oldValue.Type, nil + return oldValue.LogoLight, nil } -// ResetType resets all changes to the "type" field. -func (m *CertificateMutation) ResetType() { - m._type = nil +// ClearLogoLight clears the value of the "logo_light" field. +func (m *BrandingMutation) ClearLogoLight() { + m.logo_light = nil + m.clearedFields[branding.FieldLogoLight] = struct{}{} } -// SetDescription sets the "description" field. -func (m *CertificateMutation) SetDescription(s string) { - m.description = &s +// LogoLightCleared returns if the "logo_light" field was cleared in this mutation. +func (m *BrandingMutation) LogoLightCleared() bool { + _, ok := m.clearedFields[branding.FieldLogoLight] + return ok } -// Description returns the value of the "description" field in the mutation. -func (m *CertificateMutation) Description() (r string, exists bool) { - v := m.description +// ResetLogoLight resets all changes to the "logo_light" field. +func (m *BrandingMutation) ResetLogoLight() { + m.logo_light = nil + delete(m.clearedFields, branding.FieldLogoLight) +} + +// SetLogoSmall sets the "logo_small" field. +func (m *BrandingMutation) SetLogoSmall(s string) { + m.logo_small = &s +} + +// LogoSmall returns the value of the "logo_small" field in the mutation. +func (m *BrandingMutation) LogoSmall() (r string, exists bool) { + v := m.logo_small if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the Certificate entity. -// If the Certificate object wasn't provided to the builder, the object is fetched from the database. +// OldLogoSmall returns the old "logo_small" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CertificateMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *BrandingMutation) OldLogoSmall(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldLogoSmall is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldLogoSmall requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldLogoSmall: %w", err) } - return oldValue.Description, nil + return oldValue.LogoSmall, nil } -// ClearDescription clears the value of the "description" field. -func (m *CertificateMutation) ClearDescription() { - m.description = nil - m.clearedFields[certificate.FieldDescription] = struct{}{} +// ClearLogoSmall clears the value of the "logo_small" field. +func (m *BrandingMutation) ClearLogoSmall() { + m.logo_small = nil + m.clearedFields[branding.FieldLogoSmall] = struct{}{} } -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *CertificateMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[certificate.FieldDescription] +// LogoSmallCleared returns if the "logo_small" field was cleared in this mutation. +func (m *BrandingMutation) LogoSmallCleared() bool { + _, ok := m.clearedFields[branding.FieldLogoSmall] return ok } -// ResetDescription resets all changes to the "description" field. -func (m *CertificateMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, certificate.FieldDescription) +// ResetLogoSmall resets all changes to the "logo_small" field. +func (m *BrandingMutation) ResetLogoSmall() { + m.logo_small = nil + delete(m.clearedFields, branding.FieldLogoSmall) } -// SetExpiry sets the "expiry" field. -func (m *CertificateMutation) SetExpiry(t time.Time) { - m.expiry = &t +// SetPrimaryColor sets the "primary_color" field. +func (m *BrandingMutation) SetPrimaryColor(s string) { + m.primary_color = &s } -// Expiry returns the value of the "expiry" field in the mutation. -func (m *CertificateMutation) Expiry() (r time.Time, exists bool) { - v := m.expiry +// PrimaryColor returns the value of the "primary_color" field in the mutation. +func (m *BrandingMutation) PrimaryColor() (r string, exists bool) { + v := m.primary_color if v == nil { return } return *v, true } -// OldExpiry returns the old "expiry" field's value of the Certificate entity. -// If the Certificate object wasn't provided to the builder, the object is fetched from the database. +// OldPrimaryColor returns the old "primary_color" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CertificateMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { +func (m *BrandingMutation) OldPrimaryColor(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExpiry is only allowed on UpdateOne operations") + return v, errors.New("OldPrimaryColor is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExpiry requires an ID field in the mutation") + return v, errors.New("OldPrimaryColor requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExpiry: %w", err) + return v, fmt.Errorf("querying old value for OldPrimaryColor: %w", err) } - return oldValue.Expiry, nil + return oldValue.PrimaryColor, nil } -// ClearExpiry clears the value of the "expiry" field. -func (m *CertificateMutation) ClearExpiry() { - m.expiry = nil - m.clearedFields[certificate.FieldExpiry] = struct{}{} +// ClearPrimaryColor clears the value of the "primary_color" field. +func (m *BrandingMutation) ClearPrimaryColor() { + m.primary_color = nil + m.clearedFields[branding.FieldPrimaryColor] = struct{}{} } -// ExpiryCleared returns if the "expiry" field was cleared in this mutation. -func (m *CertificateMutation) ExpiryCleared() bool { - _, ok := m.clearedFields[certificate.FieldExpiry] +// PrimaryColorCleared returns if the "primary_color" field was cleared in this mutation. +func (m *BrandingMutation) PrimaryColorCleared() bool { + _, ok := m.clearedFields[branding.FieldPrimaryColor] return ok } -// ResetExpiry resets all changes to the "expiry" field. -func (m *CertificateMutation) ResetExpiry() { - m.expiry = nil - delete(m.clearedFields, certificate.FieldExpiry) +// ResetPrimaryColor resets all changes to the "primary_color" field. +func (m *BrandingMutation) ResetPrimaryColor() { + m.primary_color = nil + delete(m.clearedFields, branding.FieldPrimaryColor) } -// SetUID sets the "uid" field. -func (m *CertificateMutation) SetUID(s string) { - m.uid = &s +// SetProductName sets the "product_name" field. +func (m *BrandingMutation) SetProductName(s string) { + m.product_name = &s } -// UID returns the value of the "uid" field in the mutation. -func (m *CertificateMutation) UID() (r string, exists bool) { - v := m.uid +// ProductName returns the value of the "product_name" field in the mutation. +func (m *BrandingMutation) ProductName() (r string, exists bool) { + v := m.product_name if v == nil { return } return *v, true } -// OldUID returns the old "uid" field's value of the Certificate entity. -// If the Certificate object wasn't provided to the builder, the object is fetched from the database. +// OldProductName returns the old "product_name" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CertificateMutation) OldUID(ctx context.Context) (v string, err error) { +func (m *BrandingMutation) OldProductName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUID is only allowed on UpdateOne operations") + return v, errors.New("OldProductName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUID requires an ID field in the mutation") + return v, errors.New("OldProductName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUID: %w", err) + return v, fmt.Errorf("querying old value for OldProductName: %w", err) } - return oldValue.UID, nil + return oldValue.ProductName, nil } -// ClearUID clears the value of the "uid" field. -func (m *CertificateMutation) ClearUID() { - m.uid = nil - m.clearedFields[certificate.FieldUID] = struct{}{} +// ClearProductName clears the value of the "product_name" field. +func (m *BrandingMutation) ClearProductName() { + m.product_name = nil + m.clearedFields[branding.FieldProductName] = struct{}{} } -// UIDCleared returns if the "uid" field was cleared in this mutation. -func (m *CertificateMutation) UIDCleared() bool { - _, ok := m.clearedFields[certificate.FieldUID] +// ProductNameCleared returns if the "product_name" field was cleared in this mutation. +func (m *BrandingMutation) ProductNameCleared() bool { + _, ok := m.clearedFields[branding.FieldProductName] return ok } -// ResetUID resets all changes to the "uid" field. -func (m *CertificateMutation) ResetUID() { - m.uid = nil - delete(m.clearedFields, certificate.FieldUID) +// ResetProductName resets all changes to the "product_name" field. +func (m *BrandingMutation) ResetProductName() { + m.product_name = nil + delete(m.clearedFields, branding.FieldProductName) } -// Where appends a list predicates to the CertificateMutation builder. -func (m *CertificateMutation) Where(ps ...predicate.Certificate) { +// SetLoginBackgroundImage sets the "login_background_image" field. +func (m *BrandingMutation) SetLoginBackgroundImage(s string) { + m.login_background_image = &s +} + +// LoginBackgroundImage returns the value of the "login_background_image" field in the mutation. +func (m *BrandingMutation) LoginBackgroundImage() (r string, exists bool) { + v := m.login_background_image + if v == nil { + return + } + return *v, true +} + +// OldLoginBackgroundImage returns the old "login_background_image" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BrandingMutation) OldLoginBackgroundImage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginBackgroundImage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginBackgroundImage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginBackgroundImage: %w", err) + } + return oldValue.LoginBackgroundImage, nil +} + +// ClearLoginBackgroundImage clears the value of the "login_background_image" field. +func (m *BrandingMutation) ClearLoginBackgroundImage() { + m.login_background_image = nil + m.clearedFields[branding.FieldLoginBackgroundImage] = struct{}{} +} + +// LoginBackgroundImageCleared returns if the "login_background_image" field was cleared in this mutation. +func (m *BrandingMutation) LoginBackgroundImageCleared() bool { + _, ok := m.clearedFields[branding.FieldLoginBackgroundImage] + return ok +} + +// ResetLoginBackgroundImage resets all changes to the "login_background_image" field. +func (m *BrandingMutation) ResetLoginBackgroundImage() { + m.login_background_image = nil + delete(m.clearedFields, branding.FieldLoginBackgroundImage) +} + +// SetLoginWelcomeText sets the "login_welcome_text" field. +func (m *BrandingMutation) SetLoginWelcomeText(s string) { + m.login_welcome_text = &s +} + +// LoginWelcomeText returns the value of the "login_welcome_text" field in the mutation. +func (m *BrandingMutation) LoginWelcomeText() (r string, exists bool) { + v := m.login_welcome_text + if v == nil { + return + } + return *v, true +} + +// OldLoginWelcomeText returns the old "login_welcome_text" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BrandingMutation) OldLoginWelcomeText(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginWelcomeText is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginWelcomeText requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginWelcomeText: %w", err) + } + return oldValue.LoginWelcomeText, nil +} + +// ClearLoginWelcomeText clears the value of the "login_welcome_text" field. +func (m *BrandingMutation) ClearLoginWelcomeText() { + m.login_welcome_text = nil + m.clearedFields[branding.FieldLoginWelcomeText] = struct{}{} +} + +// LoginWelcomeTextCleared returns if the "login_welcome_text" field was cleared in this mutation. +func (m *BrandingMutation) LoginWelcomeTextCleared() bool { + _, ok := m.clearedFields[branding.FieldLoginWelcomeText] + return ok +} + +// ResetLoginWelcomeText resets all changes to the "login_welcome_text" field. +func (m *BrandingMutation) ResetLoginWelcomeText() { + m.login_welcome_text = nil + delete(m.clearedFields, branding.FieldLoginWelcomeText) +} + +// SetShowVersion sets the "show_version" field. +func (m *BrandingMutation) SetShowVersion(b bool) { + m.show_version = &b +} + +// ShowVersion returns the value of the "show_version" field in the mutation. +func (m *BrandingMutation) ShowVersion() (r bool, exists bool) { + v := m.show_version + if v == nil { + return + } + return *v, true +} + +// OldShowVersion returns the old "show_version" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BrandingMutation) OldShowVersion(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldShowVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldShowVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldShowVersion: %w", err) + } + return oldValue.ShowVersion, nil +} + +// ClearShowVersion clears the value of the "show_version" field. +func (m *BrandingMutation) ClearShowVersion() { + m.show_version = nil + m.clearedFields[branding.FieldShowVersion] = struct{}{} +} + +// ShowVersionCleared returns if the "show_version" field was cleared in this mutation. +func (m *BrandingMutation) ShowVersionCleared() bool { + _, ok := m.clearedFields[branding.FieldShowVersion] + return ok +} + +// ResetShowVersion resets all changes to the "show_version" field. +func (m *BrandingMutation) ResetShowVersion() { + m.show_version = nil + delete(m.clearedFields, branding.FieldShowVersion) +} + +// SetBugReportLink sets the "bug_report_link" field. +func (m *BrandingMutation) SetBugReportLink(s string) { + m.bug_report_link = &s +} + +// BugReportLink returns the value of the "bug_report_link" field in the mutation. +func (m *BrandingMutation) BugReportLink() (r string, exists bool) { + v := m.bug_report_link + if v == nil { + return + } + return *v, true +} + +// OldBugReportLink returns the old "bug_report_link" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BrandingMutation) OldBugReportLink(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBugReportLink is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBugReportLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBugReportLink: %w", err) + } + return oldValue.BugReportLink, nil +} + +// ClearBugReportLink clears the value of the "bug_report_link" field. +func (m *BrandingMutation) ClearBugReportLink() { + m.bug_report_link = nil + m.clearedFields[branding.FieldBugReportLink] = struct{}{} +} + +// BugReportLinkCleared returns if the "bug_report_link" field was cleared in this mutation. +func (m *BrandingMutation) BugReportLinkCleared() bool { + _, ok := m.clearedFields[branding.FieldBugReportLink] + return ok +} + +// ResetBugReportLink resets all changes to the "bug_report_link" field. +func (m *BrandingMutation) ResetBugReportLink() { + m.bug_report_link = nil + delete(m.clearedFields, branding.FieldBugReportLink) +} + +// SetHelpLink sets the "help_link" field. +func (m *BrandingMutation) SetHelpLink(s string) { + m.help_link = &s +} + +// HelpLink returns the value of the "help_link" field in the mutation. +func (m *BrandingMutation) HelpLink() (r string, exists bool) { + v := m.help_link + if v == nil { + return + } + return *v, true +} + +// OldHelpLink returns the old "help_link" field's value of the Branding entity. +// If the Branding object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BrandingMutation) OldHelpLink(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHelpLink is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHelpLink requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHelpLink: %w", err) + } + return oldValue.HelpLink, nil +} + +// ClearHelpLink clears the value of the "help_link" field. +func (m *BrandingMutation) ClearHelpLink() { + m.help_link = nil + m.clearedFields[branding.FieldHelpLink] = struct{}{} +} + +// HelpLinkCleared returns if the "help_link" field was cleared in this mutation. +func (m *BrandingMutation) HelpLinkCleared() bool { + _, ok := m.clearedFields[branding.FieldHelpLink] + return ok +} + +// ResetHelpLink resets all changes to the "help_link" field. +func (m *BrandingMutation) ResetHelpLink() { + m.help_link = nil + delete(m.clearedFields, branding.FieldHelpLink) +} + +// Where appends a list predicates to the BrandingMutation builder. +func (m *BrandingMutation) Where(ps ...predicate.Branding) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the CertificateMutation builder. Using this method, +// WhereP appends storage-level predicates to the BrandingMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *CertificateMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Certificate, len(ps)) +func (m *BrandingMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Branding, len(ps)) for i := range ps { p[i] = ps[i] } @@ -6649,36 +7058,51 @@ func (m *CertificateMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *CertificateMutation) Op() Op { +func (m *BrandingMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *CertificateMutation) SetOp(op Op) { +func (m *BrandingMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Certificate). -func (m *CertificateMutation) Type() string { +// Type returns the node type of this mutation (Branding). +func (m *BrandingMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *CertificateMutation) Fields() []string { - fields := make([]string, 0, 4) - if m._type != nil { - fields = append(fields, certificate.FieldType) +func (m *BrandingMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.logo_light != nil { + fields = append(fields, branding.FieldLogoLight) } - if m.description != nil { - fields = append(fields, certificate.FieldDescription) + if m.logo_small != nil { + fields = append(fields, branding.FieldLogoSmall) } - if m.expiry != nil { - fields = append(fields, certificate.FieldExpiry) + if m.primary_color != nil { + fields = append(fields, branding.FieldPrimaryColor) } - if m.uid != nil { - fields = append(fields, certificate.FieldUID) + if m.product_name != nil { + fields = append(fields, branding.FieldProductName) + } + if m.login_background_image != nil { + fields = append(fields, branding.FieldLoginBackgroundImage) + } + if m.login_welcome_text != nil { + fields = append(fields, branding.FieldLoginWelcomeText) + } + if m.show_version != nil { + fields = append(fields, branding.FieldShowVersion) + } + if m.bug_report_link != nil { + fields = append(fields, branding.FieldBugReportLink) + } + if m.help_link != nil { + fields = append(fields, branding.FieldHelpLink) } return fields } @@ -6686,16 +7110,26 @@ func (m *CertificateMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *CertificateMutation) Field(name string) (ent.Value, bool) { - switch name { - case certificate.FieldType: - return m.GetType() - case certificate.FieldDescription: - return m.Description() - case certificate.FieldExpiry: - return m.Expiry() - case certificate.FieldUID: - return m.UID() +func (m *BrandingMutation) Field(name string) (ent.Value, bool) { + switch name { + case branding.FieldLogoLight: + return m.LogoLight() + case branding.FieldLogoSmall: + return m.LogoSmall() + case branding.FieldPrimaryColor: + return m.PrimaryColor() + case branding.FieldProductName: + return m.ProductName() + case branding.FieldLoginBackgroundImage: + return m.LoginBackgroundImage() + case branding.FieldLoginWelcomeText: + return m.LoginWelcomeText() + case branding.FieldShowVersion: + return m.ShowVersion() + case branding.FieldBugReportLink: + return m.BugReportLink() + case branding.FieldHelpLink: + return m.HelpLink() } return nil, false } @@ -6703,221 +7137,312 @@ func (m *CertificateMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *CertificateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case certificate.FieldType: - return m.OldType(ctx) - case certificate.FieldDescription: - return m.OldDescription(ctx) - case certificate.FieldExpiry: - return m.OldExpiry(ctx) - case certificate.FieldUID: - return m.OldUID(ctx) - } - return nil, fmt.Errorf("unknown Certificate field %s", name) +func (m *BrandingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case branding.FieldLogoLight: + return m.OldLogoLight(ctx) + case branding.FieldLogoSmall: + return m.OldLogoSmall(ctx) + case branding.FieldPrimaryColor: + return m.OldPrimaryColor(ctx) + case branding.FieldProductName: + return m.OldProductName(ctx) + case branding.FieldLoginBackgroundImage: + return m.OldLoginBackgroundImage(ctx) + case branding.FieldLoginWelcomeText: + return m.OldLoginWelcomeText(ctx) + case branding.FieldShowVersion: + return m.OldShowVersion(ctx) + case branding.FieldBugReportLink: + return m.OldBugReportLink(ctx) + case branding.FieldHelpLink: + return m.OldHelpLink(ctx) + } + return nil, fmt.Errorf("unknown Branding field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *CertificateMutation) SetField(name string, value ent.Value) error { +func (m *BrandingMutation) SetField(name string, value ent.Value) error { switch name { - case certificate.FieldType: - v, ok := value.(certificate.Type) + case branding.FieldLogoLight: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetType(v) + m.SetLogoLight(v) return nil - case certificate.FieldDescription: + case branding.FieldLogoSmall: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) + m.SetLogoSmall(v) return nil - case certificate.FieldExpiry: - v, ok := value.(time.Time) + case branding.FieldPrimaryColor: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetExpiry(v) + m.SetPrimaryColor(v) return nil - case certificate.FieldUID: + case branding.FieldProductName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUID(v) + m.SetProductName(v) + return nil + case branding.FieldLoginBackgroundImage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginBackgroundImage(v) + return nil + case branding.FieldLoginWelcomeText: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginWelcomeText(v) + return nil + case branding.FieldShowVersion: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetShowVersion(v) + return nil + case branding.FieldBugReportLink: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBugReportLink(v) + return nil + case branding.FieldHelpLink: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHelpLink(v) return nil } - return fmt.Errorf("unknown Certificate field %s", name) + return fmt.Errorf("unknown Branding field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *CertificateMutation) AddedFields() []string { +func (m *BrandingMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *CertificateMutation) AddedField(name string) (ent.Value, bool) { +func (m *BrandingMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *CertificateMutation) AddField(name string, value ent.Value) error { +func (m *BrandingMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Certificate numeric field %s", name) + return fmt.Errorf("unknown Branding numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *CertificateMutation) ClearedFields() []string { +func (m *BrandingMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(certificate.FieldDescription) { - fields = append(fields, certificate.FieldDescription) + if m.FieldCleared(branding.FieldLogoLight) { + fields = append(fields, branding.FieldLogoLight) } - if m.FieldCleared(certificate.FieldExpiry) { - fields = append(fields, certificate.FieldExpiry) + if m.FieldCleared(branding.FieldLogoSmall) { + fields = append(fields, branding.FieldLogoSmall) } - if m.FieldCleared(certificate.FieldUID) { - fields = append(fields, certificate.FieldUID) + if m.FieldCleared(branding.FieldPrimaryColor) { + fields = append(fields, branding.FieldPrimaryColor) + } + if m.FieldCleared(branding.FieldProductName) { + fields = append(fields, branding.FieldProductName) + } + if m.FieldCleared(branding.FieldLoginBackgroundImage) { + fields = append(fields, branding.FieldLoginBackgroundImage) + } + if m.FieldCleared(branding.FieldLoginWelcomeText) { + fields = append(fields, branding.FieldLoginWelcomeText) + } + if m.FieldCleared(branding.FieldShowVersion) { + fields = append(fields, branding.FieldShowVersion) + } + if m.FieldCleared(branding.FieldBugReportLink) { + fields = append(fields, branding.FieldBugReportLink) + } + if m.FieldCleared(branding.FieldHelpLink) { + fields = append(fields, branding.FieldHelpLink) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *CertificateMutation) FieldCleared(name string) bool { +func (m *BrandingMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *CertificateMutation) ClearField(name string) error { +func (m *BrandingMutation) ClearField(name string) error { switch name { - case certificate.FieldDescription: - m.ClearDescription() + case branding.FieldLogoLight: + m.ClearLogoLight() return nil - case certificate.FieldExpiry: - m.ClearExpiry() + case branding.FieldLogoSmall: + m.ClearLogoSmall() return nil - case certificate.FieldUID: - m.ClearUID() + case branding.FieldPrimaryColor: + m.ClearPrimaryColor() + return nil + case branding.FieldProductName: + m.ClearProductName() + return nil + case branding.FieldLoginBackgroundImage: + m.ClearLoginBackgroundImage() + return nil + case branding.FieldLoginWelcomeText: + m.ClearLoginWelcomeText() + return nil + case branding.FieldShowVersion: + m.ClearShowVersion() + return nil + case branding.FieldBugReportLink: + m.ClearBugReportLink() + return nil + case branding.FieldHelpLink: + m.ClearHelpLink() return nil } - return fmt.Errorf("unknown Certificate nullable field %s", name) + return fmt.Errorf("unknown Branding nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *CertificateMutation) ResetField(name string) error { +func (m *BrandingMutation) ResetField(name string) error { switch name { - case certificate.FieldType: - m.ResetType() + case branding.FieldLogoLight: + m.ResetLogoLight() return nil - case certificate.FieldDescription: - m.ResetDescription() + case branding.FieldLogoSmall: + m.ResetLogoSmall() return nil - case certificate.FieldExpiry: - m.ResetExpiry() + case branding.FieldPrimaryColor: + m.ResetPrimaryColor() return nil - case certificate.FieldUID: - m.ResetUID() + case branding.FieldProductName: + m.ResetProductName() + return nil + case branding.FieldLoginBackgroundImage: + m.ResetLoginBackgroundImage() + return nil + case branding.FieldLoginWelcomeText: + m.ResetLoginWelcomeText() + return nil + case branding.FieldShowVersion: + m.ResetShowVersion() + return nil + case branding.FieldBugReportLink: + m.ResetBugReportLink() + return nil + case branding.FieldHelpLink: + m.ResetHelpLink() return nil } - return fmt.Errorf("unknown Certificate field %s", name) + return fmt.Errorf("unknown Branding field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *CertificateMutation) AddedEdges() []string { +func (m *BrandingMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *CertificateMutation) AddedIDs(name string) []ent.Value { +func (m *BrandingMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *CertificateMutation) RemovedEdges() []string { +func (m *BrandingMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *CertificateMutation) RemovedIDs(name string) []ent.Value { +func (m *BrandingMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *CertificateMutation) ClearedEdges() []string { +func (m *BrandingMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *CertificateMutation) EdgeCleared(name string) bool { +func (m *BrandingMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *CertificateMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown Certificate unique edge %s", name) +func (m *BrandingMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Branding unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *CertificateMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown Certificate edge %s", name) +func (m *BrandingMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Branding edge %s", name) } -// ComputerMutation represents an operation that mutates the Computer nodes in the graph. -type ComputerMutation struct { +// CertificateMutation represents an operation that mutates the Certificate nodes in the graph. +type CertificateMutation struct { config - op Op - typ string - id *int - manufacturer *string - model *string - serial *string - memory *uint64 - addmemory *int64 - processor *string - processor_cores *int64 - addprocessor_cores *int64 - processor_arch *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Computer, error) - predicates []predicate.Computer -} - -var _ ent.Mutation = (*ComputerMutation)(nil) - -// computerOption allows management of the mutation configuration using functional options. -type computerOption func(*ComputerMutation) - -// newComputerMutation creates new mutation for the Computer entity. -func newComputerMutation(c config, op Op, opts ...computerOption) *ComputerMutation { - m := &ComputerMutation{ + op Op + typ string + id *int64 + _type *certificate.Type + description *string + expiry *time.Time + uid *string + clearedFields map[string]struct{} + tenant *int + clearedtenant bool + done bool + oldValue func(context.Context) (*Certificate, error) + predicates []predicate.Certificate +} + +var _ ent.Mutation = (*CertificateMutation)(nil) + +// certificateOption allows management of the mutation configuration using functional options. +type certificateOption func(*CertificateMutation) + +// newCertificateMutation creates new mutation for the Certificate entity. +func newCertificateMutation(c config, op Op, opts ...certificateOption) *CertificateMutation { + m := &CertificateMutation{ config: c, op: op, - typ: TypeComputer, + typ: TypeCertificate, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -6926,20 +7451,20 @@ func newComputerMutation(c config, op Op, opts ...computerOption) *ComputerMutat return m } -// withComputerID sets the ID field of the mutation. -func withComputerID(id int) computerOption { - return func(m *ComputerMutation) { +// withCertificateID sets the ID field of the mutation. +func withCertificateID(id int64) certificateOption { + return func(m *CertificateMutation) { var ( err error once sync.Once - value *Computer + value *Certificate ) - m.oldValue = func(ctx context.Context) (*Computer, error) { + m.oldValue = func(ctx context.Context) (*Certificate, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Computer.Get(ctx, id) + value, err = m.Client().Certificate.Get(ctx, id) } }) return value, err @@ -6948,10 +7473,10 @@ func withComputerID(id int) computerOption { } } -// withComputer sets the old Computer of the mutation. -func withComputer(node *Computer) computerOption { - return func(m *ComputerMutation) { - m.oldValue = func(context.Context) (*Computer, error) { +// withCertificate sets the old Certificate of the mutation. +func withCertificate(node *Certificate) certificateOption { + return func(m *CertificateMutation) { + m.oldValue = func(context.Context) (*Certificate, error) { return node, nil } m.id = &node.ID @@ -6960,7 +7485,7 @@ func withComputer(node *Computer) computerOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ComputerMutation) Client() *Client { +func (m CertificateMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -6968,7 +7493,7 @@ func (m ComputerMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ComputerMutation) Tx() (*Tx, error) { +func (m CertificateMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -6977,9 +7502,15 @@ func (m ComputerMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Certificate entities. +func (m *CertificateMutation) SetID(id int64) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ComputerMutation) ID() (id int, exists bool) { +func (m *CertificateMutation) ID() (id int64, exists bool) { if m.id == nil { return } @@ -6990,454 +7521,289 @@ func (m *ComputerMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ComputerMutation) IDs(ctx context.Context) ([]int, error) { +func (m *CertificateMutation) IDs(ctx context.Context) ([]int64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []int64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Computer.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Certificate.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetManufacturer sets the "manufacturer" field. -func (m *ComputerMutation) SetManufacturer(s string) { - m.manufacturer = &s -} - -// Manufacturer returns the value of the "manufacturer" field in the mutation. -func (m *ComputerMutation) Manufacturer() (r string, exists bool) { - v := m.manufacturer - if v == nil { - return - } - return *v, true -} - -// OldManufacturer returns the old "manufacturer" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldManufacturer(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManufacturer requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) - } - return oldValue.Manufacturer, nil -} - -// ClearManufacturer clears the value of the "manufacturer" field. -func (m *ComputerMutation) ClearManufacturer() { - m.manufacturer = nil - m.clearedFields[computer.FieldManufacturer] = struct{}{} -} - -// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. -func (m *ComputerMutation) ManufacturerCleared() bool { - _, ok := m.clearedFields[computer.FieldManufacturer] - return ok -} - -// ResetManufacturer resets all changes to the "manufacturer" field. -func (m *ComputerMutation) ResetManufacturer() { - m.manufacturer = nil - delete(m.clearedFields, computer.FieldManufacturer) -} - -// SetModel sets the "model" field. -func (m *ComputerMutation) SetModel(s string) { - m.model = &s -} - -// Model returns the value of the "model" field in the mutation. -func (m *ComputerMutation) Model() (r string, exists bool) { - v := m.model - if v == nil { - return - } - return *v, true -} - -// OldModel returns the old "model" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldModel(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModel is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModel requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModel: %w", err) - } - return oldValue.Model, nil -} - -// ClearModel clears the value of the "model" field. -func (m *ComputerMutation) ClearModel() { - m.model = nil - m.clearedFields[computer.FieldModel] = struct{}{} -} - -// ModelCleared returns if the "model" field was cleared in this mutation. -func (m *ComputerMutation) ModelCleared() bool { - _, ok := m.clearedFields[computer.FieldModel] - return ok -} - -// ResetModel resets all changes to the "model" field. -func (m *ComputerMutation) ResetModel() { - m.model = nil - delete(m.clearedFields, computer.FieldModel) -} - -// SetSerial sets the "serial" field. -func (m *ComputerMutation) SetSerial(s string) { - m.serial = &s +// SetType sets the "type" field. +func (m *CertificateMutation) SetType(c certificate.Type) { + m._type = &c } -// Serial returns the value of the "serial" field in the mutation. -func (m *ComputerMutation) Serial() (r string, exists bool) { - v := m.serial +// GetType returns the value of the "type" field in the mutation. +func (m *CertificateMutation) GetType() (r certificate.Type, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldSerial returns the old "serial" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the Certificate entity. +// If the Certificate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldSerial(ctx context.Context) (v string, err error) { +func (m *CertificateMutation) OldType(ctx context.Context) (v certificate.Type, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSerial is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSerial requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSerial: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.Serial, nil -} - -// ClearSerial clears the value of the "serial" field. -func (m *ComputerMutation) ClearSerial() { - m.serial = nil - m.clearedFields[computer.FieldSerial] = struct{}{} -} - -// SerialCleared returns if the "serial" field was cleared in this mutation. -func (m *ComputerMutation) SerialCleared() bool { - _, ok := m.clearedFields[computer.FieldSerial] - return ok + return oldValue.Type, nil } -// ResetSerial resets all changes to the "serial" field. -func (m *ComputerMutation) ResetSerial() { - m.serial = nil - delete(m.clearedFields, computer.FieldSerial) +// ResetType resets all changes to the "type" field. +func (m *CertificateMutation) ResetType() { + m._type = nil } -// SetMemory sets the "memory" field. -func (m *ComputerMutation) SetMemory(u uint64) { - m.memory = &u - m.addmemory = nil +// SetDescription sets the "description" field. +func (m *CertificateMutation) SetDescription(s string) { + m.description = &s } -// Memory returns the value of the "memory" field in the mutation. -func (m *ComputerMutation) Memory() (r uint64, exists bool) { - v := m.memory +// Description returns the value of the "description" field in the mutation. +func (m *CertificateMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldMemory returns the old "memory" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the Certificate entity. +// If the Certificate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldMemory(ctx context.Context) (v uint64, err error) { +func (m *CertificateMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMemory is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMemory requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMemory: %w", err) - } - return oldValue.Memory, nil -} - -// AddMemory adds u to the "memory" field. -func (m *ComputerMutation) AddMemory(u int64) { - if m.addmemory != nil { - *m.addmemory += u - } else { - m.addmemory = &u - } -} - -// AddedMemory returns the value that was added to the "memory" field in this mutation. -func (m *ComputerMutation) AddedMemory() (r int64, exists bool) { - v := m.addmemory - if v == nil { - return + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return *v, true + return oldValue.Description, nil } -// ClearMemory clears the value of the "memory" field. -func (m *ComputerMutation) ClearMemory() { - m.memory = nil - m.addmemory = nil - m.clearedFields[computer.FieldMemory] = struct{}{} +// ClearDescription clears the value of the "description" field. +func (m *CertificateMutation) ClearDescription() { + m.description = nil + m.clearedFields[certificate.FieldDescription] = struct{}{} } -// MemoryCleared returns if the "memory" field was cleared in this mutation. -func (m *ComputerMutation) MemoryCleared() bool { - _, ok := m.clearedFields[computer.FieldMemory] +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *CertificateMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[certificate.FieldDescription] return ok } -// ResetMemory resets all changes to the "memory" field. -func (m *ComputerMutation) ResetMemory() { - m.memory = nil - m.addmemory = nil - delete(m.clearedFields, computer.FieldMemory) +// ResetDescription resets all changes to the "description" field. +func (m *CertificateMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, certificate.FieldDescription) } -// SetProcessor sets the "processor" field. -func (m *ComputerMutation) SetProcessor(s string) { - m.processor = &s +// SetExpiry sets the "expiry" field. +func (m *CertificateMutation) SetExpiry(t time.Time) { + m.expiry = &t } -// Processor returns the value of the "processor" field in the mutation. -func (m *ComputerMutation) Processor() (r string, exists bool) { - v := m.processor +// Expiry returns the value of the "expiry" field in the mutation. +func (m *CertificateMutation) Expiry() (r time.Time, exists bool) { + v := m.expiry if v == nil { return } return *v, true } -// OldProcessor returns the old "processor" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. +// OldExpiry returns the old "expiry" field's value of the Certificate entity. +// If the Certificate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldProcessor(ctx context.Context) (v string, err error) { +func (m *CertificateMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProcessor is only allowed on UpdateOne operations") + return v, errors.New("OldExpiry is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProcessor requires an ID field in the mutation") + return v, errors.New("OldExpiry requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProcessor: %w", err) + return v, fmt.Errorf("querying old value for OldExpiry: %w", err) } - return oldValue.Processor, nil + return oldValue.Expiry, nil } -// ClearProcessor clears the value of the "processor" field. -func (m *ComputerMutation) ClearProcessor() { - m.processor = nil - m.clearedFields[computer.FieldProcessor] = struct{}{} +// ClearExpiry clears the value of the "expiry" field. +func (m *CertificateMutation) ClearExpiry() { + m.expiry = nil + m.clearedFields[certificate.FieldExpiry] = struct{}{} } -// ProcessorCleared returns if the "processor" field was cleared in this mutation. -func (m *ComputerMutation) ProcessorCleared() bool { - _, ok := m.clearedFields[computer.FieldProcessor] +// ExpiryCleared returns if the "expiry" field was cleared in this mutation. +func (m *CertificateMutation) ExpiryCleared() bool { + _, ok := m.clearedFields[certificate.FieldExpiry] return ok } -// ResetProcessor resets all changes to the "processor" field. -func (m *ComputerMutation) ResetProcessor() { - m.processor = nil - delete(m.clearedFields, computer.FieldProcessor) +// ResetExpiry resets all changes to the "expiry" field. +func (m *CertificateMutation) ResetExpiry() { + m.expiry = nil + delete(m.clearedFields, certificate.FieldExpiry) } -// SetProcessorCores sets the "processor_cores" field. -func (m *ComputerMutation) SetProcessorCores(i int64) { - m.processor_cores = &i - m.addprocessor_cores = nil +// SetUID sets the "uid" field. +func (m *CertificateMutation) SetUID(s string) { + m.uid = &s } -// ProcessorCores returns the value of the "processor_cores" field in the mutation. -func (m *ComputerMutation) ProcessorCores() (r int64, exists bool) { - v := m.processor_cores +// UID returns the value of the "uid" field in the mutation. +func (m *CertificateMutation) UID() (r string, exists bool) { + v := m.uid if v == nil { return } return *v, true } -// OldProcessorCores returns the old "processor_cores" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. +// OldUID returns the old "uid" field's value of the Certificate entity. +// If the Certificate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldProcessorCores(ctx context.Context) (v int64, err error) { +func (m *CertificateMutation) OldUID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProcessorCores is only allowed on UpdateOne operations") + return v, errors.New("OldUID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProcessorCores requires an ID field in the mutation") + return v, errors.New("OldUID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProcessorCores: %w", err) - } - return oldValue.ProcessorCores, nil -} - -// AddProcessorCores adds i to the "processor_cores" field. -func (m *ComputerMutation) AddProcessorCores(i int64) { - if m.addprocessor_cores != nil { - *m.addprocessor_cores += i - } else { - m.addprocessor_cores = &i - } -} - -// AddedProcessorCores returns the value that was added to the "processor_cores" field in this mutation. -func (m *ComputerMutation) AddedProcessorCores() (r int64, exists bool) { - v := m.addprocessor_cores - if v == nil { - return + return v, fmt.Errorf("querying old value for OldUID: %w", err) } - return *v, true + return oldValue.UID, nil } -// ClearProcessorCores clears the value of the "processor_cores" field. -func (m *ComputerMutation) ClearProcessorCores() { - m.processor_cores = nil - m.addprocessor_cores = nil - m.clearedFields[computer.FieldProcessorCores] = struct{}{} +// ClearUID clears the value of the "uid" field. +func (m *CertificateMutation) ClearUID() { + m.uid = nil + m.clearedFields[certificate.FieldUID] = struct{}{} } -// ProcessorCoresCleared returns if the "processor_cores" field was cleared in this mutation. -func (m *ComputerMutation) ProcessorCoresCleared() bool { - _, ok := m.clearedFields[computer.FieldProcessorCores] +// UIDCleared returns if the "uid" field was cleared in this mutation. +func (m *CertificateMutation) UIDCleared() bool { + _, ok := m.clearedFields[certificate.FieldUID] return ok } -// ResetProcessorCores resets all changes to the "processor_cores" field. -func (m *ComputerMutation) ResetProcessorCores() { - m.processor_cores = nil - m.addprocessor_cores = nil - delete(m.clearedFields, computer.FieldProcessorCores) +// ResetUID resets all changes to the "uid" field. +func (m *CertificateMutation) ResetUID() { + m.uid = nil + delete(m.clearedFields, certificate.FieldUID) } -// SetProcessorArch sets the "processor_arch" field. -func (m *ComputerMutation) SetProcessorArch(s string) { - m.processor_arch = &s +// SetTenantID sets the "tenant_id" field. +func (m *CertificateMutation) SetTenantID(i int) { + m.tenant = &i } -// ProcessorArch returns the value of the "processor_arch" field in the mutation. -func (m *ComputerMutation) ProcessorArch() (r string, exists bool) { - v := m.processor_arch +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *CertificateMutation) TenantID() (r int, exists bool) { + v := m.tenant if v == nil { return } return *v, true } -// OldProcessorArch returns the old "processor_arch" field's value of the Computer entity. -// If the Computer object wasn't provided to the builder, the object is fetched from the database. +// OldTenantID returns the old "tenant_id" field's value of the Certificate entity. +// If the Certificate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ComputerMutation) OldProcessorArch(ctx context.Context) (v string, err error) { +func (m *CertificateMutation) OldTenantID(ctx context.Context) (v *int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProcessorArch is only allowed on UpdateOne operations") + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProcessorArch requires an ID field in the mutation") + return v, errors.New("OldTenantID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProcessorArch: %w", err) + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) } - return oldValue.ProcessorArch, nil + return oldValue.TenantID, nil } -// ClearProcessorArch clears the value of the "processor_arch" field. -func (m *ComputerMutation) ClearProcessorArch() { - m.processor_arch = nil - m.clearedFields[computer.FieldProcessorArch] = struct{}{} +// ClearTenantID clears the value of the "tenant_id" field. +func (m *CertificateMutation) ClearTenantID() { + m.tenant = nil + m.clearedFields[certificate.FieldTenantID] = struct{}{} } -// ProcessorArchCleared returns if the "processor_arch" field was cleared in this mutation. -func (m *ComputerMutation) ProcessorArchCleared() bool { - _, ok := m.clearedFields[computer.FieldProcessorArch] +// TenantIDCleared returns if the "tenant_id" field was cleared in this mutation. +func (m *CertificateMutation) TenantIDCleared() bool { + _, ok := m.clearedFields[certificate.FieldTenantID] return ok } -// ResetProcessorArch resets all changes to the "processor_arch" field. -func (m *ComputerMutation) ResetProcessorArch() { - m.processor_arch = nil - delete(m.clearedFields, computer.FieldProcessorArch) -} - -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *ComputerMutation) SetOwnerID(id string) { - m.owner = &id -} - -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *ComputerMutation) ClearOwner() { - m.clearedowner = true +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *CertificateMutation) ResetTenantID() { + m.tenant = nil + delete(m.clearedFields, certificate.FieldTenantID) } -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *ComputerMutation) OwnerCleared() bool { - return m.clearedowner +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *CertificateMutation) ClearTenant() { + m.clearedtenant = true + m.clearedFields[certificate.FieldTenantID] = struct{}{} } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *ComputerMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true - } - return +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *CertificateMutation) TenantCleared() bool { + return m.TenantIDCleared() || m.clearedtenant } -// OwnerIDs returns the "owner" edge IDs in the mutation. +// TenantIDs returns the "tenant" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *ComputerMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { +// TenantID instead. It exists only for internal usage by the builders. +func (m *CertificateMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { ids = append(ids, *id) } return } -// ResetOwner resets all changes to the "owner" edge. -func (m *ComputerMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ResetTenant resets all changes to the "tenant" edge. +func (m *CertificateMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false } -// Where appends a list predicates to the ComputerMutation builder. -func (m *ComputerMutation) Where(ps ...predicate.Computer) { +// Where appends a list predicates to the CertificateMutation builder. +func (m *CertificateMutation) Where(ps ...predicate.Certificate) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ComputerMutation builder. Using this method, +// WhereP appends storage-level predicates to the CertificateMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ComputerMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Computer, len(ps)) +func (m *CertificateMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Certificate, len(ps)) for i := range ps { p[i] = ps[i] } @@ -7445,45 +7811,39 @@ func (m *ComputerMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ComputerMutation) Op() Op { +func (m *CertificateMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ComputerMutation) SetOp(op Op) { +func (m *CertificateMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Computer). -func (m *ComputerMutation) Type() string { +// Type returns the node type of this mutation (Certificate). +func (m *CertificateMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ComputerMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.manufacturer != nil { - fields = append(fields, computer.FieldManufacturer) - } - if m.model != nil { - fields = append(fields, computer.FieldModel) - } - if m.serial != nil { - fields = append(fields, computer.FieldSerial) +func (m *CertificateMutation) Fields() []string { + fields := make([]string, 0, 5) + if m._type != nil { + fields = append(fields, certificate.FieldType) } - if m.memory != nil { - fields = append(fields, computer.FieldMemory) + if m.description != nil { + fields = append(fields, certificate.FieldDescription) } - if m.processor != nil { - fields = append(fields, computer.FieldProcessor) + if m.expiry != nil { + fields = append(fields, certificate.FieldExpiry) } - if m.processor_cores != nil { - fields = append(fields, computer.FieldProcessorCores) + if m.uid != nil { + fields = append(fields, certificate.FieldUID) } - if m.processor_arch != nil { - fields = append(fields, computer.FieldProcessorArch) + if m.tenant != nil { + fields = append(fields, certificate.FieldTenantID) } return fields } @@ -7491,22 +7851,18 @@ func (m *ComputerMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ComputerMutation) Field(name string) (ent.Value, bool) { +func (m *CertificateMutation) Field(name string) (ent.Value, bool) { switch name { - case computer.FieldManufacturer: - return m.Manufacturer() - case computer.FieldModel: - return m.Model() - case computer.FieldSerial: - return m.Serial() - case computer.FieldMemory: - return m.Memory() - case computer.FieldProcessor: - return m.Processor() - case computer.FieldProcessorCores: - return m.ProcessorCores() - case computer.FieldProcessorArch: - return m.ProcessorArch() + case certificate.FieldType: + return m.GetType() + case certificate.FieldDescription: + return m.Description() + case certificate.FieldExpiry: + return m.Expiry() + case certificate.FieldUID: + return m.UID() + case certificate.FieldTenantID: + return m.TenantID() } return nil, false } @@ -7514,106 +7870,78 @@ func (m *ComputerMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ComputerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *CertificateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case computer.FieldManufacturer: - return m.OldManufacturer(ctx) - case computer.FieldModel: - return m.OldModel(ctx) - case computer.FieldSerial: - return m.OldSerial(ctx) - case computer.FieldMemory: - return m.OldMemory(ctx) - case computer.FieldProcessor: - return m.OldProcessor(ctx) - case computer.FieldProcessorCores: - return m.OldProcessorCores(ctx) - case computer.FieldProcessorArch: - return m.OldProcessorArch(ctx) + case certificate.FieldType: + return m.OldType(ctx) + case certificate.FieldDescription: + return m.OldDescription(ctx) + case certificate.FieldExpiry: + return m.OldExpiry(ctx) + case certificate.FieldUID: + return m.OldUID(ctx) + case certificate.FieldTenantID: + return m.OldTenantID(ctx) } - return nil, fmt.Errorf("unknown Computer field %s", name) + return nil, fmt.Errorf("unknown Certificate field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ComputerMutation) SetField(name string, value ent.Value) error { +func (m *CertificateMutation) SetField(name string, value ent.Value) error { switch name { - case computer.FieldManufacturer: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManufacturer(v) - return nil - case computer.FieldModel: - v, ok := value.(string) + case certificate.FieldType: + v, ok := value.(certificate.Type) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModel(v) + m.SetType(v) return nil - case computer.FieldSerial: + case certificate.FieldDescription: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSerial(v) + m.SetDescription(v) return nil - case computer.FieldMemory: - v, ok := value.(uint64) + case certificate.FieldExpiry: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetMemory(v) + m.SetExpiry(v) return nil - case computer.FieldProcessor: + case certificate.FieldUID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProcessor(v) - return nil - case computer.FieldProcessorCores: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetProcessorCores(v) + m.SetUID(v) return nil - case computer.FieldProcessorArch: - v, ok := value.(string) + case certificate.FieldTenantID: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProcessorArch(v) + m.SetTenantID(v) return nil } - return fmt.Errorf("unknown Computer field %s", name) + return fmt.Errorf("unknown Certificate field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ComputerMutation) AddedFields() []string { +func (m *CertificateMutation) AddedFields() []string { var fields []string - if m.addmemory != nil { - fields = append(fields, computer.FieldMemory) - } - if m.addprocessor_cores != nil { - fields = append(fields, computer.FieldProcessorCores) - } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ComputerMutation) AddedField(name string) (ent.Value, bool) { +func (m *CertificateMutation) AddedField(name string) (ent.Value, bool) { switch name { - case computer.FieldMemory: - return m.AddedMemory() - case computer.FieldProcessorCores: - return m.AddedProcessorCores() } return nil, false } @@ -7621,134 +7949,96 @@ func (m *ComputerMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ComputerMutation) AddField(name string, value ent.Value) error { +func (m *CertificateMutation) AddField(name string, value ent.Value) error { switch name { - case computer.FieldMemory: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddMemory(v) - return nil - case computer.FieldProcessorCores: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddProcessorCores(v) - return nil } - return fmt.Errorf("unknown Computer numeric field %s", name) + return fmt.Errorf("unknown Certificate numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ComputerMutation) ClearedFields() []string { +func (m *CertificateMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(computer.FieldManufacturer) { - fields = append(fields, computer.FieldManufacturer) - } - if m.FieldCleared(computer.FieldModel) { - fields = append(fields, computer.FieldModel) - } - if m.FieldCleared(computer.FieldSerial) { - fields = append(fields, computer.FieldSerial) - } - if m.FieldCleared(computer.FieldMemory) { - fields = append(fields, computer.FieldMemory) + if m.FieldCleared(certificate.FieldDescription) { + fields = append(fields, certificate.FieldDescription) } - if m.FieldCleared(computer.FieldProcessor) { - fields = append(fields, computer.FieldProcessor) + if m.FieldCleared(certificate.FieldExpiry) { + fields = append(fields, certificate.FieldExpiry) } - if m.FieldCleared(computer.FieldProcessorCores) { - fields = append(fields, computer.FieldProcessorCores) + if m.FieldCleared(certificate.FieldUID) { + fields = append(fields, certificate.FieldUID) } - if m.FieldCleared(computer.FieldProcessorArch) { - fields = append(fields, computer.FieldProcessorArch) + if m.FieldCleared(certificate.FieldTenantID) { + fields = append(fields, certificate.FieldTenantID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ComputerMutation) FieldCleared(name string) bool { +func (m *CertificateMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ComputerMutation) ClearField(name string) error { +func (m *CertificateMutation) ClearField(name string) error { switch name { - case computer.FieldManufacturer: - m.ClearManufacturer() - return nil - case computer.FieldModel: - m.ClearModel() - return nil - case computer.FieldSerial: - m.ClearSerial() - return nil - case computer.FieldMemory: - m.ClearMemory() + case certificate.FieldDescription: + m.ClearDescription() return nil - case computer.FieldProcessor: - m.ClearProcessor() + case certificate.FieldExpiry: + m.ClearExpiry() return nil - case computer.FieldProcessorCores: - m.ClearProcessorCores() + case certificate.FieldUID: + m.ClearUID() return nil - case computer.FieldProcessorArch: - m.ClearProcessorArch() + case certificate.FieldTenantID: + m.ClearTenantID() return nil } - return fmt.Errorf("unknown Computer nullable field %s", name) + return fmt.Errorf("unknown Certificate nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ComputerMutation) ResetField(name string) error { +func (m *CertificateMutation) ResetField(name string) error { switch name { - case computer.FieldManufacturer: - m.ResetManufacturer() - return nil - case computer.FieldModel: - m.ResetModel() - return nil - case computer.FieldSerial: - m.ResetSerial() + case certificate.FieldType: + m.ResetType() return nil - case computer.FieldMemory: - m.ResetMemory() + case certificate.FieldDescription: + m.ResetDescription() return nil - case computer.FieldProcessor: - m.ResetProcessor() + case certificate.FieldExpiry: + m.ResetExpiry() return nil - case computer.FieldProcessorCores: - m.ResetProcessorCores() + case certificate.FieldUID: + m.ResetUID() return nil - case computer.FieldProcessorArch: - m.ResetProcessorArch() + case certificate.FieldTenantID: + m.ResetTenantID() return nil } - return fmt.Errorf("unknown Computer field %s", name) + return fmt.Errorf("unknown Certificate field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ComputerMutation) AddedEdges() []string { +func (m *CertificateMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, computer.EdgeOwner) + if m.tenant != nil { + edges = append(edges, certificate.EdgeTenant) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ComputerMutation) AddedIDs(name string) []ent.Value { +func (m *CertificateMutation) AddedIDs(name string) []ent.Value { switch name { - case computer.EdgeOwner: - if id := m.owner; id != nil { + case certificate.EdgeTenant: + if id := m.tenant; id != nil { return []ent.Value{*id} } } @@ -7756,90 +8046,92 @@ func (m *ComputerMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ComputerMutation) RemovedEdges() []string { +func (m *CertificateMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ComputerMutation) RemovedIDs(name string) []ent.Value { +func (m *CertificateMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ComputerMutation) ClearedEdges() []string { +func (m *CertificateMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, computer.EdgeOwner) + if m.clearedtenant { + edges = append(edges, certificate.EdgeTenant) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ComputerMutation) EdgeCleared(name string) bool { +func (m *CertificateMutation) EdgeCleared(name string) bool { switch name { - case computer.EdgeOwner: - return m.clearedowner + case certificate.EdgeTenant: + return m.clearedtenant } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ComputerMutation) ClearEdge(name string) error { +func (m *CertificateMutation) ClearEdge(name string) error { switch name { - case computer.EdgeOwner: - m.ClearOwner() + case certificate.EdgeTenant: + m.ClearTenant() return nil } - return fmt.Errorf("unknown Computer unique edge %s", name) + return fmt.Errorf("unknown Certificate unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ComputerMutation) ResetEdge(name string) error { +func (m *CertificateMutation) ResetEdge(name string) error { switch name { - case computer.EdgeOwner: - m.ResetOwner() + case certificate.EdgeTenant: + m.ResetTenant() return nil } - return fmt.Errorf("unknown Computer edge %s", name) + return fmt.Errorf("unknown Certificate edge %s", name) } -// DeploymentMutation represents an operation that mutates the Deployment nodes in the graph. -type DeploymentMutation struct { +// ComputerMutation represents an operation that mutates the Computer nodes in the graph. +type ComputerMutation struct { config - op Op - typ string - id *int - package_id *string - name *string - version *string - installed *time.Time - updated *time.Time - failed *bool - by_profile *bool - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Deployment, error) - predicates []predicate.Deployment + op Op + typ string + id *int + manufacturer *string + model *string + serial *string + memory *uint64 + addmemory *int64 + processor *string + processor_cores *int64 + addprocessor_cores *int64 + processor_arch *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Computer, error) + predicates []predicate.Computer } -var _ ent.Mutation = (*DeploymentMutation)(nil) +var _ ent.Mutation = (*ComputerMutation)(nil) -// deploymentOption allows management of the mutation configuration using functional options. -type deploymentOption func(*DeploymentMutation) +// computerOption allows management of the mutation configuration using functional options. +type computerOption func(*ComputerMutation) -// newDeploymentMutation creates new mutation for the Deployment entity. -func newDeploymentMutation(c config, op Op, opts ...deploymentOption) *DeploymentMutation { - m := &DeploymentMutation{ +// newComputerMutation creates new mutation for the Computer entity. +func newComputerMutation(c config, op Op, opts ...computerOption) *ComputerMutation { + m := &ComputerMutation{ config: c, op: op, - typ: TypeDeployment, + typ: TypeComputer, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -7848,20 +8140,20 @@ func newDeploymentMutation(c config, op Op, opts ...deploymentOption) *Deploymen return m } -// withDeploymentID sets the ID field of the mutation. -func withDeploymentID(id int) deploymentOption { - return func(m *DeploymentMutation) { +// withComputerID sets the ID field of the mutation. +func withComputerID(id int) computerOption { + return func(m *ComputerMutation) { var ( err error once sync.Once - value *Deployment + value *Computer ) - m.oldValue = func(ctx context.Context) (*Deployment, error) { + m.oldValue = func(ctx context.Context) (*Computer, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Deployment.Get(ctx, id) + value, err = m.Client().Computer.Get(ctx, id) } }) return value, err @@ -7870,10 +8162,10 @@ func withDeploymentID(id int) deploymentOption { } } -// withDeployment sets the old Deployment of the mutation. -func withDeployment(node *Deployment) deploymentOption { - return func(m *DeploymentMutation) { - m.oldValue = func(context.Context) (*Deployment, error) { +// withComputer sets the old Computer of the mutation. +func withComputer(node *Computer) computerOption { + return func(m *ComputerMutation) { + m.oldValue = func(context.Context) (*Computer, error) { return node, nil } m.id = &node.ID @@ -7882,7 +8174,7 @@ func withDeployment(node *Deployment) deploymentOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m DeploymentMutation) Client() *Client { +func (m ComputerMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -7890,7 +8182,7 @@ func (m DeploymentMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m DeploymentMutation) Tx() (*Tx, error) { +func (m ComputerMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -7901,7 +8193,7 @@ func (m DeploymentMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *DeploymentMutation) ID() (id int, exists bool) { +func (m *ComputerMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -7912,7 +8204,7 @@ func (m *DeploymentMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *DeploymentMutation) IDs(ctx context.Context) ([]int, error) { +func (m *ComputerMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -7921,346 +8213,414 @@ func (m *DeploymentMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Deployment.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Computer.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetPackageID sets the "package_id" field. -func (m *DeploymentMutation) SetPackageID(s string) { - m.package_id = &s +// SetManufacturer sets the "manufacturer" field. +func (m *ComputerMutation) SetManufacturer(s string) { + m.manufacturer = &s } -// PackageID returns the value of the "package_id" field in the mutation. -func (m *DeploymentMutation) PackageID() (r string, exists bool) { - v := m.package_id +// Manufacturer returns the value of the "manufacturer" field in the mutation. +func (m *ComputerMutation) Manufacturer() (r string, exists bool) { + v := m.manufacturer if v == nil { return } return *v, true } -// OldPackageID returns the old "package_id" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. +// OldManufacturer returns the old "manufacturer" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldPackageID(ctx context.Context) (v string, err error) { +func (m *ComputerMutation) OldManufacturer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageID is only allowed on UpdateOne operations") + return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageID requires an ID field in the mutation") + return v, errors.New("OldManufacturer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPackageID: %w", err) + return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) } - return oldValue.PackageID, nil -} - -// ResetPackageID resets all changes to the "package_id" field. -func (m *DeploymentMutation) ResetPackageID() { - m.package_id = nil -} - -// SetName sets the "name" field. -func (m *DeploymentMutation) SetName(s string) { - m.name = &s + return oldValue.Manufacturer, nil } -// Name returns the value of the "name" field in the mutation. -func (m *DeploymentMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true +// ClearManufacturer clears the value of the "manufacturer" field. +func (m *ComputerMutation) ClearManufacturer() { + m.manufacturer = nil + m.clearedFields[computer.FieldManufacturer] = struct{}{} } -// OldName returns the old "name" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil +// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. +func (m *ComputerMutation) ManufacturerCleared() bool { + _, ok := m.clearedFields[computer.FieldManufacturer] + return ok } -// ResetName resets all changes to the "name" field. -func (m *DeploymentMutation) ResetName() { - m.name = nil +// ResetManufacturer resets all changes to the "manufacturer" field. +func (m *ComputerMutation) ResetManufacturer() { + m.manufacturer = nil + delete(m.clearedFields, computer.FieldManufacturer) } -// SetVersion sets the "version" field. -func (m *DeploymentMutation) SetVersion(s string) { - m.version = &s +// SetModel sets the "model" field. +func (m *ComputerMutation) SetModel(s string) { + m.model = &s } -// Version returns the value of the "version" field in the mutation. -func (m *DeploymentMutation) Version() (r string, exists bool) { - v := m.version +// Model returns the value of the "model" field in the mutation. +func (m *ComputerMutation) Model() (r string, exists bool) { + v := m.model if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. +// OldModel returns the old "model" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldVersion(ctx context.Context) (v string, err error) { +func (m *ComputerMutation) OldModel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldModel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldModel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) + return v, fmt.Errorf("querying old value for OldModel: %w", err) } - return oldValue.Version, nil + return oldValue.Model, nil } -// ClearVersion clears the value of the "version" field. -func (m *DeploymentMutation) ClearVersion() { - m.version = nil - m.clearedFields[deployment.FieldVersion] = struct{}{} +// ClearModel clears the value of the "model" field. +func (m *ComputerMutation) ClearModel() { + m.model = nil + m.clearedFields[computer.FieldModel] = struct{}{} } -// VersionCleared returns if the "version" field was cleared in this mutation. -func (m *DeploymentMutation) VersionCleared() bool { - _, ok := m.clearedFields[deployment.FieldVersion] +// ModelCleared returns if the "model" field was cleared in this mutation. +func (m *ComputerMutation) ModelCleared() bool { + _, ok := m.clearedFields[computer.FieldModel] return ok } -// ResetVersion resets all changes to the "version" field. -func (m *DeploymentMutation) ResetVersion() { - m.version = nil - delete(m.clearedFields, deployment.FieldVersion) +// ResetModel resets all changes to the "model" field. +func (m *ComputerMutation) ResetModel() { + m.model = nil + delete(m.clearedFields, computer.FieldModel) } -// SetInstalled sets the "installed" field. -func (m *DeploymentMutation) SetInstalled(t time.Time) { - m.installed = &t +// SetSerial sets the "serial" field. +func (m *ComputerMutation) SetSerial(s string) { + m.serial = &s } -// Installed returns the value of the "installed" field in the mutation. -func (m *DeploymentMutation) Installed() (r time.Time, exists bool) { - v := m.installed +// Serial returns the value of the "serial" field in the mutation. +func (m *ComputerMutation) Serial() (r string, exists bool) { + v := m.serial if v == nil { return } return *v, true } -// OldInstalled returns the old "installed" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. +// OldSerial returns the old "serial" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldInstalled(ctx context.Context) (v time.Time, err error) { +func (m *ComputerMutation) OldSerial(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInstalled is only allowed on UpdateOne operations") + return v, errors.New("OldSerial is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInstalled requires an ID field in the mutation") + return v, errors.New("OldSerial requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInstalled: %w", err) + return v, fmt.Errorf("querying old value for OldSerial: %w", err) } - return oldValue.Installed, nil + return oldValue.Serial, nil } -// ClearInstalled clears the value of the "installed" field. -func (m *DeploymentMutation) ClearInstalled() { - m.installed = nil - m.clearedFields[deployment.FieldInstalled] = struct{}{} +// ClearSerial clears the value of the "serial" field. +func (m *ComputerMutation) ClearSerial() { + m.serial = nil + m.clearedFields[computer.FieldSerial] = struct{}{} } -// InstalledCleared returns if the "installed" field was cleared in this mutation. -func (m *DeploymentMutation) InstalledCleared() bool { - _, ok := m.clearedFields[deployment.FieldInstalled] +// SerialCleared returns if the "serial" field was cleared in this mutation. +func (m *ComputerMutation) SerialCleared() bool { + _, ok := m.clearedFields[computer.FieldSerial] return ok } -// ResetInstalled resets all changes to the "installed" field. -func (m *DeploymentMutation) ResetInstalled() { - m.installed = nil - delete(m.clearedFields, deployment.FieldInstalled) +// ResetSerial resets all changes to the "serial" field. +func (m *ComputerMutation) ResetSerial() { + m.serial = nil + delete(m.clearedFields, computer.FieldSerial) } -// SetUpdated sets the "updated" field. -func (m *DeploymentMutation) SetUpdated(t time.Time) { - m.updated = &t +// SetMemory sets the "memory" field. +func (m *ComputerMutation) SetMemory(u uint64) { + m.memory = &u + m.addmemory = nil } -// Updated returns the value of the "updated" field in the mutation. -func (m *DeploymentMutation) Updated() (r time.Time, exists bool) { - v := m.updated +// Memory returns the value of the "memory" field in the mutation. +func (m *ComputerMutation) Memory() (r uint64, exists bool) { + v := m.memory if v == nil { return } return *v, true } -// OldUpdated returns the old "updated" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. +// OldMemory returns the old "memory" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldUpdated(ctx context.Context) (v time.Time, err error) { +func (m *ComputerMutation) OldMemory(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdated is only allowed on UpdateOne operations") + return v, errors.New("OldMemory is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdated requires an ID field in the mutation") + return v, errors.New("OldMemory requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdated: %w", err) + return v, fmt.Errorf("querying old value for OldMemory: %w", err) } - return oldValue.Updated, nil + return oldValue.Memory, nil } -// ClearUpdated clears the value of the "updated" field. -func (m *DeploymentMutation) ClearUpdated() { - m.updated = nil - m.clearedFields[deployment.FieldUpdated] = struct{}{} +// AddMemory adds u to the "memory" field. +func (m *ComputerMutation) AddMemory(u int64) { + if m.addmemory != nil { + *m.addmemory += u + } else { + m.addmemory = &u + } } -// UpdatedCleared returns if the "updated" field was cleared in this mutation. -func (m *DeploymentMutation) UpdatedCleared() bool { - _, ok := m.clearedFields[deployment.FieldUpdated] +// AddedMemory returns the value that was added to the "memory" field in this mutation. +func (m *ComputerMutation) AddedMemory() (r int64, exists bool) { + v := m.addmemory + if v == nil { + return + } + return *v, true +} + +// ClearMemory clears the value of the "memory" field. +func (m *ComputerMutation) ClearMemory() { + m.memory = nil + m.addmemory = nil + m.clearedFields[computer.FieldMemory] = struct{}{} +} + +// MemoryCleared returns if the "memory" field was cleared in this mutation. +func (m *ComputerMutation) MemoryCleared() bool { + _, ok := m.clearedFields[computer.FieldMemory] return ok } -// ResetUpdated resets all changes to the "updated" field. -func (m *DeploymentMutation) ResetUpdated() { - m.updated = nil - delete(m.clearedFields, deployment.FieldUpdated) +// ResetMemory resets all changes to the "memory" field. +func (m *ComputerMutation) ResetMemory() { + m.memory = nil + m.addmemory = nil + delete(m.clearedFields, computer.FieldMemory) } -// SetFailed sets the "failed" field. -func (m *DeploymentMutation) SetFailed(b bool) { - m.failed = &b +// SetProcessor sets the "processor" field. +func (m *ComputerMutation) SetProcessor(s string) { + m.processor = &s } -// Failed returns the value of the "failed" field in the mutation. -func (m *DeploymentMutation) Failed() (r bool, exists bool) { - v := m.failed +// Processor returns the value of the "processor" field in the mutation. +func (m *ComputerMutation) Processor() (r string, exists bool) { + v := m.processor if v == nil { return } return *v, true } -// OldFailed returns the old "failed" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. +// OldProcessor returns the old "processor" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldFailed(ctx context.Context) (v bool, err error) { +func (m *ComputerMutation) OldProcessor(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldFailed is only allowed on UpdateOne operations") + return v, errors.New("OldProcessor is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldFailed requires an ID field in the mutation") + return v, errors.New("OldProcessor requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldFailed: %w", err) + return v, fmt.Errorf("querying old value for OldProcessor: %w", err) } - return oldValue.Failed, nil + return oldValue.Processor, nil } -// ClearFailed clears the value of the "failed" field. -func (m *DeploymentMutation) ClearFailed() { - m.failed = nil - m.clearedFields[deployment.FieldFailed] = struct{}{} +// ClearProcessor clears the value of the "processor" field. +func (m *ComputerMutation) ClearProcessor() { + m.processor = nil + m.clearedFields[computer.FieldProcessor] = struct{}{} } -// FailedCleared returns if the "failed" field was cleared in this mutation. -func (m *DeploymentMutation) FailedCleared() bool { - _, ok := m.clearedFields[deployment.FieldFailed] +// ProcessorCleared returns if the "processor" field was cleared in this mutation. +func (m *ComputerMutation) ProcessorCleared() bool { + _, ok := m.clearedFields[computer.FieldProcessor] return ok } -// ResetFailed resets all changes to the "failed" field. -func (m *DeploymentMutation) ResetFailed() { - m.failed = nil - delete(m.clearedFields, deployment.FieldFailed) +// ResetProcessor resets all changes to the "processor" field. +func (m *ComputerMutation) ResetProcessor() { + m.processor = nil + delete(m.clearedFields, computer.FieldProcessor) } -// SetByProfile sets the "by_profile" field. -func (m *DeploymentMutation) SetByProfile(b bool) { - m.by_profile = &b +// SetProcessorCores sets the "processor_cores" field. +func (m *ComputerMutation) SetProcessorCores(i int64) { + m.processor_cores = &i + m.addprocessor_cores = nil } -// ByProfile returns the value of the "by_profile" field in the mutation. -func (m *DeploymentMutation) ByProfile() (r bool, exists bool) { - v := m.by_profile +// ProcessorCores returns the value of the "processor_cores" field in the mutation. +func (m *ComputerMutation) ProcessorCores() (r int64, exists bool) { + v := m.processor_cores if v == nil { return } return *v, true } -// OldByProfile returns the old "by_profile" field's value of the Deployment entity. -// If the Deployment object wasn't provided to the builder, the object is fetched from the database. +// OldProcessorCores returns the old "processor_cores" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DeploymentMutation) OldByProfile(ctx context.Context) (v bool, err error) { +func (m *ComputerMutation) OldProcessorCores(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldByProfile is only allowed on UpdateOne operations") + return v, errors.New("OldProcessorCores is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldByProfile requires an ID field in the mutation") + return v, errors.New("OldProcessorCores requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldByProfile: %w", err) + return v, fmt.Errorf("querying old value for OldProcessorCores: %w", err) } - return oldValue.ByProfile, nil + return oldValue.ProcessorCores, nil } -// ClearByProfile clears the value of the "by_profile" field. -func (m *DeploymentMutation) ClearByProfile() { - m.by_profile = nil - m.clearedFields[deployment.FieldByProfile] = struct{}{} +// AddProcessorCores adds i to the "processor_cores" field. +func (m *ComputerMutation) AddProcessorCores(i int64) { + if m.addprocessor_cores != nil { + *m.addprocessor_cores += i + } else { + m.addprocessor_cores = &i + } } -// ByProfileCleared returns if the "by_profile" field was cleared in this mutation. -func (m *DeploymentMutation) ByProfileCleared() bool { - _, ok := m.clearedFields[deployment.FieldByProfile] +// AddedProcessorCores returns the value that was added to the "processor_cores" field in this mutation. +func (m *ComputerMutation) AddedProcessorCores() (r int64, exists bool) { + v := m.addprocessor_cores + if v == nil { + return + } + return *v, true +} + +// ClearProcessorCores clears the value of the "processor_cores" field. +func (m *ComputerMutation) ClearProcessorCores() { + m.processor_cores = nil + m.addprocessor_cores = nil + m.clearedFields[computer.FieldProcessorCores] = struct{}{} +} + +// ProcessorCoresCleared returns if the "processor_cores" field was cleared in this mutation. +func (m *ComputerMutation) ProcessorCoresCleared() bool { + _, ok := m.clearedFields[computer.FieldProcessorCores] return ok } -// ResetByProfile resets all changes to the "by_profile" field. -func (m *DeploymentMutation) ResetByProfile() { - m.by_profile = nil - delete(m.clearedFields, deployment.FieldByProfile) +// ResetProcessorCores resets all changes to the "processor_cores" field. +func (m *ComputerMutation) ResetProcessorCores() { + m.processor_cores = nil + m.addprocessor_cores = nil + delete(m.clearedFields, computer.FieldProcessorCores) +} + +// SetProcessorArch sets the "processor_arch" field. +func (m *ComputerMutation) SetProcessorArch(s string) { + m.processor_arch = &s +} + +// ProcessorArch returns the value of the "processor_arch" field in the mutation. +func (m *ComputerMutation) ProcessorArch() (r string, exists bool) { + v := m.processor_arch + if v == nil { + return + } + return *v, true +} + +// OldProcessorArch returns the old "processor_arch" field's value of the Computer entity. +// If the Computer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ComputerMutation) OldProcessorArch(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProcessorArch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProcessorArch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProcessorArch: %w", err) + } + return oldValue.ProcessorArch, nil +} + +// ClearProcessorArch clears the value of the "processor_arch" field. +func (m *ComputerMutation) ClearProcessorArch() { + m.processor_arch = nil + m.clearedFields[computer.FieldProcessorArch] = struct{}{} +} + +// ProcessorArchCleared returns if the "processor_arch" field was cleared in this mutation. +func (m *ComputerMutation) ProcessorArchCleared() bool { + _, ok := m.clearedFields[computer.FieldProcessorArch] + return ok +} + +// ResetProcessorArch resets all changes to the "processor_arch" field. +func (m *ComputerMutation) ResetProcessorArch() { + m.processor_arch = nil + delete(m.clearedFields, computer.FieldProcessorArch) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *DeploymentMutation) SetOwnerID(id string) { +func (m *ComputerMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *DeploymentMutation) ClearOwner() { +func (m *ComputerMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *DeploymentMutation) OwnerCleared() bool { +func (m *ComputerMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *DeploymentMutation) OwnerID() (id string, exists bool) { +func (m *ComputerMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -8270,7 +8630,7 @@ func (m *DeploymentMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *DeploymentMutation) OwnerIDs() (ids []string) { +func (m *ComputerMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -8278,20 +8638,20 @@ func (m *DeploymentMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *DeploymentMutation) ResetOwner() { +func (m *ComputerMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the DeploymentMutation builder. -func (m *DeploymentMutation) Where(ps ...predicate.Deployment) { +// Where appends a list predicates to the ComputerMutation builder. +func (m *ComputerMutation) Where(ps ...predicate.Computer) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the DeploymentMutation builder. Using this method, +// WhereP appends storage-level predicates to the ComputerMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *DeploymentMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Deployment, len(ps)) +func (m *ComputerMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Computer, len(ps)) for i := range ps { p[i] = ps[i] } @@ -8299,45 +8659,45 @@ func (m *DeploymentMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *DeploymentMutation) Op() Op { +func (m *ComputerMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *DeploymentMutation) SetOp(op Op) { +func (m *ComputerMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Deployment). -func (m *DeploymentMutation) Type() string { +// Type returns the node type of this mutation (Computer). +func (m *ComputerMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *DeploymentMutation) Fields() []string { +func (m *ComputerMutation) Fields() []string { fields := make([]string, 0, 7) - if m.package_id != nil { - fields = append(fields, deployment.FieldPackageID) + if m.manufacturer != nil { + fields = append(fields, computer.FieldManufacturer) } - if m.name != nil { - fields = append(fields, deployment.FieldName) + if m.model != nil { + fields = append(fields, computer.FieldModel) } - if m.version != nil { - fields = append(fields, deployment.FieldVersion) + if m.serial != nil { + fields = append(fields, computer.FieldSerial) } - if m.installed != nil { - fields = append(fields, deployment.FieldInstalled) + if m.memory != nil { + fields = append(fields, computer.FieldMemory) } - if m.updated != nil { - fields = append(fields, deployment.FieldUpdated) + if m.processor != nil { + fields = append(fields, computer.FieldProcessor) } - if m.failed != nil { - fields = append(fields, deployment.FieldFailed) + if m.processor_cores != nil { + fields = append(fields, computer.FieldProcessorCores) } - if m.by_profile != nil { - fields = append(fields, deployment.FieldByProfile) + if m.processor_arch != nil { + fields = append(fields, computer.FieldProcessorArch) } return fields } @@ -8345,22 +8705,22 @@ func (m *DeploymentMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *DeploymentMutation) Field(name string) (ent.Value, bool) { +func (m *ComputerMutation) Field(name string) (ent.Value, bool) { switch name { - case deployment.FieldPackageID: - return m.PackageID() - case deployment.FieldName: - return m.Name() - case deployment.FieldVersion: - return m.Version() - case deployment.FieldInstalled: - return m.Installed() - case deployment.FieldUpdated: - return m.Updated() - case deployment.FieldFailed: - return m.Failed() - case deployment.FieldByProfile: - return m.ByProfile() + case computer.FieldManufacturer: + return m.Manufacturer() + case computer.FieldModel: + return m.Model() + case computer.FieldSerial: + return m.Serial() + case computer.FieldMemory: + return m.Memory() + case computer.FieldProcessor: + return m.Processor() + case computer.FieldProcessorCores: + return m.ProcessorCores() + case computer.FieldProcessorArch: + return m.ProcessorArch() } return nil, false } @@ -8368,201 +8728,240 @@ func (m *DeploymentMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *DeploymentMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ComputerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case deployment.FieldPackageID: - return m.OldPackageID(ctx) - case deployment.FieldName: - return m.OldName(ctx) - case deployment.FieldVersion: - return m.OldVersion(ctx) - case deployment.FieldInstalled: - return m.OldInstalled(ctx) - case deployment.FieldUpdated: - return m.OldUpdated(ctx) - case deployment.FieldFailed: - return m.OldFailed(ctx) - case deployment.FieldByProfile: - return m.OldByProfile(ctx) + case computer.FieldManufacturer: + return m.OldManufacturer(ctx) + case computer.FieldModel: + return m.OldModel(ctx) + case computer.FieldSerial: + return m.OldSerial(ctx) + case computer.FieldMemory: + return m.OldMemory(ctx) + case computer.FieldProcessor: + return m.OldProcessor(ctx) + case computer.FieldProcessorCores: + return m.OldProcessorCores(ctx) + case computer.FieldProcessorArch: + return m.OldProcessorArch(ctx) } - return nil, fmt.Errorf("unknown Deployment field %s", name) + return nil, fmt.Errorf("unknown Computer field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *DeploymentMutation) SetField(name string, value ent.Value) error { +func (m *ComputerMutation) SetField(name string, value ent.Value) error { switch name { - case deployment.FieldPackageID: + case computer.FieldManufacturer: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPackageID(v) + m.SetManufacturer(v) return nil - case deployment.FieldName: + case computer.FieldModel: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetModel(v) return nil - case deployment.FieldVersion: + case computer.FieldSerial: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVersion(v) + m.SetSerial(v) return nil - case deployment.FieldInstalled: - v, ok := value.(time.Time) + case computer.FieldMemory: + v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInstalled(v) + m.SetMemory(v) return nil - case deployment.FieldUpdated: - v, ok := value.(time.Time) + case computer.FieldProcessor: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUpdated(v) + m.SetProcessor(v) return nil - case deployment.FieldFailed: - v, ok := value.(bool) + case computer.FieldProcessorCores: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetFailed(v) + m.SetProcessorCores(v) return nil - case deployment.FieldByProfile: - v, ok := value.(bool) + case computer.FieldProcessorArch: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetByProfile(v) + m.SetProcessorArch(v) return nil } - return fmt.Errorf("unknown Deployment field %s", name) + return fmt.Errorf("unknown Computer field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *DeploymentMutation) AddedFields() []string { - return nil +func (m *ComputerMutation) AddedFields() []string { + var fields []string + if m.addmemory != nil { + fields = append(fields, computer.FieldMemory) + } + if m.addprocessor_cores != nil { + fields = append(fields, computer.FieldProcessorCores) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *DeploymentMutation) AddedField(name string) (ent.Value, bool) { +func (m *ComputerMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case computer.FieldMemory: + return m.AddedMemory() + case computer.FieldProcessorCores: + return m.AddedProcessorCores() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *DeploymentMutation) AddField(name string, value ent.Value) error { +func (m *ComputerMutation) AddField(name string, value ent.Value) error { switch name { + case computer.FieldMemory: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMemory(v) + return nil + case computer.FieldProcessorCores: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddProcessorCores(v) + return nil } - return fmt.Errorf("unknown Deployment numeric field %s", name) + return fmt.Errorf("unknown Computer numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *DeploymentMutation) ClearedFields() []string { +func (m *ComputerMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(deployment.FieldVersion) { - fields = append(fields, deployment.FieldVersion) + if m.FieldCleared(computer.FieldManufacturer) { + fields = append(fields, computer.FieldManufacturer) } - if m.FieldCleared(deployment.FieldInstalled) { - fields = append(fields, deployment.FieldInstalled) + if m.FieldCleared(computer.FieldModel) { + fields = append(fields, computer.FieldModel) } - if m.FieldCleared(deployment.FieldUpdated) { - fields = append(fields, deployment.FieldUpdated) + if m.FieldCleared(computer.FieldSerial) { + fields = append(fields, computer.FieldSerial) } - if m.FieldCleared(deployment.FieldFailed) { - fields = append(fields, deployment.FieldFailed) + if m.FieldCleared(computer.FieldMemory) { + fields = append(fields, computer.FieldMemory) } - if m.FieldCleared(deployment.FieldByProfile) { - fields = append(fields, deployment.FieldByProfile) + if m.FieldCleared(computer.FieldProcessor) { + fields = append(fields, computer.FieldProcessor) + } + if m.FieldCleared(computer.FieldProcessorCores) { + fields = append(fields, computer.FieldProcessorCores) + } + if m.FieldCleared(computer.FieldProcessorArch) { + fields = append(fields, computer.FieldProcessorArch) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *DeploymentMutation) FieldCleared(name string) bool { +func (m *ComputerMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *DeploymentMutation) ClearField(name string) error { +func (m *ComputerMutation) ClearField(name string) error { switch name { - case deployment.FieldVersion: - m.ClearVersion() + case computer.FieldManufacturer: + m.ClearManufacturer() return nil - case deployment.FieldInstalled: - m.ClearInstalled() + case computer.FieldModel: + m.ClearModel() return nil - case deployment.FieldUpdated: - m.ClearUpdated() + case computer.FieldSerial: + m.ClearSerial() return nil - case deployment.FieldFailed: - m.ClearFailed() + case computer.FieldMemory: + m.ClearMemory() return nil - case deployment.FieldByProfile: - m.ClearByProfile() + case computer.FieldProcessor: + m.ClearProcessor() + return nil + case computer.FieldProcessorCores: + m.ClearProcessorCores() + return nil + case computer.FieldProcessorArch: + m.ClearProcessorArch() return nil } - return fmt.Errorf("unknown Deployment nullable field %s", name) + return fmt.Errorf("unknown Computer nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *DeploymentMutation) ResetField(name string) error { +func (m *ComputerMutation) ResetField(name string) error { switch name { - case deployment.FieldPackageID: - m.ResetPackageID() + case computer.FieldManufacturer: + m.ResetManufacturer() return nil - case deployment.FieldName: - m.ResetName() + case computer.FieldModel: + m.ResetModel() return nil - case deployment.FieldVersion: - m.ResetVersion() + case computer.FieldSerial: + m.ResetSerial() return nil - case deployment.FieldInstalled: - m.ResetInstalled() + case computer.FieldMemory: + m.ResetMemory() return nil - case deployment.FieldUpdated: - m.ResetUpdated() + case computer.FieldProcessor: + m.ResetProcessor() return nil - case deployment.FieldFailed: - m.ResetFailed() + case computer.FieldProcessorCores: + m.ResetProcessorCores() return nil - case deployment.FieldByProfile: - m.ResetByProfile() + case computer.FieldProcessorArch: + m.ResetProcessorArch() return nil } - return fmt.Errorf("unknown Deployment field %s", name) + return fmt.Errorf("unknown Computer field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *DeploymentMutation) AddedEdges() []string { +func (m *ComputerMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, deployment.EdgeOwner) + edges = append(edges, computer.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *DeploymentMutation) AddedIDs(name string) []ent.Value { +func (m *ComputerMutation) AddedIDs(name string) []ent.Value { switch name { - case deployment.EdgeOwner: + case computer.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -8571,31 +8970,31 @@ func (m *DeploymentMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *DeploymentMutation) RemovedEdges() []string { +func (m *ComputerMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *DeploymentMutation) RemovedIDs(name string) []ent.Value { +func (m *ComputerMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *DeploymentMutation) ClearedEdges() []string { +func (m *ComputerMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, deployment.EdgeOwner) + edges = append(edges, computer.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *DeploymentMutation) EdgeCleared(name string) bool { +func (m *ComputerMutation) EdgeCleared(name string) bool { switch name { - case deployment.EdgeOwner: + case computer.EdgeOwner: return m.clearedowner } return false @@ -8603,59 +9002,58 @@ func (m *DeploymentMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *DeploymentMutation) ClearEdge(name string) error { +func (m *ComputerMutation) ClearEdge(name string) error { switch name { - case deployment.EdgeOwner: + case computer.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown Deployment unique edge %s", name) + return fmt.Errorf("unknown Computer unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *DeploymentMutation) ResetEdge(name string) error { +func (m *ComputerMutation) ResetEdge(name string) error { switch name { - case deployment.EdgeOwner: + case computer.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown Deployment edge %s", name) + return fmt.Errorf("unknown Computer edge %s", name) } -// LogicalDiskMutation represents an operation that mutates the LogicalDisk nodes in the graph. -type LogicalDiskMutation struct { +// DeploymentMutation represents an operation that mutates the Deployment nodes in the graph. +type DeploymentMutation struct { config - op Op - typ string - id *int - label *string - filesystem *string - usage *int8 - addusage *int8 - size_in_units *string - remaining_space_in_units *string - volume_name *string - bitlocker_status *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*LogicalDisk, error) - predicates []predicate.LogicalDisk + op Op + typ string + id *int + package_id *string + name *string + version *string + installed *time.Time + updated *time.Time + failed *bool + by_profile *bool + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Deployment, error) + predicates []predicate.Deployment } -var _ ent.Mutation = (*LogicalDiskMutation)(nil) +var _ ent.Mutation = (*DeploymentMutation)(nil) -// logicaldiskOption allows management of the mutation configuration using functional options. -type logicaldiskOption func(*LogicalDiskMutation) +// deploymentOption allows management of the mutation configuration using functional options. +type deploymentOption func(*DeploymentMutation) -// newLogicalDiskMutation creates new mutation for the LogicalDisk entity. -func newLogicalDiskMutation(c config, op Op, opts ...logicaldiskOption) *LogicalDiskMutation { - m := &LogicalDiskMutation{ +// newDeploymentMutation creates new mutation for the Deployment entity. +func newDeploymentMutation(c config, op Op, opts ...deploymentOption) *DeploymentMutation { + m := &DeploymentMutation{ config: c, op: op, - typ: TypeLogicalDisk, + typ: TypeDeployment, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -8664,20 +9062,20 @@ func newLogicalDiskMutation(c config, op Op, opts ...logicaldiskOption) *Logical return m } -// withLogicalDiskID sets the ID field of the mutation. -func withLogicalDiskID(id int) logicaldiskOption { - return func(m *LogicalDiskMutation) { +// withDeploymentID sets the ID field of the mutation. +func withDeploymentID(id int) deploymentOption { + return func(m *DeploymentMutation) { var ( err error once sync.Once - value *LogicalDisk + value *Deployment ) - m.oldValue = func(ctx context.Context) (*LogicalDisk, error) { + m.oldValue = func(ctx context.Context) (*Deployment, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().LogicalDisk.Get(ctx, id) + value, err = m.Client().Deployment.Get(ctx, id) } }) return value, err @@ -8686,10 +9084,10 @@ func withLogicalDiskID(id int) logicaldiskOption { } } -// withLogicalDisk sets the old LogicalDisk of the mutation. -func withLogicalDisk(node *LogicalDisk) logicaldiskOption { - return func(m *LogicalDiskMutation) { - m.oldValue = func(context.Context) (*LogicalDisk, error) { +// withDeployment sets the old Deployment of the mutation. +func withDeployment(node *Deployment) deploymentOption { + return func(m *DeploymentMutation) { + m.oldValue = func(context.Context) (*Deployment, error) { return node, nil } m.id = &node.ID @@ -8698,7 +9096,7 @@ func withLogicalDisk(node *LogicalDisk) logicaldiskOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m LogicalDiskMutation) Client() *Client { +func (m DeploymentMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -8706,7 +9104,7 @@ func (m LogicalDiskMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m LogicalDiskMutation) Tx() (*Tx, error) { +func (m DeploymentMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -8717,7 +9115,7 @@ func (m LogicalDiskMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *LogicalDiskMutation) ID() (id int, exists bool) { +func (m *DeploymentMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -8728,7 +9126,7 @@ func (m *LogicalDiskMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *LogicalDiskMutation) IDs(ctx context.Context) ([]int, error) { +func (m *DeploymentMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -8737,366 +9135,346 @@ func (m *LogicalDiskMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().LogicalDisk.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Deployment.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetLabel sets the "label" field. -func (m *LogicalDiskMutation) SetLabel(s string) { - m.label = &s +// SetPackageID sets the "package_id" field. +func (m *DeploymentMutation) SetPackageID(s string) { + m.package_id = &s } -// Label returns the value of the "label" field in the mutation. -func (m *LogicalDiskMutation) Label() (r string, exists bool) { - v := m.label +// PackageID returns the value of the "package_id" field in the mutation. +func (m *DeploymentMutation) PackageID() (r string, exists bool) { + v := m.package_id if v == nil { return } return *v, true } -// OldLabel returns the old "label" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldPackageID returns the old "package_id" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldLabel(ctx context.Context) (v string, err error) { +func (m *DeploymentMutation) OldPackageID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLabel is only allowed on UpdateOne operations") + return v, errors.New("OldPackageID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLabel requires an ID field in the mutation") + return v, errors.New("OldPackageID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLabel: %w", err) + return v, fmt.Errorf("querying old value for OldPackageID: %w", err) } - return oldValue.Label, nil + return oldValue.PackageID, nil } -// ResetLabel resets all changes to the "label" field. -func (m *LogicalDiskMutation) ResetLabel() { - m.label = nil +// ResetPackageID resets all changes to the "package_id" field. +func (m *DeploymentMutation) ResetPackageID() { + m.package_id = nil } -// SetFilesystem sets the "filesystem" field. -func (m *LogicalDiskMutation) SetFilesystem(s string) { - m.filesystem = &s +// SetName sets the "name" field. +func (m *DeploymentMutation) SetName(s string) { + m.name = &s } -// Filesystem returns the value of the "filesystem" field in the mutation. -func (m *LogicalDiskMutation) Filesystem() (r string, exists bool) { - v := m.filesystem +// Name returns the value of the "name" field in the mutation. +func (m *DeploymentMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldFilesystem returns the old "filesystem" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldFilesystem(ctx context.Context) (v string, err error) { +func (m *DeploymentMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldFilesystem is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldFilesystem requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldFilesystem: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Filesystem, nil -} - -// ClearFilesystem clears the value of the "filesystem" field. -func (m *LogicalDiskMutation) ClearFilesystem() { - m.filesystem = nil - m.clearedFields[logicaldisk.FieldFilesystem] = struct{}{} -} - -// FilesystemCleared returns if the "filesystem" field was cleared in this mutation. -func (m *LogicalDiskMutation) FilesystemCleared() bool { - _, ok := m.clearedFields[logicaldisk.FieldFilesystem] - return ok + return oldValue.Name, nil } -// ResetFilesystem resets all changes to the "filesystem" field. -func (m *LogicalDiskMutation) ResetFilesystem() { - m.filesystem = nil - delete(m.clearedFields, logicaldisk.FieldFilesystem) +// ResetName resets all changes to the "name" field. +func (m *DeploymentMutation) ResetName() { + m.name = nil } -// SetUsage sets the "usage" field. -func (m *LogicalDiskMutation) SetUsage(i int8) { - m.usage = &i - m.addusage = nil +// SetVersion sets the "version" field. +func (m *DeploymentMutation) SetVersion(s string) { + m.version = &s } -// Usage returns the value of the "usage" field in the mutation. -func (m *LogicalDiskMutation) Usage() (r int8, exists bool) { - v := m.usage +// Version returns the value of the "version" field in the mutation. +func (m *DeploymentMutation) Version() (r string, exists bool) { + v := m.version if v == nil { return } return *v, true } -// OldUsage returns the old "usage" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldVersion returns the old "version" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldUsage(ctx context.Context) (v int8, err error) { +func (m *DeploymentMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsage is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsage requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUsage: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.Usage, nil + return oldValue.Version, nil } -// AddUsage adds i to the "usage" field. -func (m *LogicalDiskMutation) AddUsage(i int8) { - if m.addusage != nil { - *m.addusage += i - } else { - m.addusage = &i - } +// ClearVersion clears the value of the "version" field. +func (m *DeploymentMutation) ClearVersion() { + m.version = nil + m.clearedFields[deployment.FieldVersion] = struct{}{} } -// AddedUsage returns the value that was added to the "usage" field in this mutation. -func (m *LogicalDiskMutation) AddedUsage() (r int8, exists bool) { - v := m.addusage - if v == nil { - return - } - return *v, true +// VersionCleared returns if the "version" field was cleared in this mutation. +func (m *DeploymentMutation) VersionCleared() bool { + _, ok := m.clearedFields[deployment.FieldVersion] + return ok } -// ResetUsage resets all changes to the "usage" field. -func (m *LogicalDiskMutation) ResetUsage() { - m.usage = nil - m.addusage = nil +// ResetVersion resets all changes to the "version" field. +func (m *DeploymentMutation) ResetVersion() { + m.version = nil + delete(m.clearedFields, deployment.FieldVersion) } -// SetSizeInUnits sets the "size_in_units" field. -func (m *LogicalDiskMutation) SetSizeInUnits(s string) { - m.size_in_units = &s +// SetInstalled sets the "installed" field. +func (m *DeploymentMutation) SetInstalled(t time.Time) { + m.installed = &t } -// SizeInUnits returns the value of the "size_in_units" field in the mutation. -func (m *LogicalDiskMutation) SizeInUnits() (r string, exists bool) { - v := m.size_in_units +// Installed returns the value of the "installed" field in the mutation. +func (m *DeploymentMutation) Installed() (r time.Time, exists bool) { + v := m.installed if v == nil { return } return *v, true } -// OldSizeInUnits returns the old "size_in_units" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldInstalled returns the old "installed" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldSizeInUnits(ctx context.Context) (v string, err error) { +func (m *DeploymentMutation) OldInstalled(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSizeInUnits is only allowed on UpdateOne operations") + return v, errors.New("OldInstalled is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSizeInUnits requires an ID field in the mutation") + return v, errors.New("OldInstalled requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSizeInUnits: %w", err) + return v, fmt.Errorf("querying old value for OldInstalled: %w", err) } - return oldValue.SizeInUnits, nil + return oldValue.Installed, nil } -// ClearSizeInUnits clears the value of the "size_in_units" field. -func (m *LogicalDiskMutation) ClearSizeInUnits() { - m.size_in_units = nil - m.clearedFields[logicaldisk.FieldSizeInUnits] = struct{}{} +// ClearInstalled clears the value of the "installed" field. +func (m *DeploymentMutation) ClearInstalled() { + m.installed = nil + m.clearedFields[deployment.FieldInstalled] = struct{}{} } -// SizeInUnitsCleared returns if the "size_in_units" field was cleared in this mutation. -func (m *LogicalDiskMutation) SizeInUnitsCleared() bool { - _, ok := m.clearedFields[logicaldisk.FieldSizeInUnits] +// InstalledCleared returns if the "installed" field was cleared in this mutation. +func (m *DeploymentMutation) InstalledCleared() bool { + _, ok := m.clearedFields[deployment.FieldInstalled] return ok } -// ResetSizeInUnits resets all changes to the "size_in_units" field. -func (m *LogicalDiskMutation) ResetSizeInUnits() { - m.size_in_units = nil - delete(m.clearedFields, logicaldisk.FieldSizeInUnits) +// ResetInstalled resets all changes to the "installed" field. +func (m *DeploymentMutation) ResetInstalled() { + m.installed = nil + delete(m.clearedFields, deployment.FieldInstalled) } -// SetRemainingSpaceInUnits sets the "remaining_space_in_units" field. -func (m *LogicalDiskMutation) SetRemainingSpaceInUnits(s string) { - m.remaining_space_in_units = &s +// SetUpdated sets the "updated" field. +func (m *DeploymentMutation) SetUpdated(t time.Time) { + m.updated = &t } -// RemainingSpaceInUnits returns the value of the "remaining_space_in_units" field in the mutation. -func (m *LogicalDiskMutation) RemainingSpaceInUnits() (r string, exists bool) { - v := m.remaining_space_in_units +// Updated returns the value of the "updated" field in the mutation. +func (m *DeploymentMutation) Updated() (r time.Time, exists bool) { + v := m.updated if v == nil { return } return *v, true } -// OldRemainingSpaceInUnits returns the old "remaining_space_in_units" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldUpdated returns the old "updated" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldRemainingSpaceInUnits(ctx context.Context) (v string, err error) { +func (m *DeploymentMutation) OldUpdated(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemainingSpaceInUnits is only allowed on UpdateOne operations") + return v, errors.New("OldUpdated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemainingSpaceInUnits requires an ID field in the mutation") + return v, errors.New("OldUpdated requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRemainingSpaceInUnits: %w", err) + return v, fmt.Errorf("querying old value for OldUpdated: %w", err) } - return oldValue.RemainingSpaceInUnits, nil + return oldValue.Updated, nil } -// ClearRemainingSpaceInUnits clears the value of the "remaining_space_in_units" field. -func (m *LogicalDiskMutation) ClearRemainingSpaceInUnits() { - m.remaining_space_in_units = nil - m.clearedFields[logicaldisk.FieldRemainingSpaceInUnits] = struct{}{} +// ClearUpdated clears the value of the "updated" field. +func (m *DeploymentMutation) ClearUpdated() { + m.updated = nil + m.clearedFields[deployment.FieldUpdated] = struct{}{} } -// RemainingSpaceInUnitsCleared returns if the "remaining_space_in_units" field was cleared in this mutation. -func (m *LogicalDiskMutation) RemainingSpaceInUnitsCleared() bool { - _, ok := m.clearedFields[logicaldisk.FieldRemainingSpaceInUnits] +// UpdatedCleared returns if the "updated" field was cleared in this mutation. +func (m *DeploymentMutation) UpdatedCleared() bool { + _, ok := m.clearedFields[deployment.FieldUpdated] return ok } -// ResetRemainingSpaceInUnits resets all changes to the "remaining_space_in_units" field. -func (m *LogicalDiskMutation) ResetRemainingSpaceInUnits() { - m.remaining_space_in_units = nil - delete(m.clearedFields, logicaldisk.FieldRemainingSpaceInUnits) +// ResetUpdated resets all changes to the "updated" field. +func (m *DeploymentMutation) ResetUpdated() { + m.updated = nil + delete(m.clearedFields, deployment.FieldUpdated) } -// SetVolumeName sets the "volume_name" field. -func (m *LogicalDiskMutation) SetVolumeName(s string) { - m.volume_name = &s +// SetFailed sets the "failed" field. +func (m *DeploymentMutation) SetFailed(b bool) { + m.failed = &b } -// VolumeName returns the value of the "volume_name" field in the mutation. -func (m *LogicalDiskMutation) VolumeName() (r string, exists bool) { - v := m.volume_name +// Failed returns the value of the "failed" field in the mutation. +func (m *DeploymentMutation) Failed() (r bool, exists bool) { + v := m.failed if v == nil { return } return *v, true } -// OldVolumeName returns the old "volume_name" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldFailed returns the old "failed" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldVolumeName(ctx context.Context) (v string, err error) { +func (m *DeploymentMutation) OldFailed(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVolumeName is only allowed on UpdateOne operations") + return v, errors.New("OldFailed is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVolumeName requires an ID field in the mutation") + return v, errors.New("OldFailed requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVolumeName: %w", err) + return v, fmt.Errorf("querying old value for OldFailed: %w", err) } - return oldValue.VolumeName, nil + return oldValue.Failed, nil } -// ClearVolumeName clears the value of the "volume_name" field. -func (m *LogicalDiskMutation) ClearVolumeName() { - m.volume_name = nil - m.clearedFields[logicaldisk.FieldVolumeName] = struct{}{} +// ClearFailed clears the value of the "failed" field. +func (m *DeploymentMutation) ClearFailed() { + m.failed = nil + m.clearedFields[deployment.FieldFailed] = struct{}{} } -// VolumeNameCleared returns if the "volume_name" field was cleared in this mutation. -func (m *LogicalDiskMutation) VolumeNameCleared() bool { - _, ok := m.clearedFields[logicaldisk.FieldVolumeName] +// FailedCleared returns if the "failed" field was cleared in this mutation. +func (m *DeploymentMutation) FailedCleared() bool { + _, ok := m.clearedFields[deployment.FieldFailed] return ok } -// ResetVolumeName resets all changes to the "volume_name" field. -func (m *LogicalDiskMutation) ResetVolumeName() { - m.volume_name = nil - delete(m.clearedFields, logicaldisk.FieldVolumeName) +// ResetFailed resets all changes to the "failed" field. +func (m *DeploymentMutation) ResetFailed() { + m.failed = nil + delete(m.clearedFields, deployment.FieldFailed) } -// SetBitlockerStatus sets the "bitlocker_status" field. -func (m *LogicalDiskMutation) SetBitlockerStatus(s string) { - m.bitlocker_status = &s +// SetByProfile sets the "by_profile" field. +func (m *DeploymentMutation) SetByProfile(b bool) { + m.by_profile = &b } -// BitlockerStatus returns the value of the "bitlocker_status" field in the mutation. -func (m *LogicalDiskMutation) BitlockerStatus() (r string, exists bool) { - v := m.bitlocker_status +// ByProfile returns the value of the "by_profile" field in the mutation. +func (m *DeploymentMutation) ByProfile() (r bool, exists bool) { + v := m.by_profile if v == nil { return } return *v, true } -// OldBitlockerStatus returns the old "bitlocker_status" field's value of the LogicalDisk entity. -// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldByProfile returns the old "by_profile" field's value of the Deployment entity. +// If the Deployment object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *LogicalDiskMutation) OldBitlockerStatus(ctx context.Context) (v string, err error) { +func (m *DeploymentMutation) OldByProfile(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBitlockerStatus is only allowed on UpdateOne operations") + return v, errors.New("OldByProfile is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBitlockerStatus requires an ID field in the mutation") + return v, errors.New("OldByProfile requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBitlockerStatus: %w", err) + return v, fmt.Errorf("querying old value for OldByProfile: %w", err) } - return oldValue.BitlockerStatus, nil + return oldValue.ByProfile, nil } -// ClearBitlockerStatus clears the value of the "bitlocker_status" field. -func (m *LogicalDiskMutation) ClearBitlockerStatus() { - m.bitlocker_status = nil - m.clearedFields[logicaldisk.FieldBitlockerStatus] = struct{}{} +// ClearByProfile clears the value of the "by_profile" field. +func (m *DeploymentMutation) ClearByProfile() { + m.by_profile = nil + m.clearedFields[deployment.FieldByProfile] = struct{}{} } -// BitlockerStatusCleared returns if the "bitlocker_status" field was cleared in this mutation. -func (m *LogicalDiskMutation) BitlockerStatusCleared() bool { - _, ok := m.clearedFields[logicaldisk.FieldBitlockerStatus] +// ByProfileCleared returns if the "by_profile" field was cleared in this mutation. +func (m *DeploymentMutation) ByProfileCleared() bool { + _, ok := m.clearedFields[deployment.FieldByProfile] return ok } -// ResetBitlockerStatus resets all changes to the "bitlocker_status" field. -func (m *LogicalDiskMutation) ResetBitlockerStatus() { - m.bitlocker_status = nil - delete(m.clearedFields, logicaldisk.FieldBitlockerStatus) +// ResetByProfile resets all changes to the "by_profile" field. +func (m *DeploymentMutation) ResetByProfile() { + m.by_profile = nil + delete(m.clearedFields, deployment.FieldByProfile) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *LogicalDiskMutation) SetOwnerID(id string) { +func (m *DeploymentMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *LogicalDiskMutation) ClearOwner() { +func (m *DeploymentMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *LogicalDiskMutation) OwnerCleared() bool { +func (m *DeploymentMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *LogicalDiskMutation) OwnerID() (id string, exists bool) { +func (m *DeploymentMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -9106,7 +9484,7 @@ func (m *LogicalDiskMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *LogicalDiskMutation) OwnerIDs() (ids []string) { +func (m *DeploymentMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -9114,20 +9492,20 @@ func (m *LogicalDiskMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *LogicalDiskMutation) ResetOwner() { +func (m *DeploymentMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the LogicalDiskMutation builder. -func (m *LogicalDiskMutation) Where(ps ...predicate.LogicalDisk) { +// Where appends a list predicates to the DeploymentMutation builder. +func (m *DeploymentMutation) Where(ps ...predicate.Deployment) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the LogicalDiskMutation builder. Using this method, +// WhereP appends storage-level predicates to the DeploymentMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *LogicalDiskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.LogicalDisk, len(ps)) +func (m *DeploymentMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Deployment, len(ps)) for i := range ps { p[i] = ps[i] } @@ -9135,45 +9513,45 @@ func (m *LogicalDiskMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *LogicalDiskMutation) Op() Op { +func (m *DeploymentMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *LogicalDiskMutation) SetOp(op Op) { +func (m *DeploymentMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (LogicalDisk). -func (m *LogicalDiskMutation) Type() string { +// Type returns the node type of this mutation (Deployment). +func (m *DeploymentMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *LogicalDiskMutation) Fields() []string { +func (m *DeploymentMutation) Fields() []string { fields := make([]string, 0, 7) - if m.label != nil { - fields = append(fields, logicaldisk.FieldLabel) + if m.package_id != nil { + fields = append(fields, deployment.FieldPackageID) } - if m.filesystem != nil { - fields = append(fields, logicaldisk.FieldFilesystem) + if m.name != nil { + fields = append(fields, deployment.FieldName) } - if m.usage != nil { - fields = append(fields, logicaldisk.FieldUsage) + if m.version != nil { + fields = append(fields, deployment.FieldVersion) } - if m.size_in_units != nil { - fields = append(fields, logicaldisk.FieldSizeInUnits) + if m.installed != nil { + fields = append(fields, deployment.FieldInstalled) } - if m.remaining_space_in_units != nil { - fields = append(fields, logicaldisk.FieldRemainingSpaceInUnits) + if m.updated != nil { + fields = append(fields, deployment.FieldUpdated) } - if m.volume_name != nil { - fields = append(fields, logicaldisk.FieldVolumeName) + if m.failed != nil { + fields = append(fields, deployment.FieldFailed) } - if m.bitlocker_status != nil { - fields = append(fields, logicaldisk.FieldBitlockerStatus) + if m.by_profile != nil { + fields = append(fields, deployment.FieldByProfile) } return fields } @@ -9181,239 +9559,224 @@ func (m *LogicalDiskMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *LogicalDiskMutation) Field(name string) (ent.Value, bool) { - switch name { - case logicaldisk.FieldLabel: - return m.Label() - case logicaldisk.FieldFilesystem: - return m.Filesystem() - case logicaldisk.FieldUsage: - return m.Usage() - case logicaldisk.FieldSizeInUnits: - return m.SizeInUnits() - case logicaldisk.FieldRemainingSpaceInUnits: - return m.RemainingSpaceInUnits() - case logicaldisk.FieldVolumeName: - return m.VolumeName() - case logicaldisk.FieldBitlockerStatus: - return m.BitlockerStatus() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *LogicalDiskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *DeploymentMutation) Field(name string) (ent.Value, bool) { switch name { - case logicaldisk.FieldLabel: - return m.OldLabel(ctx) - case logicaldisk.FieldFilesystem: - return m.OldFilesystem(ctx) - case logicaldisk.FieldUsage: - return m.OldUsage(ctx) - case logicaldisk.FieldSizeInUnits: - return m.OldSizeInUnits(ctx) - case logicaldisk.FieldRemainingSpaceInUnits: - return m.OldRemainingSpaceInUnits(ctx) - case logicaldisk.FieldVolumeName: - return m.OldVolumeName(ctx) - case logicaldisk.FieldBitlockerStatus: - return m.OldBitlockerStatus(ctx) + case deployment.FieldPackageID: + return m.PackageID() + case deployment.FieldName: + return m.Name() + case deployment.FieldVersion: + return m.Version() + case deployment.FieldInstalled: + return m.Installed() + case deployment.FieldUpdated: + return m.Updated() + case deployment.FieldFailed: + return m.Failed() + case deployment.FieldByProfile: + return m.ByProfile() } - return nil, fmt.Errorf("unknown LogicalDisk field %s", name) + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *DeploymentMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case deployment.FieldPackageID: + return m.OldPackageID(ctx) + case deployment.FieldName: + return m.OldName(ctx) + case deployment.FieldVersion: + return m.OldVersion(ctx) + case deployment.FieldInstalled: + return m.OldInstalled(ctx) + case deployment.FieldUpdated: + return m.OldUpdated(ctx) + case deployment.FieldFailed: + return m.OldFailed(ctx) + case deployment.FieldByProfile: + return m.OldByProfile(ctx) + } + return nil, fmt.Errorf("unknown Deployment field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *LogicalDiskMutation) SetField(name string, value ent.Value) error { +func (m *DeploymentMutation) SetField(name string, value ent.Value) error { switch name { - case logicaldisk.FieldLabel: + case deployment.FieldPackageID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetLabel(v) + m.SetPackageID(v) return nil - case logicaldisk.FieldFilesystem: + case deployment.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetFilesystem(v) + m.SetName(v) return nil - case logicaldisk.FieldUsage: - v, ok := value.(int8) + case deployment.FieldVersion: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUsage(v) + m.SetVersion(v) return nil - case logicaldisk.FieldSizeInUnits: - v, ok := value.(string) + case deployment.FieldInstalled: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSizeInUnits(v) + m.SetInstalled(v) return nil - case logicaldisk.FieldRemainingSpaceInUnits: - v, ok := value.(string) + case deployment.FieldUpdated: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRemainingSpaceInUnits(v) + m.SetUpdated(v) return nil - case logicaldisk.FieldVolumeName: - v, ok := value.(string) + case deployment.FieldFailed: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVolumeName(v) + m.SetFailed(v) return nil - case logicaldisk.FieldBitlockerStatus: - v, ok := value.(string) + case deployment.FieldByProfile: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetBitlockerStatus(v) + m.SetByProfile(v) return nil } - return fmt.Errorf("unknown LogicalDisk field %s", name) + return fmt.Errorf("unknown Deployment field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *LogicalDiskMutation) AddedFields() []string { - var fields []string - if m.addusage != nil { - fields = append(fields, logicaldisk.FieldUsage) - } - return fields +func (m *DeploymentMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *LogicalDiskMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case logicaldisk.FieldUsage: - return m.AddedUsage() - } +func (m *DeploymentMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *LogicalDiskMutation) AddField(name string, value ent.Value) error { +func (m *DeploymentMutation) AddField(name string, value ent.Value) error { switch name { - case logicaldisk.FieldUsage: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUsage(v) - return nil } - return fmt.Errorf("unknown LogicalDisk numeric field %s", name) + return fmt.Errorf("unknown Deployment numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *LogicalDiskMutation) ClearedFields() []string { +func (m *DeploymentMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(logicaldisk.FieldFilesystem) { - fields = append(fields, logicaldisk.FieldFilesystem) + if m.FieldCleared(deployment.FieldVersion) { + fields = append(fields, deployment.FieldVersion) } - if m.FieldCleared(logicaldisk.FieldSizeInUnits) { - fields = append(fields, logicaldisk.FieldSizeInUnits) + if m.FieldCleared(deployment.FieldInstalled) { + fields = append(fields, deployment.FieldInstalled) } - if m.FieldCleared(logicaldisk.FieldRemainingSpaceInUnits) { - fields = append(fields, logicaldisk.FieldRemainingSpaceInUnits) + if m.FieldCleared(deployment.FieldUpdated) { + fields = append(fields, deployment.FieldUpdated) } - if m.FieldCleared(logicaldisk.FieldVolumeName) { - fields = append(fields, logicaldisk.FieldVolumeName) + if m.FieldCleared(deployment.FieldFailed) { + fields = append(fields, deployment.FieldFailed) } - if m.FieldCleared(logicaldisk.FieldBitlockerStatus) { - fields = append(fields, logicaldisk.FieldBitlockerStatus) + if m.FieldCleared(deployment.FieldByProfile) { + fields = append(fields, deployment.FieldByProfile) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *LogicalDiskMutation) FieldCleared(name string) bool { +func (m *DeploymentMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *LogicalDiskMutation) ClearField(name string) error { +func (m *DeploymentMutation) ClearField(name string) error { switch name { - case logicaldisk.FieldFilesystem: - m.ClearFilesystem() + case deployment.FieldVersion: + m.ClearVersion() return nil - case logicaldisk.FieldSizeInUnits: - m.ClearSizeInUnits() + case deployment.FieldInstalled: + m.ClearInstalled() return nil - case logicaldisk.FieldRemainingSpaceInUnits: - m.ClearRemainingSpaceInUnits() + case deployment.FieldUpdated: + m.ClearUpdated() return nil - case logicaldisk.FieldVolumeName: - m.ClearVolumeName() + case deployment.FieldFailed: + m.ClearFailed() return nil - case logicaldisk.FieldBitlockerStatus: - m.ClearBitlockerStatus() + case deployment.FieldByProfile: + m.ClearByProfile() return nil } - return fmt.Errorf("unknown LogicalDisk nullable field %s", name) + return fmt.Errorf("unknown Deployment nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *LogicalDiskMutation) ResetField(name string) error { +func (m *DeploymentMutation) ResetField(name string) error { switch name { - case logicaldisk.FieldLabel: - m.ResetLabel() + case deployment.FieldPackageID: + m.ResetPackageID() return nil - case logicaldisk.FieldFilesystem: - m.ResetFilesystem() + case deployment.FieldName: + m.ResetName() return nil - case logicaldisk.FieldUsage: - m.ResetUsage() + case deployment.FieldVersion: + m.ResetVersion() return nil - case logicaldisk.FieldSizeInUnits: - m.ResetSizeInUnits() + case deployment.FieldInstalled: + m.ResetInstalled() return nil - case logicaldisk.FieldRemainingSpaceInUnits: - m.ResetRemainingSpaceInUnits() + case deployment.FieldUpdated: + m.ResetUpdated() return nil - case logicaldisk.FieldVolumeName: - m.ResetVolumeName() + case deployment.FieldFailed: + m.ResetFailed() return nil - case logicaldisk.FieldBitlockerStatus: - m.ResetBitlockerStatus() + case deployment.FieldByProfile: + m.ResetByProfile() return nil } - return fmt.Errorf("unknown LogicalDisk field %s", name) + return fmt.Errorf("unknown Deployment field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *LogicalDiskMutation) AddedEdges() []string { +func (m *DeploymentMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, logicaldisk.EdgeOwner) + edges = append(edges, deployment.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *LogicalDiskMutation) AddedIDs(name string) []ent.Value { +func (m *DeploymentMutation) AddedIDs(name string) []ent.Value { switch name { - case logicaldisk.EdgeOwner: + case deployment.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -9422,31 +9785,31 @@ func (m *LogicalDiskMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *LogicalDiskMutation) RemovedEdges() []string { +func (m *DeploymentMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *LogicalDiskMutation) RemovedIDs(name string) []ent.Value { +func (m *DeploymentMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *LogicalDiskMutation) ClearedEdges() []string { +func (m *DeploymentMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, logicaldisk.EdgeOwner) + edges = append(edges, deployment.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *LogicalDiskMutation) EdgeCleared(name string) bool { +func (m *DeploymentMutation) EdgeCleared(name string) bool { switch name { - case logicaldisk.EdgeOwner: + case deployment.EdgeOwner: return m.clearedowner } return false @@ -9454,58 +9817,63 @@ func (m *LogicalDiskMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *LogicalDiskMutation) ClearEdge(name string) error { +func (m *DeploymentMutation) ClearEdge(name string) error { switch name { - case logicaldisk.EdgeOwner: + case deployment.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown LogicalDisk unique edge %s", name) + return fmt.Errorf("unknown Deployment unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *LogicalDiskMutation) ResetEdge(name string) error { +func (m *DeploymentMutation) ResetEdge(name string) error { switch name { - case logicaldisk.EdgeOwner: + case deployment.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown LogicalDisk edge %s", name) + return fmt.Errorf("unknown Deployment edge %s", name) } -// MemorySlotMutation represents an operation that mutates the MemorySlot nodes in the graph. -type MemorySlotMutation struct { +// EnrollmentTokenMutation represents an operation that mutates the EnrollmentToken nodes in the graph. +type EnrollmentTokenMutation struct { config - op Op - typ string - id *int - slot *string - size *string - _type *string - serial_number *string - part_number *string - speed *string - manufacturer *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*MemorySlot, error) - predicates []predicate.MemorySlot + op Op + typ string + id *int + token *string + description *string + max_uses *int + addmax_uses *int + current_uses *int + addcurrent_uses *int + expires_at *time.Time + active *bool + created *time.Time + modified *time.Time + clearedFields map[string]struct{} + tenant *int + clearedtenant bool + site *int + clearedsite bool + done bool + oldValue func(context.Context) (*EnrollmentToken, error) + predicates []predicate.EnrollmentToken } -var _ ent.Mutation = (*MemorySlotMutation)(nil) +var _ ent.Mutation = (*EnrollmentTokenMutation)(nil) -// memoryslotOption allows management of the mutation configuration using functional options. -type memoryslotOption func(*MemorySlotMutation) +// enrollmenttokenOption allows management of the mutation configuration using functional options. +type enrollmenttokenOption func(*EnrollmentTokenMutation) -// newMemorySlotMutation creates new mutation for the MemorySlot entity. -func newMemorySlotMutation(c config, op Op, opts ...memoryslotOption) *MemorySlotMutation { - m := &MemorySlotMutation{ +// newEnrollmentTokenMutation creates new mutation for the EnrollmentToken entity. +func newEnrollmentTokenMutation(c config, op Op, opts ...enrollmenttokenOption) *EnrollmentTokenMutation { + m := &EnrollmentTokenMutation{ config: c, op: op, - typ: TypeMemorySlot, + typ: TypeEnrollmentToken, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -9514,20 +9882,20 @@ func newMemorySlotMutation(c config, op Op, opts ...memoryslotOption) *MemorySlo return m } -// withMemorySlotID sets the ID field of the mutation. -func withMemorySlotID(id int) memoryslotOption { - return func(m *MemorySlotMutation) { +// withEnrollmentTokenID sets the ID field of the mutation. +func withEnrollmentTokenID(id int) enrollmenttokenOption { + return func(m *EnrollmentTokenMutation) { var ( err error once sync.Once - value *MemorySlot + value *EnrollmentToken ) - m.oldValue = func(ctx context.Context) (*MemorySlot, error) { + m.oldValue = func(ctx context.Context) (*EnrollmentToken, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().MemorySlot.Get(ctx, id) + value, err = m.Client().EnrollmentToken.Get(ctx, id) } }) return value, err @@ -9536,10 +9904,10 @@ func withMemorySlotID(id int) memoryslotOption { } } -// withMemorySlot sets the old MemorySlot of the mutation. -func withMemorySlot(node *MemorySlot) memoryslotOption { - return func(m *MemorySlotMutation) { - m.oldValue = func(context.Context) (*MemorySlot, error) { +// withEnrollmentToken sets the old EnrollmentToken of the mutation. +func withEnrollmentToken(node *EnrollmentToken) enrollmenttokenOption { + return func(m *EnrollmentTokenMutation) { + m.oldValue = func(context.Context) (*EnrollmentToken, error) { return node, nil } m.id = &node.ID @@ -9548,7 +9916,7 @@ func withMemorySlot(node *MemorySlot) memoryslotOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m MemorySlotMutation) Client() *Client { +func (m EnrollmentTokenMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -9556,7 +9924,7 @@ func (m MemorySlotMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m MemorySlotMutation) Tx() (*Tx, error) { +func (m EnrollmentTokenMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -9567,7 +9935,7 @@ func (m MemorySlotMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *MemorySlotMutation) ID() (id int, exists bool) { +func (m *EnrollmentTokenMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -9578,7 +9946,7 @@ func (m *MemorySlotMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *MemorySlotMutation) IDs(ctx context.Context) ([]int, error) { +func (m *EnrollmentTokenMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -9587,403 +9955,479 @@ func (m *MemorySlotMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().MemorySlot.Query().Where(m.predicates...).IDs(ctx) + return m.Client().EnrollmentToken.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetSlot sets the "slot" field. -func (m *MemorySlotMutation) SetSlot(s string) { - m.slot = &s +// SetToken sets the "token" field. +func (m *EnrollmentTokenMutation) SetToken(s string) { + m.token = &s } -// Slot returns the value of the "slot" field in the mutation. -func (m *MemorySlotMutation) Slot() (r string, exists bool) { - v := m.slot +// Token returns the value of the "token" field in the mutation. +func (m *EnrollmentTokenMutation) Token() (r string, exists bool) { + v := m.token if v == nil { return } return *v, true } -// OldSlot returns the old "slot" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldToken returns the old "token" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldSlot(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSlot is only allowed on UpdateOne operations") + return v, errors.New("OldToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSlot requires an ID field in the mutation") + return v, errors.New("OldToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSlot: %w", err) + return v, fmt.Errorf("querying old value for OldToken: %w", err) } - return oldValue.Slot, nil -} - -// ClearSlot clears the value of the "slot" field. -func (m *MemorySlotMutation) ClearSlot() { - m.slot = nil - m.clearedFields[memoryslot.FieldSlot] = struct{}{} -} - -// SlotCleared returns if the "slot" field was cleared in this mutation. -func (m *MemorySlotMutation) SlotCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldSlot] - return ok + return oldValue.Token, nil } -// ResetSlot resets all changes to the "slot" field. -func (m *MemorySlotMutation) ResetSlot() { - m.slot = nil - delete(m.clearedFields, memoryslot.FieldSlot) +// ResetToken resets all changes to the "token" field. +func (m *EnrollmentTokenMutation) ResetToken() { + m.token = nil } -// SetSize sets the "size" field. -func (m *MemorySlotMutation) SetSize(s string) { - m.size = &s +// SetDescription sets the "description" field. +func (m *EnrollmentTokenMutation) SetDescription(s string) { + m.description = &s } -// Size returns the value of the "size" field in the mutation. -func (m *MemorySlotMutation) Size() (r string, exists bool) { - v := m.size +// Description returns the value of the "description" field in the mutation. +func (m *EnrollmentTokenMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldSize returns the old "size" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldSize(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSize is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSize requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSize: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.Size, nil + return oldValue.Description, nil } -// ClearSize clears the value of the "size" field. -func (m *MemorySlotMutation) ClearSize() { - m.size = nil - m.clearedFields[memoryslot.FieldSize] = struct{}{} +// ClearDescription clears the value of the "description" field. +func (m *EnrollmentTokenMutation) ClearDescription() { + m.description = nil + m.clearedFields[enrollmenttoken.FieldDescription] = struct{}{} } -// SizeCleared returns if the "size" field was cleared in this mutation. -func (m *MemorySlotMutation) SizeCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldSize] +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *EnrollmentTokenMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[enrollmenttoken.FieldDescription] return ok } -// ResetSize resets all changes to the "size" field. -func (m *MemorySlotMutation) ResetSize() { - m.size = nil - delete(m.clearedFields, memoryslot.FieldSize) +// ResetDescription resets all changes to the "description" field. +func (m *EnrollmentTokenMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, enrollmenttoken.FieldDescription) } -// SetType sets the "type" field. -func (m *MemorySlotMutation) SetType(s string) { - m._type = &s +// SetMaxUses sets the "max_uses" field. +func (m *EnrollmentTokenMutation) SetMaxUses(i int) { + m.max_uses = &i + m.addmax_uses = nil } -// GetType returns the value of the "type" field in the mutation. -func (m *MemorySlotMutation) GetType() (r string, exists bool) { - v := m._type +// MaxUses returns the value of the "max_uses" field in the mutation. +func (m *EnrollmentTokenMutation) MaxUses() (r int, exists bool) { + v := m.max_uses if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldMaxUses returns the old "max_uses" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldType(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldMaxUses(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldMaxUses is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldMaxUses requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldMaxUses: %w", err) } - return oldValue.Type, nil + return oldValue.MaxUses, nil } -// ClearType clears the value of the "type" field. -func (m *MemorySlotMutation) ClearType() { - m._type = nil - m.clearedFields[memoryslot.FieldType] = struct{}{} +// AddMaxUses adds i to the "max_uses" field. +func (m *EnrollmentTokenMutation) AddMaxUses(i int) { + if m.addmax_uses != nil { + *m.addmax_uses += i + } else { + m.addmax_uses = &i + } } -// TypeCleared returns if the "type" field was cleared in this mutation. -func (m *MemorySlotMutation) TypeCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldType] - return ok +// AddedMaxUses returns the value that was added to the "max_uses" field in this mutation. +func (m *EnrollmentTokenMutation) AddedMaxUses() (r int, exists bool) { + v := m.addmax_uses + if v == nil { + return + } + return *v, true } -// ResetType resets all changes to the "type" field. -func (m *MemorySlotMutation) ResetType() { - m._type = nil - delete(m.clearedFields, memoryslot.FieldType) +// ResetMaxUses resets all changes to the "max_uses" field. +func (m *EnrollmentTokenMutation) ResetMaxUses() { + m.max_uses = nil + m.addmax_uses = nil } -// SetSerialNumber sets the "serial_number" field. -func (m *MemorySlotMutation) SetSerialNumber(s string) { - m.serial_number = &s +// SetCurrentUses sets the "current_uses" field. +func (m *EnrollmentTokenMutation) SetCurrentUses(i int) { + m.current_uses = &i + m.addcurrent_uses = nil } -// SerialNumber returns the value of the "serial_number" field in the mutation. -func (m *MemorySlotMutation) SerialNumber() (r string, exists bool) { - v := m.serial_number +// CurrentUses returns the value of the "current_uses" field in the mutation. +func (m *EnrollmentTokenMutation) CurrentUses() (r int, exists bool) { + v := m.current_uses if v == nil { return } return *v, true } -// OldSerialNumber returns the old "serial_number" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldCurrentUses returns the old "current_uses" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldSerialNumber(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldCurrentUses(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") + return v, errors.New("OldCurrentUses is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSerialNumber requires an ID field in the mutation") + return v, errors.New("OldCurrentUses requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) + return v, fmt.Errorf("querying old value for OldCurrentUses: %w", err) } - return oldValue.SerialNumber, nil + return oldValue.CurrentUses, nil } -// ClearSerialNumber clears the value of the "serial_number" field. -func (m *MemorySlotMutation) ClearSerialNumber() { - m.serial_number = nil - m.clearedFields[memoryslot.FieldSerialNumber] = struct{}{} +// AddCurrentUses adds i to the "current_uses" field. +func (m *EnrollmentTokenMutation) AddCurrentUses(i int) { + if m.addcurrent_uses != nil { + *m.addcurrent_uses += i + } else { + m.addcurrent_uses = &i + } } -// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. -func (m *MemorySlotMutation) SerialNumberCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldSerialNumber] - return ok +// AddedCurrentUses returns the value that was added to the "current_uses" field in this mutation. +func (m *EnrollmentTokenMutation) AddedCurrentUses() (r int, exists bool) { + v := m.addcurrent_uses + if v == nil { + return + } + return *v, true } -// ResetSerialNumber resets all changes to the "serial_number" field. -func (m *MemorySlotMutation) ResetSerialNumber() { - m.serial_number = nil - delete(m.clearedFields, memoryslot.FieldSerialNumber) +// ResetCurrentUses resets all changes to the "current_uses" field. +func (m *EnrollmentTokenMutation) ResetCurrentUses() { + m.current_uses = nil + m.addcurrent_uses = nil } -// SetPartNumber sets the "part_number" field. -func (m *MemorySlotMutation) SetPartNumber(s string) { - m.part_number = &s +// SetExpiresAt sets the "expires_at" field. +func (m *EnrollmentTokenMutation) SetExpiresAt(t time.Time) { + m.expires_at = &t } -// PartNumber returns the value of the "part_number" field in the mutation. -func (m *MemorySlotMutation) PartNumber() (r string, exists bool) { - v := m.part_number +// ExpiresAt returns the value of the "expires_at" field in the mutation. +func (m *EnrollmentTokenMutation) ExpiresAt() (r time.Time, exists bool) { + v := m.expires_at if v == nil { return } return *v, true } -// OldPartNumber returns the old "part_number" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldExpiresAt returns the old "expires_at" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldPartNumber(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPartNumber is only allowed on UpdateOne operations") + return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPartNumber requires an ID field in the mutation") + return v, errors.New("OldExpiresAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPartNumber: %w", err) + return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err) } - return oldValue.PartNumber, nil + return oldValue.ExpiresAt, nil } -// ClearPartNumber clears the value of the "part_number" field. -func (m *MemorySlotMutation) ClearPartNumber() { - m.part_number = nil - m.clearedFields[memoryslot.FieldPartNumber] = struct{}{} +// ClearExpiresAt clears the value of the "expires_at" field. +func (m *EnrollmentTokenMutation) ClearExpiresAt() { + m.expires_at = nil + m.clearedFields[enrollmenttoken.FieldExpiresAt] = struct{}{} } -// PartNumberCleared returns if the "part_number" field was cleared in this mutation. -func (m *MemorySlotMutation) PartNumberCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldPartNumber] +// ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation. +func (m *EnrollmentTokenMutation) ExpiresAtCleared() bool { + _, ok := m.clearedFields[enrollmenttoken.FieldExpiresAt] return ok } -// ResetPartNumber resets all changes to the "part_number" field. -func (m *MemorySlotMutation) ResetPartNumber() { - m.part_number = nil - delete(m.clearedFields, memoryslot.FieldPartNumber) +// ResetExpiresAt resets all changes to the "expires_at" field. +func (m *EnrollmentTokenMutation) ResetExpiresAt() { + m.expires_at = nil + delete(m.clearedFields, enrollmenttoken.FieldExpiresAt) } -// SetSpeed sets the "speed" field. -func (m *MemorySlotMutation) SetSpeed(s string) { - m.speed = &s +// SetActive sets the "active" field. +func (m *EnrollmentTokenMutation) SetActive(b bool) { + m.active = &b } -// Speed returns the value of the "speed" field in the mutation. -func (m *MemorySlotMutation) Speed() (r string, exists bool) { - v := m.speed +// Active returns the value of the "active" field in the mutation. +func (m *EnrollmentTokenMutation) Active() (r bool, exists bool) { + v := m.active if v == nil { return } return *v, true } -// OldSpeed returns the old "speed" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldActive returns the old "active" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldSpeed(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldActive(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSpeed is only allowed on UpdateOne operations") + return v, errors.New("OldActive is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSpeed requires an ID field in the mutation") + return v, errors.New("OldActive requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSpeed: %w", err) + return v, fmt.Errorf("querying old value for OldActive: %w", err) } - return oldValue.Speed, nil -} - -// ClearSpeed clears the value of the "speed" field. -func (m *MemorySlotMutation) ClearSpeed() { - m.speed = nil - m.clearedFields[memoryslot.FieldSpeed] = struct{}{} -} - -// SpeedCleared returns if the "speed" field was cleared in this mutation. -func (m *MemorySlotMutation) SpeedCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldSpeed] - return ok + return oldValue.Active, nil } -// ResetSpeed resets all changes to the "speed" field. -func (m *MemorySlotMutation) ResetSpeed() { - m.speed = nil - delete(m.clearedFields, memoryslot.FieldSpeed) +// ResetActive resets all changes to the "active" field. +func (m *EnrollmentTokenMutation) ResetActive() { + m.active = nil } -// SetManufacturer sets the "manufacturer" field. -func (m *MemorySlotMutation) SetManufacturer(s string) { - m.manufacturer = &s +// SetCreated sets the "created" field. +func (m *EnrollmentTokenMutation) SetCreated(t time.Time) { + m.created = &t } -// Manufacturer returns the value of the "manufacturer" field in the mutation. -func (m *MemorySlotMutation) Manufacturer() (r string, exists bool) { - v := m.manufacturer +// Created returns the value of the "created" field in the mutation. +func (m *EnrollmentTokenMutation) Created() (r time.Time, exists bool) { + v := m.created if v == nil { return } return *v, true } -// OldManufacturer returns the old "manufacturer" field's value of the MemorySlot entity. -// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// OldCreated returns the old "created" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MemorySlotMutation) OldManufacturer(ctx context.Context) (v string, err error) { +func (m *EnrollmentTokenMutation) OldCreated(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") + return v, errors.New("OldCreated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManufacturer requires an ID field in the mutation") + return v, errors.New("OldCreated requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) + return v, fmt.Errorf("querying old value for OldCreated: %w", err) } - return oldValue.Manufacturer, nil + return oldValue.Created, nil } -// ClearManufacturer clears the value of the "manufacturer" field. -func (m *MemorySlotMutation) ClearManufacturer() { - m.manufacturer = nil - m.clearedFields[memoryslot.FieldManufacturer] = struct{}{} +// ClearCreated clears the value of the "created" field. +func (m *EnrollmentTokenMutation) ClearCreated() { + m.created = nil + m.clearedFields[enrollmenttoken.FieldCreated] = struct{}{} } -// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. -func (m *MemorySlotMutation) ManufacturerCleared() bool { - _, ok := m.clearedFields[memoryslot.FieldManufacturer] +// CreatedCleared returns if the "created" field was cleared in this mutation. +func (m *EnrollmentTokenMutation) CreatedCleared() bool { + _, ok := m.clearedFields[enrollmenttoken.FieldCreated] return ok } -// ResetManufacturer resets all changes to the "manufacturer" field. -func (m *MemorySlotMutation) ResetManufacturer() { - m.manufacturer = nil - delete(m.clearedFields, memoryslot.FieldManufacturer) -} - -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *MemorySlotMutation) SetOwnerID(id string) { - m.owner = &id +// ResetCreated resets all changes to the "created" field. +func (m *EnrollmentTokenMutation) ResetCreated() { + m.created = nil + delete(m.clearedFields, enrollmenttoken.FieldCreated) } -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *MemorySlotMutation) ClearOwner() { - m.clearedowner = true +// SetModified sets the "modified" field. +func (m *EnrollmentTokenMutation) SetModified(t time.Time) { + m.modified = &t } -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *MemorySlotMutation) OwnerCleared() bool { - return m.clearedowner +// Modified returns the value of the "modified" field in the mutation. +func (m *EnrollmentTokenMutation) Modified() (r time.Time, exists bool) { + v := m.modified + if v == nil { + return + } + return *v, true } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *MemorySlotMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true +// OldModified returns the old "modified" field's value of the EnrollmentToken entity. +// If the EnrollmentToken object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *EnrollmentTokenMutation) OldModified(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModified is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModified requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModified: %w", err) + } + return oldValue.Modified, nil +} + +// ClearModified clears the value of the "modified" field. +func (m *EnrollmentTokenMutation) ClearModified() { + m.modified = nil + m.clearedFields[enrollmenttoken.FieldModified] = struct{}{} +} + +// ModifiedCleared returns if the "modified" field was cleared in this mutation. +func (m *EnrollmentTokenMutation) ModifiedCleared() bool { + _, ok := m.clearedFields[enrollmenttoken.FieldModified] + return ok +} + +// ResetModified resets all changes to the "modified" field. +func (m *EnrollmentTokenMutation) ResetModified() { + m.modified = nil + delete(m.clearedFields, enrollmenttoken.FieldModified) +} + +// SetTenantID sets the "tenant" edge to the Tenant entity by id. +func (m *EnrollmentTokenMutation) SetTenantID(id int) { + m.tenant = &id +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *EnrollmentTokenMutation) ClearTenant() { + m.clearedtenant = true +} + +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *EnrollmentTokenMutation) TenantCleared() bool { + return m.clearedtenant +} + +// TenantID returns the "tenant" edge ID in the mutation. +func (m *EnrollmentTokenMutation) TenantID() (id int, exists bool) { + if m.tenant != nil { + return *m.tenant, true } return } -// OwnerIDs returns the "owner" edge IDs in the mutation. +// TenantIDs returns the "tenant" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *MemorySlotMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { +// TenantID instead. It exists only for internal usage by the builders. +func (m *EnrollmentTokenMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { ids = append(ids, *id) } return } -// ResetOwner resets all changes to the "owner" edge. -func (m *MemorySlotMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ResetTenant resets all changes to the "tenant" edge. +func (m *EnrollmentTokenMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false } -// Where appends a list predicates to the MemorySlotMutation builder. -func (m *MemorySlotMutation) Where(ps ...predicate.MemorySlot) { +// SetSiteID sets the "site" edge to the Site entity by id. +func (m *EnrollmentTokenMutation) SetSiteID(id int) { + m.site = &id +} + +// ClearSite clears the "site" edge to the Site entity. +func (m *EnrollmentTokenMutation) ClearSite() { + m.clearedsite = true +} + +// SiteCleared reports if the "site" edge to the Site entity was cleared. +func (m *EnrollmentTokenMutation) SiteCleared() bool { + return m.clearedsite +} + +// SiteID returns the "site" edge ID in the mutation. +func (m *EnrollmentTokenMutation) SiteID() (id int, exists bool) { + if m.site != nil { + return *m.site, true + } + return +} + +// SiteIDs returns the "site" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SiteID instead. It exists only for internal usage by the builders. +func (m *EnrollmentTokenMutation) SiteIDs() (ids []int) { + if id := m.site; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetSite resets all changes to the "site" edge. +func (m *EnrollmentTokenMutation) ResetSite() { + m.site = nil + m.clearedsite = false +} + +// Where appends a list predicates to the EnrollmentTokenMutation builder. +func (m *EnrollmentTokenMutation) Where(ps ...predicate.EnrollmentToken) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the MemorySlotMutation builder. Using this method, +// WhereP appends storage-level predicates to the EnrollmentTokenMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MemorySlotMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.MemorySlot, len(ps)) +func (m *EnrollmentTokenMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.EnrollmentToken, len(ps)) for i := range ps { p[i] = ps[i] } @@ -9991,45 +10435,48 @@ func (m *MemorySlotMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *MemorySlotMutation) Op() Op { +func (m *EnrollmentTokenMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *MemorySlotMutation) SetOp(op Op) { +func (m *EnrollmentTokenMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (MemorySlot). -func (m *MemorySlotMutation) Type() string { +// Type returns the node type of this mutation (EnrollmentToken). +func (m *EnrollmentTokenMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *MemorySlotMutation) Fields() []string { - fields := make([]string, 0, 7) - if m.slot != nil { - fields = append(fields, memoryslot.FieldSlot) +func (m *EnrollmentTokenMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.token != nil { + fields = append(fields, enrollmenttoken.FieldToken) } - if m.size != nil { - fields = append(fields, memoryslot.FieldSize) + if m.description != nil { + fields = append(fields, enrollmenttoken.FieldDescription) } - if m._type != nil { - fields = append(fields, memoryslot.FieldType) + if m.max_uses != nil { + fields = append(fields, enrollmenttoken.FieldMaxUses) } - if m.serial_number != nil { - fields = append(fields, memoryslot.FieldSerialNumber) + if m.current_uses != nil { + fields = append(fields, enrollmenttoken.FieldCurrentUses) } - if m.part_number != nil { - fields = append(fields, memoryslot.FieldPartNumber) + if m.expires_at != nil { + fields = append(fields, enrollmenttoken.FieldExpiresAt) } - if m.speed != nil { - fields = append(fields, memoryslot.FieldSpeed) + if m.active != nil { + fields = append(fields, enrollmenttoken.FieldActive) } - if m.manufacturer != nil { - fields = append(fields, memoryslot.FieldManufacturer) + if m.created != nil { + fields = append(fields, enrollmenttoken.FieldCreated) + } + if m.modified != nil { + fields = append(fields, enrollmenttoken.FieldModified) } return fields } @@ -10037,22 +10484,24 @@ func (m *MemorySlotMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *MemorySlotMutation) Field(name string) (ent.Value, bool) { +func (m *EnrollmentTokenMutation) Field(name string) (ent.Value, bool) { switch name { - case memoryslot.FieldSlot: - return m.Slot() - case memoryslot.FieldSize: - return m.Size() - case memoryslot.FieldType: - return m.GetType() - case memoryslot.FieldSerialNumber: - return m.SerialNumber() - case memoryslot.FieldPartNumber: - return m.PartNumber() - case memoryslot.FieldSpeed: - return m.Speed() - case memoryslot.FieldManufacturer: - return m.Manufacturer() + case enrollmenttoken.FieldToken: + return m.Token() + case enrollmenttoken.FieldDescription: + return m.Description() + case enrollmenttoken.FieldMaxUses: + return m.MaxUses() + case enrollmenttoken.FieldCurrentUses: + return m.CurrentUses() + case enrollmenttoken.FieldExpiresAt: + return m.ExpiresAt() + case enrollmenttoken.FieldActive: + return m.Active() + case enrollmenttoken.FieldCreated: + return m.Created() + case enrollmenttoken.FieldModified: + return m.Modified() } return nil, false } @@ -10060,214 +10509,242 @@ func (m *MemorySlotMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *MemorySlotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *EnrollmentTokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case memoryslot.FieldSlot: - return m.OldSlot(ctx) - case memoryslot.FieldSize: - return m.OldSize(ctx) - case memoryslot.FieldType: - return m.OldType(ctx) - case memoryslot.FieldSerialNumber: - return m.OldSerialNumber(ctx) - case memoryslot.FieldPartNumber: - return m.OldPartNumber(ctx) - case memoryslot.FieldSpeed: - return m.OldSpeed(ctx) - case memoryslot.FieldManufacturer: - return m.OldManufacturer(ctx) + case enrollmenttoken.FieldToken: + return m.OldToken(ctx) + case enrollmenttoken.FieldDescription: + return m.OldDescription(ctx) + case enrollmenttoken.FieldMaxUses: + return m.OldMaxUses(ctx) + case enrollmenttoken.FieldCurrentUses: + return m.OldCurrentUses(ctx) + case enrollmenttoken.FieldExpiresAt: + return m.OldExpiresAt(ctx) + case enrollmenttoken.FieldActive: + return m.OldActive(ctx) + case enrollmenttoken.FieldCreated: + return m.OldCreated(ctx) + case enrollmenttoken.FieldModified: + return m.OldModified(ctx) } - return nil, fmt.Errorf("unknown MemorySlot field %s", name) + return nil, fmt.Errorf("unknown EnrollmentToken field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MemorySlotMutation) SetField(name string, value ent.Value) error { +func (m *EnrollmentTokenMutation) SetField(name string, value ent.Value) error { switch name { - case memoryslot.FieldSlot: + case enrollmenttoken.FieldToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSlot(v) + m.SetToken(v) return nil - case memoryslot.FieldSize: + case enrollmenttoken.FieldDescription: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSize(v) + m.SetDescription(v) return nil - case memoryslot.FieldType: - v, ok := value.(string) + case enrollmenttoken.FieldMaxUses: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetType(v) + m.SetMaxUses(v) return nil - case memoryslot.FieldSerialNumber: - v, ok := value.(string) + case enrollmenttoken.FieldCurrentUses: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSerialNumber(v) + m.SetCurrentUses(v) return nil - case memoryslot.FieldPartNumber: - v, ok := value.(string) + case enrollmenttoken.FieldExpiresAt: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPartNumber(v) + m.SetExpiresAt(v) return nil - case memoryslot.FieldSpeed: - v, ok := value.(string) + case enrollmenttoken.FieldActive: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSpeed(v) + m.SetActive(v) return nil - case memoryslot.FieldManufacturer: - v, ok := value.(string) + case enrollmenttoken.FieldCreated: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetManufacturer(v) + m.SetCreated(v) + return nil + case enrollmenttoken.FieldModified: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModified(v) return nil } - return fmt.Errorf("unknown MemorySlot field %s", name) + return fmt.Errorf("unknown EnrollmentToken field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *MemorySlotMutation) AddedFields() []string { - return nil +func (m *EnrollmentTokenMutation) AddedFields() []string { + var fields []string + if m.addmax_uses != nil { + fields = append(fields, enrollmenttoken.FieldMaxUses) + } + if m.addcurrent_uses != nil { + fields = append(fields, enrollmenttoken.FieldCurrentUses) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *MemorySlotMutation) AddedField(name string) (ent.Value, bool) { +func (m *EnrollmentTokenMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case enrollmenttoken.FieldMaxUses: + return m.AddedMaxUses() + case enrollmenttoken.FieldCurrentUses: + return m.AddedCurrentUses() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MemorySlotMutation) AddField(name string, value ent.Value) error { +func (m *EnrollmentTokenMutation) AddField(name string, value ent.Value) error { switch name { + case enrollmenttoken.FieldMaxUses: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMaxUses(v) + return nil + case enrollmenttoken.FieldCurrentUses: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCurrentUses(v) + return nil } - return fmt.Errorf("unknown MemorySlot numeric field %s", name) + return fmt.Errorf("unknown EnrollmentToken numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *MemorySlotMutation) ClearedFields() []string { +func (m *EnrollmentTokenMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(memoryslot.FieldSlot) { - fields = append(fields, memoryslot.FieldSlot) - } - if m.FieldCleared(memoryslot.FieldSize) { - fields = append(fields, memoryslot.FieldSize) - } - if m.FieldCleared(memoryslot.FieldType) { - fields = append(fields, memoryslot.FieldType) + if m.FieldCleared(enrollmenttoken.FieldDescription) { + fields = append(fields, enrollmenttoken.FieldDescription) } - if m.FieldCleared(memoryslot.FieldSerialNumber) { - fields = append(fields, memoryslot.FieldSerialNumber) - } - if m.FieldCleared(memoryslot.FieldPartNumber) { - fields = append(fields, memoryslot.FieldPartNumber) + if m.FieldCleared(enrollmenttoken.FieldExpiresAt) { + fields = append(fields, enrollmenttoken.FieldExpiresAt) } - if m.FieldCleared(memoryslot.FieldSpeed) { - fields = append(fields, memoryslot.FieldSpeed) + if m.FieldCleared(enrollmenttoken.FieldCreated) { + fields = append(fields, enrollmenttoken.FieldCreated) } - if m.FieldCleared(memoryslot.FieldManufacturer) { - fields = append(fields, memoryslot.FieldManufacturer) + if m.FieldCleared(enrollmenttoken.FieldModified) { + fields = append(fields, enrollmenttoken.FieldModified) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *MemorySlotMutation) FieldCleared(name string) bool { +func (m *EnrollmentTokenMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *MemorySlotMutation) ClearField(name string) error { +func (m *EnrollmentTokenMutation) ClearField(name string) error { switch name { - case memoryslot.FieldSlot: - m.ClearSlot() - return nil - case memoryslot.FieldSize: - m.ClearSize() - return nil - case memoryslot.FieldType: - m.ClearType() - return nil - case memoryslot.FieldSerialNumber: - m.ClearSerialNumber() + case enrollmenttoken.FieldDescription: + m.ClearDescription() return nil - case memoryslot.FieldPartNumber: - m.ClearPartNumber() + case enrollmenttoken.FieldExpiresAt: + m.ClearExpiresAt() return nil - case memoryslot.FieldSpeed: - m.ClearSpeed() + case enrollmenttoken.FieldCreated: + m.ClearCreated() return nil - case memoryslot.FieldManufacturer: - m.ClearManufacturer() + case enrollmenttoken.FieldModified: + m.ClearModified() return nil } - return fmt.Errorf("unknown MemorySlot nullable field %s", name) + return fmt.Errorf("unknown EnrollmentToken nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *MemorySlotMutation) ResetField(name string) error { +func (m *EnrollmentTokenMutation) ResetField(name string) error { switch name { - case memoryslot.FieldSlot: - m.ResetSlot() + case enrollmenttoken.FieldToken: + m.ResetToken() return nil - case memoryslot.FieldSize: - m.ResetSize() + case enrollmenttoken.FieldDescription: + m.ResetDescription() return nil - case memoryslot.FieldType: - m.ResetType() + case enrollmenttoken.FieldMaxUses: + m.ResetMaxUses() return nil - case memoryslot.FieldSerialNumber: - m.ResetSerialNumber() + case enrollmenttoken.FieldCurrentUses: + m.ResetCurrentUses() return nil - case memoryslot.FieldPartNumber: - m.ResetPartNumber() + case enrollmenttoken.FieldExpiresAt: + m.ResetExpiresAt() return nil - case memoryslot.FieldSpeed: - m.ResetSpeed() + case enrollmenttoken.FieldActive: + m.ResetActive() return nil - case memoryslot.FieldManufacturer: - m.ResetManufacturer() + case enrollmenttoken.FieldCreated: + m.ResetCreated() + return nil + case enrollmenttoken.FieldModified: + m.ResetModified() return nil } - return fmt.Errorf("unknown MemorySlot field %s", name) + return fmt.Errorf("unknown EnrollmentToken field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *MemorySlotMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, memoryslot.EdgeOwner) +func (m *EnrollmentTokenMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.tenant != nil { + edges = append(edges, enrollmenttoken.EdgeTenant) + } + if m.site != nil { + edges = append(edges, enrollmenttoken.EdgeSite) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *MemorySlotMutation) AddedIDs(name string) []ent.Value { +func (m *EnrollmentTokenMutation) AddedIDs(name string) []ent.Value { switch name { - case memoryslot.EdgeOwner: - if id := m.owner; id != nil { + case enrollmenttoken.EdgeTenant: + if id := m.tenant; id != nil { + return []ent.Value{*id} + } + case enrollmenttoken.EdgeSite: + if id := m.site; id != nil { return []ent.Value{*id} } } @@ -10275,86 +10752,102 @@ func (m *MemorySlotMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *MemorySlotMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) +func (m *EnrollmentTokenMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *MemorySlotMutation) RemovedIDs(name string) []ent.Value { +func (m *EnrollmentTokenMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *MemorySlotMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, memoryslot.EdgeOwner) +func (m *EnrollmentTokenMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedtenant { + edges = append(edges, enrollmenttoken.EdgeTenant) + } + if m.clearedsite { + edges = append(edges, enrollmenttoken.EdgeSite) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *MemorySlotMutation) EdgeCleared(name string) bool { +func (m *EnrollmentTokenMutation) EdgeCleared(name string) bool { switch name { - case memoryslot.EdgeOwner: - return m.clearedowner + case enrollmenttoken.EdgeTenant: + return m.clearedtenant + case enrollmenttoken.EdgeSite: + return m.clearedsite } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *MemorySlotMutation) ClearEdge(name string) error { +func (m *EnrollmentTokenMutation) ClearEdge(name string) error { switch name { - case memoryslot.EdgeOwner: - m.ClearOwner() + case enrollmenttoken.EdgeTenant: + m.ClearTenant() + return nil + case enrollmenttoken.EdgeSite: + m.ClearSite() return nil } - return fmt.Errorf("unknown MemorySlot unique edge %s", name) + return fmt.Errorf("unknown EnrollmentToken unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *MemorySlotMutation) ResetEdge(name string) error { +func (m *EnrollmentTokenMutation) ResetEdge(name string) error { switch name { - case memoryslot.EdgeOwner: - m.ResetOwner() + case enrollmenttoken.EdgeTenant: + m.ResetTenant() + return nil + case enrollmenttoken.EdgeSite: + m.ResetSite() return nil } - return fmt.Errorf("unknown MemorySlot edge %s", name) + return fmt.Errorf("unknown EnrollmentToken edge %s", name) } -// MetadataMutation represents an operation that mutates the Metadata nodes in the graph. -type MetadataMutation struct { +// LogicalDiskMutation represents an operation that mutates the LogicalDisk nodes in the graph. +type LogicalDiskMutation struct { config - op Op - typ string - id *int - value *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - org *int - clearedorg bool - done bool - oldValue func(context.Context) (*Metadata, error) - predicates []predicate.Metadata + op Op + typ string + id *int + label *string + filesystem *string + usage *int8 + addusage *int8 + size_in_units *string + remaining_space_in_units *string + volume_name *string + bitlocker_status *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*LogicalDisk, error) + predicates []predicate.LogicalDisk } -var _ ent.Mutation = (*MetadataMutation)(nil) +var _ ent.Mutation = (*LogicalDiskMutation)(nil) -// metadataOption allows management of the mutation configuration using functional options. -type metadataOption func(*MetadataMutation) +// logicaldiskOption allows management of the mutation configuration using functional options. +type logicaldiskOption func(*LogicalDiskMutation) -// newMetadataMutation creates new mutation for the Metadata entity. -func newMetadataMutation(c config, op Op, opts ...metadataOption) *MetadataMutation { - m := &MetadataMutation{ +// newLogicalDiskMutation creates new mutation for the LogicalDisk entity. +func newLogicalDiskMutation(c config, op Op, opts ...logicaldiskOption) *LogicalDiskMutation { + m := &LogicalDiskMutation{ config: c, op: op, - typ: TypeMetadata, + typ: TypeLogicalDisk, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -10363,20 +10856,20 @@ func newMetadataMutation(c config, op Op, opts ...metadataOption) *MetadataMutat return m } -// withMetadataID sets the ID field of the mutation. -func withMetadataID(id int) metadataOption { - return func(m *MetadataMutation) { +// withLogicalDiskID sets the ID field of the mutation. +func withLogicalDiskID(id int) logicaldiskOption { + return func(m *LogicalDiskMutation) { var ( err error once sync.Once - value *Metadata + value *LogicalDisk ) - m.oldValue = func(ctx context.Context) (*Metadata, error) { + m.oldValue = func(ctx context.Context) (*LogicalDisk, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Metadata.Get(ctx, id) + value, err = m.Client().LogicalDisk.Get(ctx, id) } }) return value, err @@ -10385,10 +10878,10 @@ func withMetadataID(id int) metadataOption { } } -// withMetadata sets the old Metadata of the mutation. -func withMetadata(node *Metadata) metadataOption { - return func(m *MetadataMutation) { - m.oldValue = func(context.Context) (*Metadata, error) { +// withLogicalDisk sets the old LogicalDisk of the mutation. +func withLogicalDisk(node *LogicalDisk) logicaldiskOption { + return func(m *LogicalDiskMutation) { + m.oldValue = func(context.Context) (*LogicalDisk, error) { return node, nil } m.id = &node.ID @@ -10397,7 +10890,7 @@ func withMetadata(node *Metadata) metadataOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m MetadataMutation) Client() *Client { +func (m LogicalDiskMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -10405,7 +10898,7 @@ func (m MetadataMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m MetadataMutation) Tx() (*Tx, error) { +func (m LogicalDiskMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -10416,7 +10909,7 @@ func (m MetadataMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *MetadataMutation) ID() (id int, exists bool) { +func (m *LogicalDiskMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -10427,7 +10920,7 @@ func (m *MetadataMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *MetadataMutation) IDs(ctx context.Context) ([]int, error) { +func (m *LogicalDiskMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -10436,135 +10929,397 @@ func (m *MetadataMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Metadata.Query().Where(m.predicates...).IDs(ctx) + return m.Client().LogicalDisk.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetValue sets the "value" field. -func (m *MetadataMutation) SetValue(s string) { - m.value = &s +// SetLabel sets the "label" field. +func (m *LogicalDiskMutation) SetLabel(s string) { + m.label = &s } -// Value returns the value of the "value" field in the mutation. -func (m *MetadataMutation) Value() (r string, exists bool) { - v := m.value +// Label returns the value of the "label" field in the mutation. +func (m *LogicalDiskMutation) Label() (r string, exists bool) { + v := m.label if v == nil { return } return *v, true } -// OldValue returns the old "value" field's value of the Metadata entity. -// If the Metadata object wasn't provided to the builder, the object is fetched from the database. +// OldLabel returns the old "label" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MetadataMutation) OldValue(ctx context.Context) (v string, err error) { +func (m *LogicalDiskMutation) OldLabel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldValue is only allowed on UpdateOne operations") + return v, errors.New("OldLabel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldValue requires an ID field in the mutation") + return v, errors.New("OldLabel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldValue: %w", err) + return v, fmt.Errorf("querying old value for OldLabel: %w", err) } - return oldValue.Value, nil -} - -// ResetValue resets all changes to the "value" field. -func (m *MetadataMutation) ResetValue() { - m.value = nil -} - -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *MetadataMutation) SetOwnerID(id string) { - m.owner = &id + return oldValue.Label, nil } -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *MetadataMutation) ClearOwner() { - m.clearedowner = true +// ResetLabel resets all changes to the "label" field. +func (m *LogicalDiskMutation) ResetLabel() { + m.label = nil } -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *MetadataMutation) OwnerCleared() bool { - return m.clearedowner +// SetFilesystem sets the "filesystem" field. +func (m *LogicalDiskMutation) SetFilesystem(s string) { + m.filesystem = &s } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *MetadataMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true +// Filesystem returns the value of the "filesystem" field in the mutation. +func (m *LogicalDiskMutation) Filesystem() (r string, exists bool) { + v := m.filesystem + if v == nil { + return } - return + return *v, true } -// OwnerIDs returns the "owner" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *MetadataMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { - ids = append(ids, *id) +// OldFilesystem returns the old "filesystem" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LogicalDiskMutation) OldFilesystem(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFilesystem is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFilesystem requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFilesystem: %w", err) + } + return oldValue.Filesystem, nil } -// ResetOwner resets all changes to the "owner" edge. -func (m *MetadataMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ClearFilesystem clears the value of the "filesystem" field. +func (m *LogicalDiskMutation) ClearFilesystem() { + m.filesystem = nil + m.clearedFields[logicaldisk.FieldFilesystem] = struct{}{} } -// SetOrgID sets the "org" edge to the OrgMetadata entity by id. -func (m *MetadataMutation) SetOrgID(id int) { - m.org = &id +// FilesystemCleared returns if the "filesystem" field was cleared in this mutation. +func (m *LogicalDiskMutation) FilesystemCleared() bool { + _, ok := m.clearedFields[logicaldisk.FieldFilesystem] + return ok } -// ClearOrg clears the "org" edge to the OrgMetadata entity. -func (m *MetadataMutation) ClearOrg() { - m.clearedorg = true +// ResetFilesystem resets all changes to the "filesystem" field. +func (m *LogicalDiskMutation) ResetFilesystem() { + m.filesystem = nil + delete(m.clearedFields, logicaldisk.FieldFilesystem) } -// OrgCleared reports if the "org" edge to the OrgMetadata entity was cleared. -func (m *MetadataMutation) OrgCleared() bool { - return m.clearedorg +// SetUsage sets the "usage" field. +func (m *LogicalDiskMutation) SetUsage(i int8) { + m.usage = &i + m.addusage = nil } -// OrgID returns the "org" edge ID in the mutation. -func (m *MetadataMutation) OrgID() (id int, exists bool) { - if m.org != nil { - return *m.org, true +// Usage returns the value of the "usage" field in the mutation. +func (m *LogicalDiskMutation) Usage() (r int8, exists bool) { + v := m.usage + if v == nil { + return + } + return *v, true +} + +// OldUsage returns the old "usage" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LogicalDiskMutation) OldUsage(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsage: %w", err) + } + return oldValue.Usage, nil +} + +// AddUsage adds i to the "usage" field. +func (m *LogicalDiskMutation) AddUsage(i int8) { + if m.addusage != nil { + *m.addusage += i + } else { + m.addusage = &i + } +} + +// AddedUsage returns the value that was added to the "usage" field in this mutation. +func (m *LogicalDiskMutation) AddedUsage() (r int8, exists bool) { + v := m.addusage + if v == nil { + return + } + return *v, true +} + +// ResetUsage resets all changes to the "usage" field. +func (m *LogicalDiskMutation) ResetUsage() { + m.usage = nil + m.addusage = nil +} + +// SetSizeInUnits sets the "size_in_units" field. +func (m *LogicalDiskMutation) SetSizeInUnits(s string) { + m.size_in_units = &s +} + +// SizeInUnits returns the value of the "size_in_units" field in the mutation. +func (m *LogicalDiskMutation) SizeInUnits() (r string, exists bool) { + v := m.size_in_units + if v == nil { + return + } + return *v, true +} + +// OldSizeInUnits returns the old "size_in_units" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LogicalDiskMutation) OldSizeInUnits(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSizeInUnits is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSizeInUnits requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSizeInUnits: %w", err) + } + return oldValue.SizeInUnits, nil +} + +// ClearSizeInUnits clears the value of the "size_in_units" field. +func (m *LogicalDiskMutation) ClearSizeInUnits() { + m.size_in_units = nil + m.clearedFields[logicaldisk.FieldSizeInUnits] = struct{}{} +} + +// SizeInUnitsCleared returns if the "size_in_units" field was cleared in this mutation. +func (m *LogicalDiskMutation) SizeInUnitsCleared() bool { + _, ok := m.clearedFields[logicaldisk.FieldSizeInUnits] + return ok +} + +// ResetSizeInUnits resets all changes to the "size_in_units" field. +func (m *LogicalDiskMutation) ResetSizeInUnits() { + m.size_in_units = nil + delete(m.clearedFields, logicaldisk.FieldSizeInUnits) +} + +// SetRemainingSpaceInUnits sets the "remaining_space_in_units" field. +func (m *LogicalDiskMutation) SetRemainingSpaceInUnits(s string) { + m.remaining_space_in_units = &s +} + +// RemainingSpaceInUnits returns the value of the "remaining_space_in_units" field in the mutation. +func (m *LogicalDiskMutation) RemainingSpaceInUnits() (r string, exists bool) { + v := m.remaining_space_in_units + if v == nil { + return + } + return *v, true +} + +// OldRemainingSpaceInUnits returns the old "remaining_space_in_units" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LogicalDiskMutation) OldRemainingSpaceInUnits(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemainingSpaceInUnits is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemainingSpaceInUnits requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemainingSpaceInUnits: %w", err) + } + return oldValue.RemainingSpaceInUnits, nil +} + +// ClearRemainingSpaceInUnits clears the value of the "remaining_space_in_units" field. +func (m *LogicalDiskMutation) ClearRemainingSpaceInUnits() { + m.remaining_space_in_units = nil + m.clearedFields[logicaldisk.FieldRemainingSpaceInUnits] = struct{}{} +} + +// RemainingSpaceInUnitsCleared returns if the "remaining_space_in_units" field was cleared in this mutation. +func (m *LogicalDiskMutation) RemainingSpaceInUnitsCleared() bool { + _, ok := m.clearedFields[logicaldisk.FieldRemainingSpaceInUnits] + return ok +} + +// ResetRemainingSpaceInUnits resets all changes to the "remaining_space_in_units" field. +func (m *LogicalDiskMutation) ResetRemainingSpaceInUnits() { + m.remaining_space_in_units = nil + delete(m.clearedFields, logicaldisk.FieldRemainingSpaceInUnits) +} + +// SetVolumeName sets the "volume_name" field. +func (m *LogicalDiskMutation) SetVolumeName(s string) { + m.volume_name = &s +} + +// VolumeName returns the value of the "volume_name" field in the mutation. +func (m *LogicalDiskMutation) VolumeName() (r string, exists bool) { + v := m.volume_name + if v == nil { + return + } + return *v, true +} + +// OldVolumeName returns the old "volume_name" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LogicalDiskMutation) OldVolumeName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVolumeName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVolumeName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVolumeName: %w", err) + } + return oldValue.VolumeName, nil +} + +// ClearVolumeName clears the value of the "volume_name" field. +func (m *LogicalDiskMutation) ClearVolumeName() { + m.volume_name = nil + m.clearedFields[logicaldisk.FieldVolumeName] = struct{}{} +} + +// VolumeNameCleared returns if the "volume_name" field was cleared in this mutation. +func (m *LogicalDiskMutation) VolumeNameCleared() bool { + _, ok := m.clearedFields[logicaldisk.FieldVolumeName] + return ok +} + +// ResetVolumeName resets all changes to the "volume_name" field. +func (m *LogicalDiskMutation) ResetVolumeName() { + m.volume_name = nil + delete(m.clearedFields, logicaldisk.FieldVolumeName) +} + +// SetBitlockerStatus sets the "bitlocker_status" field. +func (m *LogicalDiskMutation) SetBitlockerStatus(s string) { + m.bitlocker_status = &s +} + +// BitlockerStatus returns the value of the "bitlocker_status" field in the mutation. +func (m *LogicalDiskMutation) BitlockerStatus() (r string, exists bool) { + v := m.bitlocker_status + if v == nil { + return + } + return *v, true +} + +// OldBitlockerStatus returns the old "bitlocker_status" field's value of the LogicalDisk entity. +// If the LogicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LogicalDiskMutation) OldBitlockerStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBitlockerStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBitlockerStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBitlockerStatus: %w", err) + } + return oldValue.BitlockerStatus, nil +} + +// ClearBitlockerStatus clears the value of the "bitlocker_status" field. +func (m *LogicalDiskMutation) ClearBitlockerStatus() { + m.bitlocker_status = nil + m.clearedFields[logicaldisk.FieldBitlockerStatus] = struct{}{} +} + +// BitlockerStatusCleared returns if the "bitlocker_status" field was cleared in this mutation. +func (m *LogicalDiskMutation) BitlockerStatusCleared() bool { + _, ok := m.clearedFields[logicaldisk.FieldBitlockerStatus] + return ok +} + +// ResetBitlockerStatus resets all changes to the "bitlocker_status" field. +func (m *LogicalDiskMutation) ResetBitlockerStatus() { + m.bitlocker_status = nil + delete(m.clearedFields, logicaldisk.FieldBitlockerStatus) +} + +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *LogicalDiskMutation) SetOwnerID(id string) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *LogicalDiskMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *LogicalDiskMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *LogicalDiskMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true } return } -// OrgIDs returns the "org" edge IDs in the mutation. +// OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OrgID instead. It exists only for internal usage by the builders. -func (m *MetadataMutation) OrgIDs() (ids []int) { - if id := m.org; id != nil { +// OwnerID instead. It exists only for internal usage by the builders. +func (m *LogicalDiskMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { ids = append(ids, *id) } return } -// ResetOrg resets all changes to the "org" edge. -func (m *MetadataMutation) ResetOrg() { - m.org = nil - m.clearedorg = false +// ResetOwner resets all changes to the "owner" edge. +func (m *LogicalDiskMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// Where appends a list predicates to the MetadataMutation builder. -func (m *MetadataMutation) Where(ps ...predicate.Metadata) { +// Where appends a list predicates to the LogicalDiskMutation builder. +func (m *LogicalDiskMutation) Where(ps ...predicate.LogicalDisk) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the MetadataMutation builder. Using this method, +// WhereP appends storage-level predicates to the LogicalDiskMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MetadataMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Metadata, len(ps)) +func (m *LogicalDiskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.LogicalDisk, len(ps)) for i := range ps { p[i] = ps[i] } @@ -10572,27 +11327,45 @@ func (m *MetadataMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *MetadataMutation) Op() Op { +func (m *LogicalDiskMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *MetadataMutation) SetOp(op Op) { +func (m *LogicalDiskMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Metadata). -func (m *MetadataMutation) Type() string { +// Type returns the node type of this mutation (LogicalDisk). +func (m *LogicalDiskMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *MetadataMutation) Fields() []string { - fields := make([]string, 0, 1) - if m.value != nil { - fields = append(fields, metadata.FieldValue) +func (m *LogicalDiskMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.label != nil { + fields = append(fields, logicaldisk.FieldLabel) + } + if m.filesystem != nil { + fields = append(fields, logicaldisk.FieldFilesystem) + } + if m.usage != nil { + fields = append(fields, logicaldisk.FieldUsage) + } + if m.size_in_units != nil { + fields = append(fields, logicaldisk.FieldSizeInUnits) + } + if m.remaining_space_in_units != nil { + fields = append(fields, logicaldisk.FieldRemainingSpaceInUnits) + } + if m.volume_name != nil { + fields = append(fields, logicaldisk.FieldVolumeName) + } + if m.bitlocker_status != nil { + fields = append(fields, logicaldisk.FieldBitlockerStatus) } return fields } @@ -10600,10 +11373,22 @@ func (m *MetadataMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *MetadataMutation) Field(name string) (ent.Value, bool) { +func (m *LogicalDiskMutation) Field(name string) (ent.Value, bool) { switch name { - case metadata.FieldValue: - return m.Value() + case logicaldisk.FieldLabel: + return m.Label() + case logicaldisk.FieldFilesystem: + return m.Filesystem() + case logicaldisk.FieldUsage: + return m.Usage() + case logicaldisk.FieldSizeInUnits: + return m.SizeInUnits() + case logicaldisk.FieldRemainingSpaceInUnits: + return m.RemainingSpaceInUnits() + case logicaldisk.FieldVolumeName: + return m.VolumeName() + case logicaldisk.FieldBitlockerStatus: + return m.BitlockerStatus() } return nil, false } @@ -10611,204 +11396,308 @@ func (m *MetadataMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *MetadataMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *LogicalDiskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case metadata.FieldValue: - return m.OldValue(ctx) + case logicaldisk.FieldLabel: + return m.OldLabel(ctx) + case logicaldisk.FieldFilesystem: + return m.OldFilesystem(ctx) + case logicaldisk.FieldUsage: + return m.OldUsage(ctx) + case logicaldisk.FieldSizeInUnits: + return m.OldSizeInUnits(ctx) + case logicaldisk.FieldRemainingSpaceInUnits: + return m.OldRemainingSpaceInUnits(ctx) + case logicaldisk.FieldVolumeName: + return m.OldVolumeName(ctx) + case logicaldisk.FieldBitlockerStatus: + return m.OldBitlockerStatus(ctx) } - return nil, fmt.Errorf("unknown Metadata field %s", name) + return nil, fmt.Errorf("unknown LogicalDisk field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MetadataMutation) SetField(name string, value ent.Value) error { +func (m *LogicalDiskMutation) SetField(name string, value ent.Value) error { switch name { - case metadata.FieldValue: + case logicaldisk.FieldLabel: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetValue(v) + m.SetLabel(v) + return nil + case logicaldisk.FieldFilesystem: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFilesystem(v) + return nil + case logicaldisk.FieldUsage: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsage(v) + return nil + case logicaldisk.FieldSizeInUnits: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSizeInUnits(v) + return nil + case logicaldisk.FieldRemainingSpaceInUnits: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemainingSpaceInUnits(v) + return nil + case logicaldisk.FieldVolumeName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVolumeName(v) + return nil + case logicaldisk.FieldBitlockerStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBitlockerStatus(v) return nil } - return fmt.Errorf("unknown Metadata field %s", name) + return fmt.Errorf("unknown LogicalDisk field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *MetadataMutation) AddedFields() []string { - return nil +func (m *LogicalDiskMutation) AddedFields() []string { + var fields []string + if m.addusage != nil { + fields = append(fields, logicaldisk.FieldUsage) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *MetadataMutation) AddedField(name string) (ent.Value, bool) { +func (m *LogicalDiskMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case logicaldisk.FieldUsage: + return m.AddedUsage() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MetadataMutation) AddField(name string, value ent.Value) error { +func (m *LogicalDiskMutation) AddField(name string, value ent.Value) error { switch name { + case logicaldisk.FieldUsage: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUsage(v) + return nil } - return fmt.Errorf("unknown Metadata numeric field %s", name) + return fmt.Errorf("unknown LogicalDisk numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *MetadataMutation) ClearedFields() []string { - return nil +func (m *LogicalDiskMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(logicaldisk.FieldFilesystem) { + fields = append(fields, logicaldisk.FieldFilesystem) + } + if m.FieldCleared(logicaldisk.FieldSizeInUnits) { + fields = append(fields, logicaldisk.FieldSizeInUnits) + } + if m.FieldCleared(logicaldisk.FieldRemainingSpaceInUnits) { + fields = append(fields, logicaldisk.FieldRemainingSpaceInUnits) + } + if m.FieldCleared(logicaldisk.FieldVolumeName) { + fields = append(fields, logicaldisk.FieldVolumeName) + } + if m.FieldCleared(logicaldisk.FieldBitlockerStatus) { + fields = append(fields, logicaldisk.FieldBitlockerStatus) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *MetadataMutation) FieldCleared(name string) bool { +func (m *LogicalDiskMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *MetadataMutation) ClearField(name string) error { - return fmt.Errorf("unknown Metadata nullable field %s", name) +func (m *LogicalDiskMutation) ClearField(name string) error { + switch name { + case logicaldisk.FieldFilesystem: + m.ClearFilesystem() + return nil + case logicaldisk.FieldSizeInUnits: + m.ClearSizeInUnits() + return nil + case logicaldisk.FieldRemainingSpaceInUnits: + m.ClearRemainingSpaceInUnits() + return nil + case logicaldisk.FieldVolumeName: + m.ClearVolumeName() + return nil + case logicaldisk.FieldBitlockerStatus: + m.ClearBitlockerStatus() + return nil + } + return fmt.Errorf("unknown LogicalDisk nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *MetadataMutation) ResetField(name string) error { +func (m *LogicalDiskMutation) ResetField(name string) error { switch name { - case metadata.FieldValue: - m.ResetValue() + case logicaldisk.FieldLabel: + m.ResetLabel() + return nil + case logicaldisk.FieldFilesystem: + m.ResetFilesystem() + return nil + case logicaldisk.FieldUsage: + m.ResetUsage() + return nil + case logicaldisk.FieldSizeInUnits: + m.ResetSizeInUnits() + return nil + case logicaldisk.FieldRemainingSpaceInUnits: + m.ResetRemainingSpaceInUnits() + return nil + case logicaldisk.FieldVolumeName: + m.ResetVolumeName() + return nil + case logicaldisk.FieldBitlockerStatus: + m.ResetBitlockerStatus() return nil } - return fmt.Errorf("unknown Metadata field %s", name) + return fmt.Errorf("unknown LogicalDisk field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *MetadataMutation) AddedEdges() []string { - edges := make([]string, 0, 2) +func (m *LogicalDiskMutation) AddedEdges() []string { + edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, metadata.EdgeOwner) - } - if m.org != nil { - edges = append(edges, metadata.EdgeOrg) + edges = append(edges, logicaldisk.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *MetadataMutation) AddedIDs(name string) []ent.Value { +func (m *LogicalDiskMutation) AddedIDs(name string) []ent.Value { switch name { - case metadata.EdgeOwner: + case logicaldisk.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } - case metadata.EdgeOrg: - if id := m.org; id != nil { - return []ent.Value{*id} - } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *MetadataMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *LogicalDiskMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *MetadataMutation) RemovedIDs(name string) []ent.Value { +func (m *LogicalDiskMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *MetadataMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) +func (m *LogicalDiskMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, metadata.EdgeOwner) - } - if m.clearedorg { - edges = append(edges, metadata.EdgeOrg) + edges = append(edges, logicaldisk.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *MetadataMutation) EdgeCleared(name string) bool { +func (m *LogicalDiskMutation) EdgeCleared(name string) bool { switch name { - case metadata.EdgeOwner: + case logicaldisk.EdgeOwner: return m.clearedowner - case metadata.EdgeOrg: - return m.clearedorg } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *MetadataMutation) ClearEdge(name string) error { +func (m *LogicalDiskMutation) ClearEdge(name string) error { switch name { - case metadata.EdgeOwner: + case logicaldisk.EdgeOwner: m.ClearOwner() return nil - case metadata.EdgeOrg: - m.ClearOrg() - return nil } - return fmt.Errorf("unknown Metadata unique edge %s", name) + return fmt.Errorf("unknown LogicalDisk unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *MetadataMutation) ResetEdge(name string) error { +func (m *LogicalDiskMutation) ResetEdge(name string) error { switch name { - case metadata.EdgeOwner: + case logicaldisk.EdgeOwner: m.ResetOwner() return nil - case metadata.EdgeOrg: - m.ResetOrg() - return nil } - return fmt.Errorf("unknown Metadata edge %s", name) + return fmt.Errorf("unknown LogicalDisk edge %s", name) } -// MonitorMutation represents an operation that mutates the Monitor nodes in the graph. -type MonitorMutation struct { +// MemorySlotMutation represents an operation that mutates the MemorySlot nodes in the graph. +type MemorySlotMutation struct { config - op Op - typ string - id *int - manufacturer *string - model *string - serial *string - week_of_manufacture *string - year_of_manufacture *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Monitor, error) - predicates []predicate.Monitor + op Op + typ string + id *int + slot *string + size *string + _type *string + serial_number *string + part_number *string + speed *string + manufacturer *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*MemorySlot, error) + predicates []predicate.MemorySlot } -var _ ent.Mutation = (*MonitorMutation)(nil) +var _ ent.Mutation = (*MemorySlotMutation)(nil) -// monitorOption allows management of the mutation configuration using functional options. -type monitorOption func(*MonitorMutation) +// memoryslotOption allows management of the mutation configuration using functional options. +type memoryslotOption func(*MemorySlotMutation) -// newMonitorMutation creates new mutation for the Monitor entity. -func newMonitorMutation(c config, op Op, opts ...monitorOption) *MonitorMutation { - m := &MonitorMutation{ +// newMemorySlotMutation creates new mutation for the MemorySlot entity. +func newMemorySlotMutation(c config, op Op, opts ...memoryslotOption) *MemorySlotMutation { + m := &MemorySlotMutation{ config: c, op: op, - typ: TypeMonitor, + typ: TypeMemorySlot, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -10817,20 +11706,20 @@ func newMonitorMutation(c config, op Op, opts ...monitorOption) *MonitorMutation return m } -// withMonitorID sets the ID field of the mutation. -func withMonitorID(id int) monitorOption { - return func(m *MonitorMutation) { +// withMemorySlotID sets the ID field of the mutation. +func withMemorySlotID(id int) memoryslotOption { + return func(m *MemorySlotMutation) { var ( err error once sync.Once - value *Monitor + value *MemorySlot ) - m.oldValue = func(ctx context.Context) (*Monitor, error) { + m.oldValue = func(ctx context.Context) (*MemorySlot, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Monitor.Get(ctx, id) + value, err = m.Client().MemorySlot.Get(ctx, id) } }) return value, err @@ -10839,10 +11728,10 @@ func withMonitorID(id int) monitorOption { } } -// withMonitor sets the old Monitor of the mutation. -func withMonitor(node *Monitor) monitorOption { - return func(m *MonitorMutation) { - m.oldValue = func(context.Context) (*Monitor, error) { +// withMemorySlot sets the old MemorySlot of the mutation. +func withMemorySlot(node *MemorySlot) memoryslotOption { + return func(m *MemorySlotMutation) { + m.oldValue = func(context.Context) (*MemorySlot, error) { return node, nil } m.id = &node.ID @@ -10851,7 +11740,7 @@ func withMonitor(node *Monitor) monitorOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m MonitorMutation) Client() *Client { +func (m MemorySlotMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -10859,7 +11748,7 @@ func (m MonitorMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m MonitorMutation) Tx() (*Tx, error) { +func (m MemorySlotMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -10870,7 +11759,7 @@ func (m MonitorMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *MonitorMutation) ID() (id int, exists bool) { +func (m *MemorySlotMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -10881,7 +11770,7 @@ func (m *MonitorMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *MonitorMutation) IDs(ctx context.Context) ([]int, error) { +func (m *MemorySlotMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -10890,274 +11779,372 @@ func (m *MonitorMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Monitor.Query().Where(m.predicates...).IDs(ctx) + return m.Client().MemorySlot.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetManufacturer sets the "manufacturer" field. -func (m *MonitorMutation) SetManufacturer(s string) { - m.manufacturer = &s +// SetSlot sets the "slot" field. +func (m *MemorySlotMutation) SetSlot(s string) { + m.slot = &s } -// Manufacturer returns the value of the "manufacturer" field in the mutation. -func (m *MonitorMutation) Manufacturer() (r string, exists bool) { - v := m.manufacturer +// Slot returns the value of the "slot" field in the mutation. +func (m *MemorySlotMutation) Slot() (r string, exists bool) { + v := m.slot if v == nil { return } return *v, true } -// OldManufacturer returns the old "manufacturer" field's value of the Monitor entity. -// If the Monitor object wasn't provided to the builder, the object is fetched from the database. +// OldSlot returns the old "slot" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MonitorMutation) OldManufacturer(ctx context.Context) (v string, err error) { +func (m *MemorySlotMutation) OldSlot(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") + return v, errors.New("OldSlot is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManufacturer requires an ID field in the mutation") + return v, errors.New("OldSlot requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) + return v, fmt.Errorf("querying old value for OldSlot: %w", err) } - return oldValue.Manufacturer, nil + return oldValue.Slot, nil } -// ClearManufacturer clears the value of the "manufacturer" field. -func (m *MonitorMutation) ClearManufacturer() { - m.manufacturer = nil - m.clearedFields[monitor.FieldManufacturer] = struct{}{} +// ClearSlot clears the value of the "slot" field. +func (m *MemorySlotMutation) ClearSlot() { + m.slot = nil + m.clearedFields[memoryslot.FieldSlot] = struct{}{} } -// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. -func (m *MonitorMutation) ManufacturerCleared() bool { - _, ok := m.clearedFields[monitor.FieldManufacturer] +// SlotCleared returns if the "slot" field was cleared in this mutation. +func (m *MemorySlotMutation) SlotCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldSlot] return ok } -// ResetManufacturer resets all changes to the "manufacturer" field. -func (m *MonitorMutation) ResetManufacturer() { - m.manufacturer = nil - delete(m.clearedFields, monitor.FieldManufacturer) +// ResetSlot resets all changes to the "slot" field. +func (m *MemorySlotMutation) ResetSlot() { + m.slot = nil + delete(m.clearedFields, memoryslot.FieldSlot) } -// SetModel sets the "model" field. -func (m *MonitorMutation) SetModel(s string) { - m.model = &s +// SetSize sets the "size" field. +func (m *MemorySlotMutation) SetSize(s string) { + m.size = &s } -// Model returns the value of the "model" field in the mutation. -func (m *MonitorMutation) Model() (r string, exists bool) { - v := m.model +// Size returns the value of the "size" field in the mutation. +func (m *MemorySlotMutation) Size() (r string, exists bool) { + v := m.size if v == nil { return } return *v, true } -// OldModel returns the old "model" field's value of the Monitor entity. -// If the Monitor object wasn't provided to the builder, the object is fetched from the database. +// OldSize returns the old "size" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MonitorMutation) OldModel(ctx context.Context) (v string, err error) { +func (m *MemorySlotMutation) OldSize(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModel is only allowed on UpdateOne operations") + return v, errors.New("OldSize is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModel requires an ID field in the mutation") + return v, errors.New("OldSize requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModel: %w", err) + return v, fmt.Errorf("querying old value for OldSize: %w", err) } - return oldValue.Model, nil + return oldValue.Size, nil } -// ClearModel clears the value of the "model" field. -func (m *MonitorMutation) ClearModel() { - m.model = nil - m.clearedFields[monitor.FieldModel] = struct{}{} +// ClearSize clears the value of the "size" field. +func (m *MemorySlotMutation) ClearSize() { + m.size = nil + m.clearedFields[memoryslot.FieldSize] = struct{}{} } -// ModelCleared returns if the "model" field was cleared in this mutation. -func (m *MonitorMutation) ModelCleared() bool { - _, ok := m.clearedFields[monitor.FieldModel] +// SizeCleared returns if the "size" field was cleared in this mutation. +func (m *MemorySlotMutation) SizeCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldSize] return ok } -// ResetModel resets all changes to the "model" field. -func (m *MonitorMutation) ResetModel() { - m.model = nil - delete(m.clearedFields, monitor.FieldModel) +// ResetSize resets all changes to the "size" field. +func (m *MemorySlotMutation) ResetSize() { + m.size = nil + delete(m.clearedFields, memoryslot.FieldSize) } -// SetSerial sets the "serial" field. -func (m *MonitorMutation) SetSerial(s string) { - m.serial = &s +// SetType sets the "type" field. +func (m *MemorySlotMutation) SetType(s string) { + m._type = &s } -// Serial returns the value of the "serial" field in the mutation. -func (m *MonitorMutation) Serial() (r string, exists bool) { - v := m.serial +// GetType returns the value of the "type" field in the mutation. +func (m *MemorySlotMutation) GetType() (r string, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldSerial returns the old "serial" field's value of the Monitor entity. -// If the Monitor object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MonitorMutation) OldSerial(ctx context.Context) (v string, err error) { +func (m *MemorySlotMutation) OldType(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSerial is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSerial requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSerial: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.Serial, nil + return oldValue.Type, nil } -// ClearSerial clears the value of the "serial" field. -func (m *MonitorMutation) ClearSerial() { - m.serial = nil - m.clearedFields[monitor.FieldSerial] = struct{}{} +// ClearType clears the value of the "type" field. +func (m *MemorySlotMutation) ClearType() { + m._type = nil + m.clearedFields[memoryslot.FieldType] = struct{}{} } -// SerialCleared returns if the "serial" field was cleared in this mutation. -func (m *MonitorMutation) SerialCleared() bool { - _, ok := m.clearedFields[monitor.FieldSerial] +// TypeCleared returns if the "type" field was cleared in this mutation. +func (m *MemorySlotMutation) TypeCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldType] return ok } -// ResetSerial resets all changes to the "serial" field. -func (m *MonitorMutation) ResetSerial() { - m.serial = nil - delete(m.clearedFields, monitor.FieldSerial) +// ResetType resets all changes to the "type" field. +func (m *MemorySlotMutation) ResetType() { + m._type = nil + delete(m.clearedFields, memoryslot.FieldType) } -// SetWeekOfManufacture sets the "week_of_manufacture" field. -func (m *MonitorMutation) SetWeekOfManufacture(s string) { - m.week_of_manufacture = &s +// SetSerialNumber sets the "serial_number" field. +func (m *MemorySlotMutation) SetSerialNumber(s string) { + m.serial_number = &s } -// WeekOfManufacture returns the value of the "week_of_manufacture" field in the mutation. -func (m *MonitorMutation) WeekOfManufacture() (r string, exists bool) { - v := m.week_of_manufacture +// SerialNumber returns the value of the "serial_number" field in the mutation. +func (m *MemorySlotMutation) SerialNumber() (r string, exists bool) { + v := m.serial_number if v == nil { return } return *v, true } -// OldWeekOfManufacture returns the old "week_of_manufacture" field's value of the Monitor entity. -// If the Monitor object wasn't provided to the builder, the object is fetched from the database. +// OldSerialNumber returns the old "serial_number" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MonitorMutation) OldWeekOfManufacture(ctx context.Context) (v string, err error) { +func (m *MemorySlotMutation) OldSerialNumber(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWeekOfManufacture is only allowed on UpdateOne operations") + return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWeekOfManufacture requires an ID field in the mutation") + return v, errors.New("OldSerialNumber requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldWeekOfManufacture: %w", err) + return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) } - return oldValue.WeekOfManufacture, nil + return oldValue.SerialNumber, nil } -// ClearWeekOfManufacture clears the value of the "week_of_manufacture" field. -func (m *MonitorMutation) ClearWeekOfManufacture() { - m.week_of_manufacture = nil - m.clearedFields[monitor.FieldWeekOfManufacture] = struct{}{} +// ClearSerialNumber clears the value of the "serial_number" field. +func (m *MemorySlotMutation) ClearSerialNumber() { + m.serial_number = nil + m.clearedFields[memoryslot.FieldSerialNumber] = struct{}{} } -// WeekOfManufactureCleared returns if the "week_of_manufacture" field was cleared in this mutation. -func (m *MonitorMutation) WeekOfManufactureCleared() bool { - _, ok := m.clearedFields[monitor.FieldWeekOfManufacture] +// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. +func (m *MemorySlotMutation) SerialNumberCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldSerialNumber] return ok } -// ResetWeekOfManufacture resets all changes to the "week_of_manufacture" field. -func (m *MonitorMutation) ResetWeekOfManufacture() { - m.week_of_manufacture = nil - delete(m.clearedFields, monitor.FieldWeekOfManufacture) +// ResetSerialNumber resets all changes to the "serial_number" field. +func (m *MemorySlotMutation) ResetSerialNumber() { + m.serial_number = nil + delete(m.clearedFields, memoryslot.FieldSerialNumber) } -// SetYearOfManufacture sets the "year_of_manufacture" field. -func (m *MonitorMutation) SetYearOfManufacture(s string) { - m.year_of_manufacture = &s +// SetPartNumber sets the "part_number" field. +func (m *MemorySlotMutation) SetPartNumber(s string) { + m.part_number = &s } -// YearOfManufacture returns the value of the "year_of_manufacture" field in the mutation. -func (m *MonitorMutation) YearOfManufacture() (r string, exists bool) { - v := m.year_of_manufacture +// PartNumber returns the value of the "part_number" field in the mutation. +func (m *MemorySlotMutation) PartNumber() (r string, exists bool) { + v := m.part_number if v == nil { return } return *v, true } -// OldYearOfManufacture returns the old "year_of_manufacture" field's value of the Monitor entity. -// If the Monitor object wasn't provided to the builder, the object is fetched from the database. +// OldPartNumber returns the old "part_number" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *MonitorMutation) OldYearOfManufacture(ctx context.Context) (v string, err error) { +func (m *MemorySlotMutation) OldPartNumber(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldYearOfManufacture is only allowed on UpdateOne operations") + return v, errors.New("OldPartNumber is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldYearOfManufacture requires an ID field in the mutation") + return v, errors.New("OldPartNumber requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldYearOfManufacture: %w", err) + return v, fmt.Errorf("querying old value for OldPartNumber: %w", err) } - return oldValue.YearOfManufacture, nil + return oldValue.PartNumber, nil } -// ClearYearOfManufacture clears the value of the "year_of_manufacture" field. -func (m *MonitorMutation) ClearYearOfManufacture() { - m.year_of_manufacture = nil - m.clearedFields[monitor.FieldYearOfManufacture] = struct{}{} +// ClearPartNumber clears the value of the "part_number" field. +func (m *MemorySlotMutation) ClearPartNumber() { + m.part_number = nil + m.clearedFields[memoryslot.FieldPartNumber] = struct{}{} } -// YearOfManufactureCleared returns if the "year_of_manufacture" field was cleared in this mutation. -func (m *MonitorMutation) YearOfManufactureCleared() bool { - _, ok := m.clearedFields[monitor.FieldYearOfManufacture] +// PartNumberCleared returns if the "part_number" field was cleared in this mutation. +func (m *MemorySlotMutation) PartNumberCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldPartNumber] return ok } -// ResetYearOfManufacture resets all changes to the "year_of_manufacture" field. -func (m *MonitorMutation) ResetYearOfManufacture() { - m.year_of_manufacture = nil - delete(m.clearedFields, monitor.FieldYearOfManufacture) +// ResetPartNumber resets all changes to the "part_number" field. +func (m *MemorySlotMutation) ResetPartNumber() { + m.part_number = nil + delete(m.clearedFields, memoryslot.FieldPartNumber) +} + +// SetSpeed sets the "speed" field. +func (m *MemorySlotMutation) SetSpeed(s string) { + m.speed = &s +} + +// Speed returns the value of the "speed" field in the mutation. +func (m *MemorySlotMutation) Speed() (r string, exists bool) { + v := m.speed + if v == nil { + return + } + return *v, true +} + +// OldSpeed returns the old "speed" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MemorySlotMutation) OldSpeed(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSpeed is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSpeed requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSpeed: %w", err) + } + return oldValue.Speed, nil +} + +// ClearSpeed clears the value of the "speed" field. +func (m *MemorySlotMutation) ClearSpeed() { + m.speed = nil + m.clearedFields[memoryslot.FieldSpeed] = struct{}{} +} + +// SpeedCleared returns if the "speed" field was cleared in this mutation. +func (m *MemorySlotMutation) SpeedCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldSpeed] + return ok +} + +// ResetSpeed resets all changes to the "speed" field. +func (m *MemorySlotMutation) ResetSpeed() { + m.speed = nil + delete(m.clearedFields, memoryslot.FieldSpeed) +} + +// SetManufacturer sets the "manufacturer" field. +func (m *MemorySlotMutation) SetManufacturer(s string) { + m.manufacturer = &s +} + +// Manufacturer returns the value of the "manufacturer" field in the mutation. +func (m *MemorySlotMutation) Manufacturer() (r string, exists bool) { + v := m.manufacturer + if v == nil { + return + } + return *v, true +} + +// OldManufacturer returns the old "manufacturer" field's value of the MemorySlot entity. +// If the MemorySlot object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *MemorySlotMutation) OldManufacturer(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldManufacturer requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) + } + return oldValue.Manufacturer, nil +} + +// ClearManufacturer clears the value of the "manufacturer" field. +func (m *MemorySlotMutation) ClearManufacturer() { + m.manufacturer = nil + m.clearedFields[memoryslot.FieldManufacturer] = struct{}{} +} + +// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. +func (m *MemorySlotMutation) ManufacturerCleared() bool { + _, ok := m.clearedFields[memoryslot.FieldManufacturer] + return ok +} + +// ResetManufacturer resets all changes to the "manufacturer" field. +func (m *MemorySlotMutation) ResetManufacturer() { + m.manufacturer = nil + delete(m.clearedFields, memoryslot.FieldManufacturer) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *MonitorMutation) SetOwnerID(id string) { +func (m *MemorySlotMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *MonitorMutation) ClearOwner() { +func (m *MemorySlotMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *MonitorMutation) OwnerCleared() bool { +func (m *MemorySlotMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *MonitorMutation) OwnerID() (id string, exists bool) { +func (m *MemorySlotMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -11167,7 +12154,7 @@ func (m *MonitorMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *MonitorMutation) OwnerIDs() (ids []string) { +func (m *MemorySlotMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -11175,20 +12162,20 @@ func (m *MonitorMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *MonitorMutation) ResetOwner() { +func (m *MemorySlotMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the MonitorMutation builder. -func (m *MonitorMutation) Where(ps ...predicate.Monitor) { +// Where appends a list predicates to the MemorySlotMutation builder. +func (m *MemorySlotMutation) Where(ps ...predicate.MemorySlot) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the MonitorMutation builder. Using this method, +// WhereP appends storage-level predicates to the MemorySlotMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *MonitorMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Monitor, len(ps)) +func (m *MemorySlotMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MemorySlot, len(ps)) for i := range ps { p[i] = ps[i] } @@ -11196,39 +12183,45 @@ func (m *MonitorMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *MonitorMutation) Op() Op { +func (m *MemorySlotMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *MonitorMutation) SetOp(op Op) { +func (m *MemorySlotMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Monitor). -func (m *MonitorMutation) Type() string { +// Type returns the node type of this mutation (MemorySlot). +func (m *MemorySlotMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *MonitorMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.manufacturer != nil { - fields = append(fields, monitor.FieldManufacturer) - } - if m.model != nil { - fields = append(fields, monitor.FieldModel) +func (m *MemorySlotMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.slot != nil { + fields = append(fields, memoryslot.FieldSlot) } - if m.serial != nil { - fields = append(fields, monitor.FieldSerial) + if m.size != nil { + fields = append(fields, memoryslot.FieldSize) } - if m.week_of_manufacture != nil { - fields = append(fields, monitor.FieldWeekOfManufacture) + if m._type != nil { + fields = append(fields, memoryslot.FieldType) } - if m.year_of_manufacture != nil { - fields = append(fields, monitor.FieldYearOfManufacture) + if m.serial_number != nil { + fields = append(fields, memoryslot.FieldSerialNumber) + } + if m.part_number != nil { + fields = append(fields, memoryslot.FieldPartNumber) + } + if m.speed != nil { + fields = append(fields, memoryslot.FieldSpeed) + } + if m.manufacturer != nil { + fields = append(fields, memoryslot.FieldManufacturer) } return fields } @@ -11236,18 +12229,22 @@ func (m *MonitorMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *MonitorMutation) Field(name string) (ent.Value, bool) { +func (m *MemorySlotMutation) Field(name string) (ent.Value, bool) { switch name { - case monitor.FieldManufacturer: + case memoryslot.FieldSlot: + return m.Slot() + case memoryslot.FieldSize: + return m.Size() + case memoryslot.FieldType: + return m.GetType() + case memoryslot.FieldSerialNumber: + return m.SerialNumber() + case memoryslot.FieldPartNumber: + return m.PartNumber() + case memoryslot.FieldSpeed: + return m.Speed() + case memoryslot.FieldManufacturer: return m.Manufacturer() - case monitor.FieldModel: - return m.Model() - case monitor.FieldSerial: - return m.Serial() - case monitor.FieldWeekOfManufacture: - return m.WeekOfManufacture() - case monitor.FieldYearOfManufacture: - return m.YearOfManufacture() } return nil, false } @@ -11255,177 +12252,213 @@ func (m *MonitorMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *MonitorMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *MemorySlotMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case monitor.FieldManufacturer: + case memoryslot.FieldSlot: + return m.OldSlot(ctx) + case memoryslot.FieldSize: + return m.OldSize(ctx) + case memoryslot.FieldType: + return m.OldType(ctx) + case memoryslot.FieldSerialNumber: + return m.OldSerialNumber(ctx) + case memoryslot.FieldPartNumber: + return m.OldPartNumber(ctx) + case memoryslot.FieldSpeed: + return m.OldSpeed(ctx) + case memoryslot.FieldManufacturer: return m.OldManufacturer(ctx) - case monitor.FieldModel: - return m.OldModel(ctx) - case monitor.FieldSerial: - return m.OldSerial(ctx) - case monitor.FieldWeekOfManufacture: - return m.OldWeekOfManufacture(ctx) - case monitor.FieldYearOfManufacture: - return m.OldYearOfManufacture(ctx) } - return nil, fmt.Errorf("unknown Monitor field %s", name) + return nil, fmt.Errorf("unknown MemorySlot field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MonitorMutation) SetField(name string, value ent.Value) error { +func (m *MemorySlotMutation) SetField(name string, value ent.Value) error { switch name { - case monitor.FieldManufacturer: + case memoryslot.FieldSlot: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetManufacturer(v) + m.SetSlot(v) return nil - case monitor.FieldModel: + case memoryslot.FieldSize: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModel(v) + m.SetSize(v) return nil - case monitor.FieldSerial: + case memoryslot.FieldType: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSerial(v) + m.SetType(v) return nil - case monitor.FieldWeekOfManufacture: + case memoryslot.FieldSerialNumber: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetWeekOfManufacture(v) + m.SetSerialNumber(v) return nil - case monitor.FieldYearOfManufacture: + case memoryslot.FieldPartNumber: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetYearOfManufacture(v) + m.SetPartNumber(v) + return nil + case memoryslot.FieldSpeed: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpeed(v) + return nil + case memoryslot.FieldManufacturer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetManufacturer(v) return nil } - return fmt.Errorf("unknown Monitor field %s", name) + return fmt.Errorf("unknown MemorySlot field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *MonitorMutation) AddedFields() []string { +func (m *MemorySlotMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *MonitorMutation) AddedField(name string) (ent.Value, bool) { +func (m *MemorySlotMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *MonitorMutation) AddField(name string, value ent.Value) error { +func (m *MemorySlotMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Monitor numeric field %s", name) + return fmt.Errorf("unknown MemorySlot numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *MonitorMutation) ClearedFields() []string { +func (m *MemorySlotMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(monitor.FieldManufacturer) { - fields = append(fields, monitor.FieldManufacturer) + if m.FieldCleared(memoryslot.FieldSlot) { + fields = append(fields, memoryslot.FieldSlot) } - if m.FieldCleared(monitor.FieldModel) { - fields = append(fields, monitor.FieldModel) + if m.FieldCleared(memoryslot.FieldSize) { + fields = append(fields, memoryslot.FieldSize) } - if m.FieldCleared(monitor.FieldSerial) { - fields = append(fields, monitor.FieldSerial) + if m.FieldCleared(memoryslot.FieldType) { + fields = append(fields, memoryslot.FieldType) } - if m.FieldCleared(monitor.FieldWeekOfManufacture) { - fields = append(fields, monitor.FieldWeekOfManufacture) + if m.FieldCleared(memoryslot.FieldSerialNumber) { + fields = append(fields, memoryslot.FieldSerialNumber) } - if m.FieldCleared(monitor.FieldYearOfManufacture) { - fields = append(fields, monitor.FieldYearOfManufacture) + if m.FieldCleared(memoryslot.FieldPartNumber) { + fields = append(fields, memoryslot.FieldPartNumber) + } + if m.FieldCleared(memoryslot.FieldSpeed) { + fields = append(fields, memoryslot.FieldSpeed) + } + if m.FieldCleared(memoryslot.FieldManufacturer) { + fields = append(fields, memoryslot.FieldManufacturer) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *MonitorMutation) FieldCleared(name string) bool { +func (m *MemorySlotMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *MonitorMutation) ClearField(name string) error { +func (m *MemorySlotMutation) ClearField(name string) error { switch name { - case monitor.FieldManufacturer: - m.ClearManufacturer() + case memoryslot.FieldSlot: + m.ClearSlot() return nil - case monitor.FieldModel: - m.ClearModel() + case memoryslot.FieldSize: + m.ClearSize() return nil - case monitor.FieldSerial: - m.ClearSerial() + case memoryslot.FieldType: + m.ClearType() return nil - case monitor.FieldWeekOfManufacture: - m.ClearWeekOfManufacture() + case memoryslot.FieldSerialNumber: + m.ClearSerialNumber() return nil - case monitor.FieldYearOfManufacture: - m.ClearYearOfManufacture() + case memoryslot.FieldPartNumber: + m.ClearPartNumber() + return nil + case memoryslot.FieldSpeed: + m.ClearSpeed() + return nil + case memoryslot.FieldManufacturer: + m.ClearManufacturer() return nil } - return fmt.Errorf("unknown Monitor nullable field %s", name) + return fmt.Errorf("unknown MemorySlot nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *MonitorMutation) ResetField(name string) error { +func (m *MemorySlotMutation) ResetField(name string) error { switch name { - case monitor.FieldManufacturer: - m.ResetManufacturer() + case memoryslot.FieldSlot: + m.ResetSlot() return nil - case monitor.FieldModel: - m.ResetModel() + case memoryslot.FieldSize: + m.ResetSize() return nil - case monitor.FieldSerial: - m.ResetSerial() + case memoryslot.FieldType: + m.ResetType() return nil - case monitor.FieldWeekOfManufacture: - m.ResetWeekOfManufacture() + case memoryslot.FieldSerialNumber: + m.ResetSerialNumber() return nil - case monitor.FieldYearOfManufacture: - m.ResetYearOfManufacture() + case memoryslot.FieldPartNumber: + m.ResetPartNumber() + return nil + case memoryslot.FieldSpeed: + m.ResetSpeed() + return nil + case memoryslot.FieldManufacturer: + m.ResetManufacturer() return nil } - return fmt.Errorf("unknown Monitor field %s", name) + return fmt.Errorf("unknown MemorySlot field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *MonitorMutation) AddedEdges() []string { +func (m *MemorySlotMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, monitor.EdgeOwner) + edges = append(edges, memoryslot.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *MonitorMutation) AddedIDs(name string) []ent.Value { +func (m *MemorySlotMutation) AddedIDs(name string) []ent.Value { switch name { - case monitor.EdgeOwner: + case memoryslot.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -11434,31 +12467,31 @@ func (m *MonitorMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *MonitorMutation) RemovedEdges() []string { +func (m *MemorySlotMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *MonitorMutation) RemovedIDs(name string) []ent.Value { +func (m *MemorySlotMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *MonitorMutation) ClearedEdges() []string { +func (m *MemorySlotMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, monitor.EdgeOwner) + edges = append(edges, memoryslot.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *MonitorMutation) EdgeCleared(name string) bool { +func (m *MemorySlotMutation) EdgeCleared(name string) bool { switch name { - case monitor.EdgeOwner: + case memoryslot.EdgeOwner: return m.clearedowner } return false @@ -11466,67 +12499,54 @@ func (m *MonitorMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *MonitorMutation) ClearEdge(name string) error { +func (m *MemorySlotMutation) ClearEdge(name string) error { switch name { - case monitor.EdgeOwner: + case memoryslot.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown Monitor unique edge %s", name) + return fmt.Errorf("unknown MemorySlot unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *MonitorMutation) ResetEdge(name string) error { +func (m *MemorySlotMutation) ResetEdge(name string) error { switch name { - case monitor.EdgeOwner: + case memoryslot.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown Monitor edge %s", name) + return fmt.Errorf("unknown MemorySlot edge %s", name) } -// NetbirdMutation represents an operation that mutates the Netbird nodes in the graph. -type NetbirdMutation struct { +// MetadataMutation represents an operation that mutates the Metadata nodes in the graph. +type MetadataMutation struct { config - op Op - typ string - id *int - version *string - installed *bool - service_status *string - ip *string - profile *string - management_url *string - management_connected *bool - signal_url *string - signal_connected *bool - ssh_enabled *bool - peers_total *int - addpeers_total *int - peers_connected *int - addpeers_connected *int - profiles_available *string - dns_server *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Netbird, error) - predicates []predicate.Netbird + op Op + typ string + id *int + value *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + org *int + clearedorg bool + done bool + oldValue func(context.Context) (*Metadata, error) + predicates []predicate.Metadata } -var _ ent.Mutation = (*NetbirdMutation)(nil) +var _ ent.Mutation = (*MetadataMutation)(nil) -// netbirdOption allows management of the mutation configuration using functional options. -type netbirdOption func(*NetbirdMutation) +// metadataOption allows management of the mutation configuration using functional options. +type metadataOption func(*MetadataMutation) -// newNetbirdMutation creates new mutation for the Netbird entity. -func newNetbirdMutation(c config, op Op, opts ...netbirdOption) *NetbirdMutation { - m := &NetbirdMutation{ +// newMetadataMutation creates new mutation for the Metadata entity. +func newMetadataMutation(c config, op Op, opts ...metadataOption) *MetadataMutation { + m := &MetadataMutation{ config: c, op: op, - typ: TypeNetbird, + typ: TypeMetadata, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -11535,20 +12555,20 @@ func newNetbirdMutation(c config, op Op, opts ...netbirdOption) *NetbirdMutation return m } -// withNetbirdID sets the ID field of the mutation. -func withNetbirdID(id int) netbirdOption { - return func(m *NetbirdMutation) { +// withMetadataID sets the ID field of the mutation. +func withMetadataID(id int) metadataOption { + return func(m *MetadataMutation) { var ( err error once sync.Once - value *Netbird + value *Metadata ) - m.oldValue = func(ctx context.Context) (*Netbird, error) { + m.oldValue = func(ctx context.Context) (*Metadata, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Netbird.Get(ctx, id) + value, err = m.Client().Metadata.Get(ctx, id) } }) return value, err @@ -11557,10 +12577,10 @@ func withNetbirdID(id int) netbirdOption { } } -// withNetbird sets the old Netbird of the mutation. -func withNetbird(node *Netbird) netbirdOption { - return func(m *NetbirdMutation) { - m.oldValue = func(context.Context) (*Netbird, error) { +// withMetadata sets the old Metadata of the mutation. +func withMetadata(node *Metadata) metadataOption { + return func(m *MetadataMutation) { + m.oldValue = func(context.Context) (*Metadata, error) { return node, nil } m.id = &node.ID @@ -11569,7 +12589,7 @@ func withNetbird(node *Netbird) netbirdOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m NetbirdMutation) Client() *Client { +func (m MetadataMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -11577,7 +12597,7 @@ func (m NetbirdMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m NetbirdMutation) Tx() (*Tx, error) { +func (m MetadataMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -11588,7 +12608,7 @@ func (m NetbirdMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *NetbirdMutation) ID() (id int, exists bool) { +func (m *MetadataMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -11599,7 +12619,7 @@ func (m *NetbirdMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *NetbirdMutation) IDs(ctx context.Context) ([]int, error) { +func (m *MetadataMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -11608,679 +12628,728 @@ func (m *NetbirdMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Netbird.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Metadata.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetVersion sets the "version" field. -func (m *NetbirdMutation) SetVersion(s string) { - m.version = &s +// SetValue sets the "value" field. +func (m *MetadataMutation) SetValue(s string) { + m.value = &s } -// Version returns the value of the "version" field in the mutation. -func (m *NetbirdMutation) Version() (r string, exists bool) { - v := m.version +// Value returns the value of the "value" field in the mutation. +func (m *MetadataMutation) Value() (r string, exists bool) { + v := m.value if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// OldValue returns the old "value" field's value of the Metadata entity. +// If the Metadata object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldVersion(ctx context.Context) (v string, err error) { +func (m *MetadataMutation) OldValue(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldValue is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldValue requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) + return v, fmt.Errorf("querying old value for OldValue: %w", err) } - return oldValue.Version, nil + return oldValue.Value, nil } -// ResetVersion resets all changes to the "version" field. -func (m *NetbirdMutation) ResetVersion() { - m.version = nil +// ResetValue resets all changes to the "value" field. +func (m *MetadataMutation) ResetValue() { + m.value = nil } -// SetInstalled sets the "installed" field. -func (m *NetbirdMutation) SetInstalled(b bool) { - m.installed = &b +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *MetadataMutation) SetOwnerID(id string) { + m.owner = &id } -// Installed returns the value of the "installed" field in the mutation. -func (m *NetbirdMutation) Installed() (r bool, exists bool) { - v := m.installed - if v == nil { - return - } - return *v, true +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *MetadataMutation) ClearOwner() { + m.clearedowner = true } -// OldInstalled returns the old "installed" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldInstalled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInstalled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInstalled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInstalled: %w", err) - } - return oldValue.Installed, nil +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *MetadataMutation) OwnerCleared() bool { + return m.clearedowner } -// ResetInstalled resets all changes to the "installed" field. -func (m *NetbirdMutation) ResetInstalled() { - m.installed = nil +// OwnerID returns the "owner" edge ID in the mutation. +func (m *MetadataMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true + } + return } -// SetServiceStatus sets the "service_status" field. -func (m *NetbirdMutation) SetServiceStatus(s string) { - m.service_status = &s +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *MetadataMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return } -// ServiceStatus returns the value of the "service_status" field in the mutation. -func (m *NetbirdMutation) ServiceStatus() (r string, exists bool) { - v := m.service_status - if v == nil { - return - } - return *v, true +// ResetOwner resets all changes to the "owner" edge. +func (m *MetadataMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// OldServiceStatus returns the old "service_status" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldServiceStatus(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldServiceStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldServiceStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldServiceStatus: %w", err) - } - return oldValue.ServiceStatus, nil +// SetOrgID sets the "org" edge to the OrgMetadata entity by id. +func (m *MetadataMutation) SetOrgID(id int) { + m.org = &id } -// ResetServiceStatus resets all changes to the "service_status" field. -func (m *NetbirdMutation) ResetServiceStatus() { - m.service_status = nil +// ClearOrg clears the "org" edge to the OrgMetadata entity. +func (m *MetadataMutation) ClearOrg() { + m.clearedorg = true } -// SetIP sets the "ip" field. -func (m *NetbirdMutation) SetIP(s string) { - m.ip = &s +// OrgCleared reports if the "org" edge to the OrgMetadata entity was cleared. +func (m *MetadataMutation) OrgCleared() bool { + return m.clearedorg } -// IP returns the value of the "ip" field in the mutation. -func (m *NetbirdMutation) IP() (r string, exists bool) { - v := m.ip - if v == nil { - return +// OrgID returns the "org" edge ID in the mutation. +func (m *MetadataMutation) OrgID() (id int, exists bool) { + if m.org != nil { + return *m.org, true } - return *v, true + return } -// OldIP returns the old "ip" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldIP(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIP is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIP requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIP: %w", err) +// OrgIDs returns the "org" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OrgID instead. It exists only for internal usage by the builders. +func (m *MetadataMutation) OrgIDs() (ids []int) { + if id := m.org; id != nil { + ids = append(ids, *id) } - return oldValue.IP, nil + return } -// ClearIP clears the value of the "ip" field. -func (m *NetbirdMutation) ClearIP() { - m.ip = nil - m.clearedFields[netbird.FieldIP] = struct{}{} +// ResetOrg resets all changes to the "org" edge. +func (m *MetadataMutation) ResetOrg() { + m.org = nil + m.clearedorg = false } -// IPCleared returns if the "ip" field was cleared in this mutation. -func (m *NetbirdMutation) IPCleared() bool { - _, ok := m.clearedFields[netbird.FieldIP] - return ok +// Where appends a list predicates to the MetadataMutation builder. +func (m *MetadataMutation) Where(ps ...predicate.Metadata) { + m.predicates = append(m.predicates, ps...) } -// ResetIP resets all changes to the "ip" field. -func (m *NetbirdMutation) ResetIP() { - m.ip = nil - delete(m.clearedFields, netbird.FieldIP) +// WhereP appends storage-level predicates to the MetadataMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MetadataMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Metadata, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// SetProfile sets the "profile" field. -func (m *NetbirdMutation) SetProfile(s string) { - m.profile = &s +// Op returns the operation name. +func (m *MetadataMutation) Op() Op { + return m.op } -// Profile returns the value of the "profile" field in the mutation. -func (m *NetbirdMutation) Profile() (r string, exists bool) { - v := m.profile - if v == nil { - return +// SetOp allows setting the mutation operation. +func (m *MetadataMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Metadata). +func (m *MetadataMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *MetadataMutation) Fields() []string { + fields := make([]string, 0, 1) + if m.value != nil { + fields = append(fields, metadata.FieldValue) } - return *v, true + return fields } -// OldProfile returns the old "profile" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldProfile(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProfile is only allowed on UpdateOne operations") +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *MetadataMutation) Field(name string) (ent.Value, bool) { + switch name { + case metadata.FieldValue: + return m.Value() } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProfile requires an ID field in the mutation") + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *MetadataMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case metadata.FieldValue: + return m.OldValue(ctx) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldProfile: %w", err) + return nil, fmt.Errorf("unknown Metadata field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MetadataMutation) SetField(name string, value ent.Value) error { + switch name { + case metadata.FieldValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetValue(v) + return nil } - return oldValue.Profile, nil + return fmt.Errorf("unknown Metadata field %s", name) } -// ClearProfile clears the value of the "profile" field. -func (m *NetbirdMutation) ClearProfile() { - m.profile = nil - m.clearedFields[netbird.FieldProfile] = struct{}{} +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *MetadataMutation) AddedFields() []string { + return nil } -// ProfileCleared returns if the "profile" field was cleared in this mutation. -func (m *NetbirdMutation) ProfileCleared() bool { - _, ok := m.clearedFields[netbird.FieldProfile] - return ok +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *MetadataMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// ResetProfile resets all changes to the "profile" field. -func (m *NetbirdMutation) ResetProfile() { - m.profile = nil - delete(m.clearedFields, netbird.FieldProfile) +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *MetadataMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Metadata numeric field %s", name) } -// SetManagementURL sets the "management_url" field. -func (m *NetbirdMutation) SetManagementURL(s string) { - m.management_url = &s +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *MetadataMutation) ClearedFields() []string { + return nil } -// ManagementURL returns the value of the "management_url" field in the mutation. -func (m *NetbirdMutation) ManagementURL() (r string, exists bool) { - v := m.management_url - if v == nil { - return - } - return *v, true +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *MetadataMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok } -// OldManagementURL returns the old "management_url" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldManagementURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManagementURL is only allowed on UpdateOne operations") +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *MetadataMutation) ClearField(name string) error { + return fmt.Errorf("unknown Metadata nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *MetadataMutation) ResetField(name string) error { + switch name { + case metadata.FieldValue: + m.ResetValue() + return nil } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManagementURL requires an ID field in the mutation") + return fmt.Errorf("unknown Metadata field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *MetadataMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.owner != nil { + edges = append(edges, metadata.EdgeOwner) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManagementURL: %w", err) + if m.org != nil { + edges = append(edges, metadata.EdgeOrg) } - return oldValue.ManagementURL, nil + return edges } -// ClearManagementURL clears the value of the "management_url" field. -func (m *NetbirdMutation) ClearManagementURL() { - m.management_url = nil - m.clearedFields[netbird.FieldManagementURL] = struct{}{} +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *MetadataMutation) AddedIDs(name string) []ent.Value { + switch name { + case metadata.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } + case metadata.EdgeOrg: + if id := m.org; id != nil { + return []ent.Value{*id} + } + } + return nil } -// ManagementURLCleared returns if the "management_url" field was cleared in this mutation. -func (m *NetbirdMutation) ManagementURLCleared() bool { - _, ok := m.clearedFields[netbird.FieldManagementURL] - return ok +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *MetadataMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges } -// ResetManagementURL resets all changes to the "management_url" field. -func (m *NetbirdMutation) ResetManagementURL() { - m.management_url = nil - delete(m.clearedFields, netbird.FieldManagementURL) +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *MetadataMutation) RemovedIDs(name string) []ent.Value { + return nil } -// SetManagementConnected sets the "management_connected" field. -func (m *NetbirdMutation) SetManagementConnected(b bool) { - m.management_connected = &b +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *MetadataMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedowner { + edges = append(edges, metadata.EdgeOwner) + } + if m.clearedorg { + edges = append(edges, metadata.EdgeOrg) + } + return edges } -// ManagementConnected returns the value of the "management_connected" field in the mutation. -func (m *NetbirdMutation) ManagementConnected() (r bool, exists bool) { - v := m.management_connected - if v == nil { - return +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *MetadataMutation) EdgeCleared(name string) bool { + switch name { + case metadata.EdgeOwner: + return m.clearedowner + case metadata.EdgeOrg: + return m.clearedorg } - return *v, true + return false } -// OldManagementConnected returns the old "management_connected" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldManagementConnected(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManagementConnected is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManagementConnected requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManagementConnected: %w", err) +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *MetadataMutation) ClearEdge(name string) error { + switch name { + case metadata.EdgeOwner: + m.ClearOwner() + return nil + case metadata.EdgeOrg: + m.ClearOrg() + return nil } - return oldValue.ManagementConnected, nil + return fmt.Errorf("unknown Metadata unique edge %s", name) } -// ResetManagementConnected resets all changes to the "management_connected" field. -func (m *NetbirdMutation) ResetManagementConnected() { - m.management_connected = nil +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *MetadataMutation) ResetEdge(name string) error { + switch name { + case metadata.EdgeOwner: + m.ResetOwner() + return nil + case metadata.EdgeOrg: + m.ResetOrg() + return nil + } + return fmt.Errorf("unknown Metadata edge %s", name) } -// SetSignalURL sets the "signal_url" field. -func (m *NetbirdMutation) SetSignalURL(s string) { - m.signal_url = &s +// MonitorMutation represents an operation that mutates the Monitor nodes in the graph. +type MonitorMutation struct { + config + op Op + typ string + id *int + manufacturer *string + model *string + serial *string + week_of_manufacture *string + year_of_manufacture *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Monitor, error) + predicates []predicate.Monitor } -// SignalURL returns the value of the "signal_url" field in the mutation. -func (m *NetbirdMutation) SignalURL() (r string, exists bool) { - v := m.signal_url - if v == nil { - return +var _ ent.Mutation = (*MonitorMutation)(nil) + +// monitorOption allows management of the mutation configuration using functional options. +type monitorOption func(*MonitorMutation) + +// newMonitorMutation creates new mutation for the Monitor entity. +func newMonitorMutation(c config, op Op, opts ...monitorOption) *MonitorMutation { + m := &MonitorMutation{ + config: c, + op: op, + typ: TypeMonitor, + clearedFields: make(map[string]struct{}), } - return *v, true + for _, opt := range opts { + opt(m) + } + return m } -// OldSignalURL returns the old "signal_url" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldSignalURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignalURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignalURL requires an ID field in the mutation") +// withMonitorID sets the ID field of the mutation. +func withMonitorID(id int) monitorOption { + return func(m *MonitorMutation) { + var ( + err error + once sync.Once + value *Monitor + ) + m.oldValue = func(ctx context.Context) (*Monitor, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Monitor.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSignalURL: %w", err) +} + +// withMonitor sets the old Monitor of the mutation. +func withMonitor(node *Monitor) monitorOption { + return func(m *MonitorMutation) { + m.oldValue = func(context.Context) (*Monitor, error) { + return node, nil + } + m.id = &node.ID } - return oldValue.SignalURL, nil } -// ClearSignalURL clears the value of the "signal_url" field. -func (m *NetbirdMutation) ClearSignalURL() { - m.signal_url = nil - m.clearedFields[netbird.FieldSignalURL] = struct{}{} +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m MonitorMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// SignalURLCleared returns if the "signal_url" field was cleared in this mutation. -func (m *NetbirdMutation) SignalURLCleared() bool { - _, ok := m.clearedFields[netbird.FieldSignalURL] - return ok +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m MonitorMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetSignalURL resets all changes to the "signal_url" field. -func (m *NetbirdMutation) ResetSignalURL() { - m.signal_url = nil - delete(m.clearedFields, netbird.FieldSignalURL) +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *MonitorMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// SetSignalConnected sets the "signal_connected" field. -func (m *NetbirdMutation) SetSignalConnected(b bool) { - m.signal_connected = &b +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *MonitorMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Monitor.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// SignalConnected returns the value of the "signal_connected" field in the mutation. -func (m *NetbirdMutation) SignalConnected() (r bool, exists bool) { - v := m.signal_connected +// SetManufacturer sets the "manufacturer" field. +func (m *MonitorMutation) SetManufacturer(s string) { + m.manufacturer = &s +} + +// Manufacturer returns the value of the "manufacturer" field in the mutation. +func (m *MonitorMutation) Manufacturer() (r string, exists bool) { + v := m.manufacturer if v == nil { return } return *v, true } -// OldSignalConnected returns the old "signal_connected" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// OldManufacturer returns the old "manufacturer" field's value of the Monitor entity. +// If the Monitor object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldSignalConnected(ctx context.Context) (v bool, err error) { +func (m *MonitorMutation) OldManufacturer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSignalConnected is only allowed on UpdateOne operations") + return v, errors.New("OldManufacturer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSignalConnected requires an ID field in the mutation") + return v, errors.New("OldManufacturer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSignalConnected: %w", err) + return v, fmt.Errorf("querying old value for OldManufacturer: %w", err) } - return oldValue.SignalConnected, nil + return oldValue.Manufacturer, nil } -// ResetSignalConnected resets all changes to the "signal_connected" field. -func (m *NetbirdMutation) ResetSignalConnected() { - m.signal_connected = nil +// ClearManufacturer clears the value of the "manufacturer" field. +func (m *MonitorMutation) ClearManufacturer() { + m.manufacturer = nil + m.clearedFields[monitor.FieldManufacturer] = struct{}{} } -// SetSSHEnabled sets the "ssh_enabled" field. -func (m *NetbirdMutation) SetSSHEnabled(b bool) { - m.ssh_enabled = &b +// ManufacturerCleared returns if the "manufacturer" field was cleared in this mutation. +func (m *MonitorMutation) ManufacturerCleared() bool { + _, ok := m.clearedFields[monitor.FieldManufacturer] + return ok } -// SSHEnabled returns the value of the "ssh_enabled" field in the mutation. -func (m *NetbirdMutation) SSHEnabled() (r bool, exists bool) { - v := m.ssh_enabled +// ResetManufacturer resets all changes to the "manufacturer" field. +func (m *MonitorMutation) ResetManufacturer() { + m.manufacturer = nil + delete(m.clearedFields, monitor.FieldManufacturer) +} + +// SetModel sets the "model" field. +func (m *MonitorMutation) SetModel(s string) { + m.model = &s +} + +// Model returns the value of the "model" field in the mutation. +func (m *MonitorMutation) Model() (r string, exists bool) { + v := m.model if v == nil { return } return *v, true } -// OldSSHEnabled returns the old "ssh_enabled" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// OldModel returns the old "model" field's value of the Monitor entity. +// If the Monitor object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldSSHEnabled(ctx context.Context) (v bool, err error) { +func (m *MonitorMutation) OldModel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSSHEnabled is only allowed on UpdateOne operations") + return v, errors.New("OldModel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSSHEnabled requires an ID field in the mutation") + return v, errors.New("OldModel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSSHEnabled: %w", err) + return v, fmt.Errorf("querying old value for OldModel: %w", err) } - return oldValue.SSHEnabled, nil + return oldValue.Model, nil } -// ResetSSHEnabled resets all changes to the "ssh_enabled" field. -func (m *NetbirdMutation) ResetSSHEnabled() { - m.ssh_enabled = nil +// ClearModel clears the value of the "model" field. +func (m *MonitorMutation) ClearModel() { + m.model = nil + m.clearedFields[monitor.FieldModel] = struct{}{} } -// SetPeersTotal sets the "peers_total" field. -func (m *NetbirdMutation) SetPeersTotal(i int) { - m.peers_total = &i - m.addpeers_total = nil +// ModelCleared returns if the "model" field was cleared in this mutation. +func (m *MonitorMutation) ModelCleared() bool { + _, ok := m.clearedFields[monitor.FieldModel] + return ok } -// PeersTotal returns the value of the "peers_total" field in the mutation. -func (m *NetbirdMutation) PeersTotal() (r int, exists bool) { - v := m.peers_total +// ResetModel resets all changes to the "model" field. +func (m *MonitorMutation) ResetModel() { + m.model = nil + delete(m.clearedFields, monitor.FieldModel) +} + +// SetSerial sets the "serial" field. +func (m *MonitorMutation) SetSerial(s string) { + m.serial = &s +} + +// Serial returns the value of the "serial" field in the mutation. +func (m *MonitorMutation) Serial() (r string, exists bool) { + v := m.serial if v == nil { return } return *v, true } -// OldPeersTotal returns the old "peers_total" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// OldSerial returns the old "serial" field's value of the Monitor entity. +// If the Monitor object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldPeersTotal(ctx context.Context) (v int, err error) { +func (m *MonitorMutation) OldSerial(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPeersTotal is only allowed on UpdateOne operations") + return v, errors.New("OldSerial is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPeersTotal requires an ID field in the mutation") + return v, errors.New("OldSerial requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPeersTotal: %w", err) + return v, fmt.Errorf("querying old value for OldSerial: %w", err) } - return oldValue.PeersTotal, nil + return oldValue.Serial, nil } -// AddPeersTotal adds i to the "peers_total" field. -func (m *NetbirdMutation) AddPeersTotal(i int) { - if m.addpeers_total != nil { - *m.addpeers_total += i - } else { - m.addpeers_total = &i - } -} - -// AddedPeersTotal returns the value that was added to the "peers_total" field in this mutation. -func (m *NetbirdMutation) AddedPeersTotal() (r int, exists bool) { - v := m.addpeers_total - if v == nil { - return - } - return *v, true -} - -// ClearPeersTotal clears the value of the "peers_total" field. -func (m *NetbirdMutation) ClearPeersTotal() { - m.peers_total = nil - m.addpeers_total = nil - m.clearedFields[netbird.FieldPeersTotal] = struct{}{} -} - -// PeersTotalCleared returns if the "peers_total" field was cleared in this mutation. -func (m *NetbirdMutation) PeersTotalCleared() bool { - _, ok := m.clearedFields[netbird.FieldPeersTotal] - return ok -} - -// ResetPeersTotal resets all changes to the "peers_total" field. -func (m *NetbirdMutation) ResetPeersTotal() { - m.peers_total = nil - m.addpeers_total = nil - delete(m.clearedFields, netbird.FieldPeersTotal) -} - -// SetPeersConnected sets the "peers_connected" field. -func (m *NetbirdMutation) SetPeersConnected(i int) { - m.peers_connected = &i - m.addpeers_connected = nil -} - -// PeersConnected returns the value of the "peers_connected" field in the mutation. -func (m *NetbirdMutation) PeersConnected() (r int, exists bool) { - v := m.peers_connected - if v == nil { - return - } - return *v, true -} - -// OldPeersConnected returns the old "peers_connected" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldPeersConnected(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPeersConnected is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPeersConnected requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPeersConnected: %w", err) - } - return oldValue.PeersConnected, nil -} - -// AddPeersConnected adds i to the "peers_connected" field. -func (m *NetbirdMutation) AddPeersConnected(i int) { - if m.addpeers_connected != nil { - *m.addpeers_connected += i - } else { - m.addpeers_connected = &i - } -} - -// AddedPeersConnected returns the value that was added to the "peers_connected" field in this mutation. -func (m *NetbirdMutation) AddedPeersConnected() (r int, exists bool) { - v := m.addpeers_connected - if v == nil { - return - } - return *v, true -} - -// ClearPeersConnected clears the value of the "peers_connected" field. -func (m *NetbirdMutation) ClearPeersConnected() { - m.peers_connected = nil - m.addpeers_connected = nil - m.clearedFields[netbird.FieldPeersConnected] = struct{}{} +// ClearSerial clears the value of the "serial" field. +func (m *MonitorMutation) ClearSerial() { + m.serial = nil + m.clearedFields[monitor.FieldSerial] = struct{}{} } -// PeersConnectedCleared returns if the "peers_connected" field was cleared in this mutation. -func (m *NetbirdMutation) PeersConnectedCleared() bool { - _, ok := m.clearedFields[netbird.FieldPeersConnected] +// SerialCleared returns if the "serial" field was cleared in this mutation. +func (m *MonitorMutation) SerialCleared() bool { + _, ok := m.clearedFields[monitor.FieldSerial] return ok } -// ResetPeersConnected resets all changes to the "peers_connected" field. -func (m *NetbirdMutation) ResetPeersConnected() { - m.peers_connected = nil - m.addpeers_connected = nil - delete(m.clearedFields, netbird.FieldPeersConnected) +// ResetSerial resets all changes to the "serial" field. +func (m *MonitorMutation) ResetSerial() { + m.serial = nil + delete(m.clearedFields, monitor.FieldSerial) } -// SetProfilesAvailable sets the "profiles_available" field. -func (m *NetbirdMutation) SetProfilesAvailable(s string) { - m.profiles_available = &s +// SetWeekOfManufacture sets the "week_of_manufacture" field. +func (m *MonitorMutation) SetWeekOfManufacture(s string) { + m.week_of_manufacture = &s } -// ProfilesAvailable returns the value of the "profiles_available" field in the mutation. -func (m *NetbirdMutation) ProfilesAvailable() (r string, exists bool) { - v := m.profiles_available +// WeekOfManufacture returns the value of the "week_of_manufacture" field in the mutation. +func (m *MonitorMutation) WeekOfManufacture() (r string, exists bool) { + v := m.week_of_manufacture if v == nil { return } return *v, true } -// OldProfilesAvailable returns the old "profiles_available" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// OldWeekOfManufacture returns the old "week_of_manufacture" field's value of the Monitor entity. +// If the Monitor object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldProfilesAvailable(ctx context.Context) (v string, err error) { +func (m *MonitorMutation) OldWeekOfManufacture(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProfilesAvailable is only allowed on UpdateOne operations") + return v, errors.New("OldWeekOfManufacture is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProfilesAvailable requires an ID field in the mutation") + return v, errors.New("OldWeekOfManufacture requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProfilesAvailable: %w", err) + return v, fmt.Errorf("querying old value for OldWeekOfManufacture: %w", err) } - return oldValue.ProfilesAvailable, nil + return oldValue.WeekOfManufacture, nil } -// ClearProfilesAvailable clears the value of the "profiles_available" field. -func (m *NetbirdMutation) ClearProfilesAvailable() { - m.profiles_available = nil - m.clearedFields[netbird.FieldProfilesAvailable] = struct{}{} +// ClearWeekOfManufacture clears the value of the "week_of_manufacture" field. +func (m *MonitorMutation) ClearWeekOfManufacture() { + m.week_of_manufacture = nil + m.clearedFields[monitor.FieldWeekOfManufacture] = struct{}{} } -// ProfilesAvailableCleared returns if the "profiles_available" field was cleared in this mutation. -func (m *NetbirdMutation) ProfilesAvailableCleared() bool { - _, ok := m.clearedFields[netbird.FieldProfilesAvailable] +// WeekOfManufactureCleared returns if the "week_of_manufacture" field was cleared in this mutation. +func (m *MonitorMutation) WeekOfManufactureCleared() bool { + _, ok := m.clearedFields[monitor.FieldWeekOfManufacture] return ok } -// ResetProfilesAvailable resets all changes to the "profiles_available" field. -func (m *NetbirdMutation) ResetProfilesAvailable() { - m.profiles_available = nil - delete(m.clearedFields, netbird.FieldProfilesAvailable) +// ResetWeekOfManufacture resets all changes to the "week_of_manufacture" field. +func (m *MonitorMutation) ResetWeekOfManufacture() { + m.week_of_manufacture = nil + delete(m.clearedFields, monitor.FieldWeekOfManufacture) } -// SetDNSServer sets the "dns_server" field. -func (m *NetbirdMutation) SetDNSServer(s string) { - m.dns_server = &s +// SetYearOfManufacture sets the "year_of_manufacture" field. +func (m *MonitorMutation) SetYearOfManufacture(s string) { + m.year_of_manufacture = &s } -// DNSServer returns the value of the "dns_server" field in the mutation. -func (m *NetbirdMutation) DNSServer() (r string, exists bool) { - v := m.dns_server +// YearOfManufacture returns the value of the "year_of_manufacture" field in the mutation. +func (m *MonitorMutation) YearOfManufacture() (r string, exists bool) { + v := m.year_of_manufacture if v == nil { return } return *v, true } -// OldDNSServer returns the old "dns_server" field's value of the Netbird entity. -// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// OldYearOfManufacture returns the old "year_of_manufacture" field's value of the Monitor entity. +// If the Monitor object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdMutation) OldDNSServer(ctx context.Context) (v string, err error) { +func (m *MonitorMutation) OldYearOfManufacture(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDNSServer is only allowed on UpdateOne operations") + return v, errors.New("OldYearOfManufacture is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDNSServer requires an ID field in the mutation") + return v, errors.New("OldYearOfManufacture requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDNSServer: %w", err) + return v, fmt.Errorf("querying old value for OldYearOfManufacture: %w", err) } - return oldValue.DNSServer, nil + return oldValue.YearOfManufacture, nil } -// ClearDNSServer clears the value of the "dns_server" field. -func (m *NetbirdMutation) ClearDNSServer() { - m.dns_server = nil - m.clearedFields[netbird.FieldDNSServer] = struct{}{} +// ClearYearOfManufacture clears the value of the "year_of_manufacture" field. +func (m *MonitorMutation) ClearYearOfManufacture() { + m.year_of_manufacture = nil + m.clearedFields[monitor.FieldYearOfManufacture] = struct{}{} } -// DNSServerCleared returns if the "dns_server" field was cleared in this mutation. -func (m *NetbirdMutation) DNSServerCleared() bool { - _, ok := m.clearedFields[netbird.FieldDNSServer] +// YearOfManufactureCleared returns if the "year_of_manufacture" field was cleared in this mutation. +func (m *MonitorMutation) YearOfManufactureCleared() bool { + _, ok := m.clearedFields[monitor.FieldYearOfManufacture] return ok } -// ResetDNSServer resets all changes to the "dns_server" field. -func (m *NetbirdMutation) ResetDNSServer() { - m.dns_server = nil - delete(m.clearedFields, netbird.FieldDNSServer) +// ResetYearOfManufacture resets all changes to the "year_of_manufacture" field. +func (m *MonitorMutation) ResetYearOfManufacture() { + m.year_of_manufacture = nil + delete(m.clearedFields, monitor.FieldYearOfManufacture) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *NetbirdMutation) SetOwnerID(id string) { +func (m *MonitorMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *NetbirdMutation) ClearOwner() { +func (m *MonitorMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *NetbirdMutation) OwnerCleared() bool { +func (m *MonitorMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *NetbirdMutation) OwnerID() (id string, exists bool) { +func (m *MonitorMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -12290,7 +13359,7 @@ func (m *NetbirdMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *NetbirdMutation) OwnerIDs() (ids []string) { +func (m *MonitorMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -12298,20 +13367,20 @@ func (m *NetbirdMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *NetbirdMutation) ResetOwner() { +func (m *MonitorMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the NetbirdMutation builder. -func (m *NetbirdMutation) Where(ps ...predicate.Netbird) { +// Where appends a list predicates to the MonitorMutation builder. +func (m *MonitorMutation) Where(ps ...predicate.Monitor) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the NetbirdMutation builder. Using this method, +// WhereP appends storage-level predicates to the MonitorMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *NetbirdMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Netbird, len(ps)) +func (m *MonitorMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Monitor, len(ps)) for i := range ps { p[i] = ps[i] } @@ -12319,66 +13388,39 @@ func (m *NetbirdMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *NetbirdMutation) Op() Op { +func (m *MonitorMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *NetbirdMutation) SetOp(op Op) { +func (m *MonitorMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Netbird). -func (m *NetbirdMutation) Type() string { +// Type returns the node type of this mutation (Monitor). +func (m *MonitorMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *NetbirdMutation) Fields() []string { - fields := make([]string, 0, 14) - if m.version != nil { - fields = append(fields, netbird.FieldVersion) - } - if m.installed != nil { - fields = append(fields, netbird.FieldInstalled) - } - if m.service_status != nil { - fields = append(fields, netbird.FieldServiceStatus) - } - if m.ip != nil { - fields = append(fields, netbird.FieldIP) - } - if m.profile != nil { - fields = append(fields, netbird.FieldProfile) - } - if m.management_url != nil { - fields = append(fields, netbird.FieldManagementURL) - } - if m.management_connected != nil { - fields = append(fields, netbird.FieldManagementConnected) - } - if m.signal_url != nil { - fields = append(fields, netbird.FieldSignalURL) - } - if m.signal_connected != nil { - fields = append(fields, netbird.FieldSignalConnected) - } - if m.ssh_enabled != nil { - fields = append(fields, netbird.FieldSSHEnabled) +func (m *MonitorMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.manufacturer != nil { + fields = append(fields, monitor.FieldManufacturer) } - if m.peers_total != nil { - fields = append(fields, netbird.FieldPeersTotal) + if m.model != nil { + fields = append(fields, monitor.FieldModel) } - if m.peers_connected != nil { - fields = append(fields, netbird.FieldPeersConnected) + if m.serial != nil { + fields = append(fields, monitor.FieldSerial) } - if m.profiles_available != nil { - fields = append(fields, netbird.FieldProfilesAvailable) + if m.week_of_manufacture != nil { + fields = append(fields, monitor.FieldWeekOfManufacture) } - if m.dns_server != nil { - fields = append(fields, netbird.FieldDNSServer) + if m.year_of_manufacture != nil { + fields = append(fields, monitor.FieldYearOfManufacture) } return fields } @@ -12386,36 +13428,18 @@ func (m *NetbirdMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *NetbirdMutation) Field(name string) (ent.Value, bool) { +func (m *MonitorMutation) Field(name string) (ent.Value, bool) { switch name { - case netbird.FieldVersion: - return m.Version() - case netbird.FieldInstalled: - return m.Installed() - case netbird.FieldServiceStatus: - return m.ServiceStatus() - case netbird.FieldIP: - return m.IP() - case netbird.FieldProfile: - return m.Profile() - case netbird.FieldManagementURL: - return m.ManagementURL() - case netbird.FieldManagementConnected: - return m.ManagementConnected() - case netbird.FieldSignalURL: - return m.SignalURL() - case netbird.FieldSignalConnected: - return m.SignalConnected() - case netbird.FieldSSHEnabled: - return m.SSHEnabled() - case netbird.FieldPeersTotal: - return m.PeersTotal() - case netbird.FieldPeersConnected: - return m.PeersConnected() - case netbird.FieldProfilesAvailable: - return m.ProfilesAvailable() - case netbird.FieldDNSServer: - return m.DNSServer() + case monitor.FieldManufacturer: + return m.Manufacturer() + case monitor.FieldModel: + return m.Model() + case monitor.FieldSerial: + return m.Serial() + case monitor.FieldWeekOfManufacture: + return m.WeekOfManufacture() + case monitor.FieldYearOfManufacture: + return m.YearOfManufacture() } return nil, false } @@ -12423,330 +13447,177 @@ func (m *NetbirdMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *NetbirdMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *MonitorMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case netbird.FieldVersion: - return m.OldVersion(ctx) - case netbird.FieldInstalled: - return m.OldInstalled(ctx) - case netbird.FieldServiceStatus: - return m.OldServiceStatus(ctx) - case netbird.FieldIP: - return m.OldIP(ctx) - case netbird.FieldProfile: - return m.OldProfile(ctx) - case netbird.FieldManagementURL: - return m.OldManagementURL(ctx) - case netbird.FieldManagementConnected: - return m.OldManagementConnected(ctx) - case netbird.FieldSignalURL: - return m.OldSignalURL(ctx) - case netbird.FieldSignalConnected: - return m.OldSignalConnected(ctx) - case netbird.FieldSSHEnabled: - return m.OldSSHEnabled(ctx) - case netbird.FieldPeersTotal: - return m.OldPeersTotal(ctx) - case netbird.FieldPeersConnected: - return m.OldPeersConnected(ctx) - case netbird.FieldProfilesAvailable: - return m.OldProfilesAvailable(ctx) - case netbird.FieldDNSServer: - return m.OldDNSServer(ctx) + case monitor.FieldManufacturer: + return m.OldManufacturer(ctx) + case monitor.FieldModel: + return m.OldModel(ctx) + case monitor.FieldSerial: + return m.OldSerial(ctx) + case monitor.FieldWeekOfManufacture: + return m.OldWeekOfManufacture(ctx) + case monitor.FieldYearOfManufacture: + return m.OldYearOfManufacture(ctx) } - return nil, fmt.Errorf("unknown Netbird field %s", name) + return nil, fmt.Errorf("unknown Monitor field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NetbirdMutation) SetField(name string, value ent.Value) error { +func (m *MonitorMutation) SetField(name string, value ent.Value) error { switch name { - case netbird.FieldVersion: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVersion(v) - return nil - case netbird.FieldInstalled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInstalled(v) - return nil - case netbird.FieldServiceStatus: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetServiceStatus(v) - return nil - case netbird.FieldIP: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIP(v) - return nil - case netbird.FieldProfile: + case monitor.FieldManufacturer: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProfile(v) + m.SetManufacturer(v) return nil - case netbird.FieldManagementURL: + case monitor.FieldModel: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetManagementURL(v) - return nil - case netbird.FieldManagementConnected: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManagementConnected(v) + m.SetModel(v) return nil - case netbird.FieldSignalURL: + case monitor.FieldSerial: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSignalURL(v) - return nil - case netbird.FieldSignalConnected: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSignalConnected(v) - return nil - case netbird.FieldSSHEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSSHEnabled(v) - return nil - case netbird.FieldPeersTotal: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPeersTotal(v) - return nil - case netbird.FieldPeersConnected: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPeersConnected(v) + m.SetSerial(v) return nil - case netbird.FieldProfilesAvailable: + case monitor.FieldWeekOfManufacture: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetProfilesAvailable(v) + m.SetWeekOfManufacture(v) return nil - case netbird.FieldDNSServer: + case monitor.FieldYearOfManufacture: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDNSServer(v) + m.SetYearOfManufacture(v) return nil } - return fmt.Errorf("unknown Netbird field %s", name) + return fmt.Errorf("unknown Monitor field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *NetbirdMutation) AddedFields() []string { - var fields []string - if m.addpeers_total != nil { - fields = append(fields, netbird.FieldPeersTotal) - } - if m.addpeers_connected != nil { - fields = append(fields, netbird.FieldPeersConnected) - } - return fields +func (m *MonitorMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *NetbirdMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case netbird.FieldPeersTotal: - return m.AddedPeersTotal() - case netbird.FieldPeersConnected: - return m.AddedPeersConnected() - } +func (m *MonitorMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NetbirdMutation) AddField(name string, value ent.Value) error { +func (m *MonitorMutation) AddField(name string, value ent.Value) error { switch name { - case netbird.FieldPeersTotal: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPeersTotal(v) - return nil - case netbird.FieldPeersConnected: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddPeersConnected(v) - return nil } - return fmt.Errorf("unknown Netbird numeric field %s", name) + return fmt.Errorf("unknown Monitor numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *NetbirdMutation) ClearedFields() []string { +func (m *MonitorMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(netbird.FieldIP) { - fields = append(fields, netbird.FieldIP) + if m.FieldCleared(monitor.FieldManufacturer) { + fields = append(fields, monitor.FieldManufacturer) } - if m.FieldCleared(netbird.FieldProfile) { - fields = append(fields, netbird.FieldProfile) + if m.FieldCleared(monitor.FieldModel) { + fields = append(fields, monitor.FieldModel) } - if m.FieldCleared(netbird.FieldManagementURL) { - fields = append(fields, netbird.FieldManagementURL) + if m.FieldCleared(monitor.FieldSerial) { + fields = append(fields, monitor.FieldSerial) } - if m.FieldCleared(netbird.FieldSignalURL) { - fields = append(fields, netbird.FieldSignalURL) + if m.FieldCleared(monitor.FieldWeekOfManufacture) { + fields = append(fields, monitor.FieldWeekOfManufacture) } - if m.FieldCleared(netbird.FieldPeersTotal) { - fields = append(fields, netbird.FieldPeersTotal) - } - if m.FieldCleared(netbird.FieldPeersConnected) { - fields = append(fields, netbird.FieldPeersConnected) - } - if m.FieldCleared(netbird.FieldProfilesAvailable) { - fields = append(fields, netbird.FieldProfilesAvailable) - } - if m.FieldCleared(netbird.FieldDNSServer) { - fields = append(fields, netbird.FieldDNSServer) + if m.FieldCleared(monitor.FieldYearOfManufacture) { + fields = append(fields, monitor.FieldYearOfManufacture) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *NetbirdMutation) FieldCleared(name string) bool { +func (m *MonitorMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *NetbirdMutation) ClearField(name string) error { +func (m *MonitorMutation) ClearField(name string) error { switch name { - case netbird.FieldIP: - m.ClearIP() - return nil - case netbird.FieldProfile: - m.ClearProfile() - return nil - case netbird.FieldManagementURL: - m.ClearManagementURL() - return nil - case netbird.FieldSignalURL: - m.ClearSignalURL() + case monitor.FieldManufacturer: + m.ClearManufacturer() return nil - case netbird.FieldPeersTotal: - m.ClearPeersTotal() + case monitor.FieldModel: + m.ClearModel() return nil - case netbird.FieldPeersConnected: - m.ClearPeersConnected() + case monitor.FieldSerial: + m.ClearSerial() return nil - case netbird.FieldProfilesAvailable: - m.ClearProfilesAvailable() + case monitor.FieldWeekOfManufacture: + m.ClearWeekOfManufacture() return nil - case netbird.FieldDNSServer: - m.ClearDNSServer() + case monitor.FieldYearOfManufacture: + m.ClearYearOfManufacture() return nil } - return fmt.Errorf("unknown Netbird nullable field %s", name) + return fmt.Errorf("unknown Monitor nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *NetbirdMutation) ResetField(name string) error { +func (m *MonitorMutation) ResetField(name string) error { switch name { - case netbird.FieldVersion: - m.ResetVersion() - return nil - case netbird.FieldInstalled: - m.ResetInstalled() - return nil - case netbird.FieldServiceStatus: - m.ResetServiceStatus() - return nil - case netbird.FieldIP: - m.ResetIP() - return nil - case netbird.FieldProfile: - m.ResetProfile() - return nil - case netbird.FieldManagementURL: - m.ResetManagementURL() - return nil - case netbird.FieldManagementConnected: - m.ResetManagementConnected() - return nil - case netbird.FieldSignalURL: - m.ResetSignalURL() - return nil - case netbird.FieldSignalConnected: - m.ResetSignalConnected() - return nil - case netbird.FieldSSHEnabled: - m.ResetSSHEnabled() + case monitor.FieldManufacturer: + m.ResetManufacturer() return nil - case netbird.FieldPeersTotal: - m.ResetPeersTotal() + case monitor.FieldModel: + m.ResetModel() return nil - case netbird.FieldPeersConnected: - m.ResetPeersConnected() + case monitor.FieldSerial: + m.ResetSerial() return nil - case netbird.FieldProfilesAvailable: - m.ResetProfilesAvailable() + case monitor.FieldWeekOfManufacture: + m.ResetWeekOfManufacture() return nil - case netbird.FieldDNSServer: - m.ResetDNSServer() + case monitor.FieldYearOfManufacture: + m.ResetYearOfManufacture() return nil } - return fmt.Errorf("unknown Netbird field %s", name) + return fmt.Errorf("unknown Monitor field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *NetbirdMutation) AddedEdges() []string { +func (m *MonitorMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, netbird.EdgeOwner) + edges = append(edges, monitor.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *NetbirdMutation) AddedIDs(name string) []ent.Value { +func (m *MonitorMutation) AddedIDs(name string) []ent.Value { switch name { - case netbird.EdgeOwner: + case monitor.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -12755,31 +13626,31 @@ func (m *NetbirdMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *NetbirdMutation) RemovedEdges() []string { +func (m *MonitorMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *NetbirdMutation) RemovedIDs(name string) []ent.Value { +func (m *MonitorMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NetbirdMutation) ClearedEdges() []string { +func (m *MonitorMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, netbird.EdgeOwner) + edges = append(edges, monitor.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *NetbirdMutation) EdgeCleared(name string) bool { +func (m *MonitorMutation) EdgeCleared(name string) bool { switch name { - case netbird.EdgeOwner: + case monitor.EdgeOwner: return m.clearedowner } return false @@ -12787,54 +13658,67 @@ func (m *NetbirdMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *NetbirdMutation) ClearEdge(name string) error { +func (m *MonitorMutation) ClearEdge(name string) error { switch name { - case netbird.EdgeOwner: + case monitor.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown Netbird unique edge %s", name) + return fmt.Errorf("unknown Monitor unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *NetbirdMutation) ResetEdge(name string) error { +func (m *MonitorMutation) ResetEdge(name string) error { switch name { - case netbird.EdgeOwner: + case monitor.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown Netbird edge %s", name) + return fmt.Errorf("unknown Monitor edge %s", name) } -// NetbirdSettingsMutation represents an operation that mutates the NetbirdSettings nodes in the graph. -type NetbirdSettingsMutation struct { +// NetbirdMutation represents an operation that mutates the Netbird nodes in the graph. +type NetbirdMutation struct { config - op Op - typ string - id *int - management_url *string - access_token *string - clearedFields map[string]struct{} - tenant map[int]struct{} - removedtenant map[int]struct{} - clearedtenant bool - done bool - oldValue func(context.Context) (*NetbirdSettings, error) - predicates []predicate.NetbirdSettings + op Op + typ string + id *int + version *string + installed *bool + service_status *string + ip *string + profile *string + management_url *string + management_connected *bool + signal_url *string + signal_connected *bool + ssh_enabled *bool + peers_total *int + addpeers_total *int + peers_connected *int + addpeers_connected *int + profiles_available *string + dns_server *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Netbird, error) + predicates []predicate.Netbird } -var _ ent.Mutation = (*NetbirdSettingsMutation)(nil) +var _ ent.Mutation = (*NetbirdMutation)(nil) -// netbirdsettingsOption allows management of the mutation configuration using functional options. -type netbirdsettingsOption func(*NetbirdSettingsMutation) +// netbirdOption allows management of the mutation configuration using functional options. +type netbirdOption func(*NetbirdMutation) -// newNetbirdSettingsMutation creates new mutation for the NetbirdSettings entity. -func newNetbirdSettingsMutation(c config, op Op, opts ...netbirdsettingsOption) *NetbirdSettingsMutation { - m := &NetbirdSettingsMutation{ +// newNetbirdMutation creates new mutation for the Netbird entity. +func newNetbirdMutation(c config, op Op, opts ...netbirdOption) *NetbirdMutation { + m := &NetbirdMutation{ config: c, op: op, - typ: TypeNetbirdSettings, + typ: TypeNetbird, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -12843,20 +13727,20 @@ func newNetbirdSettingsMutation(c config, op Op, opts ...netbirdsettingsOption) return m } -// withNetbirdSettingsID sets the ID field of the mutation. -func withNetbirdSettingsID(id int) netbirdsettingsOption { - return func(m *NetbirdSettingsMutation) { +// withNetbirdID sets the ID field of the mutation. +func withNetbirdID(id int) netbirdOption { + return func(m *NetbirdMutation) { var ( err error once sync.Once - value *NetbirdSettings + value *Netbird ) - m.oldValue = func(ctx context.Context) (*NetbirdSettings, error) { + m.oldValue = func(ctx context.Context) (*Netbird, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().NetbirdSettings.Get(ctx, id) + value, err = m.Client().Netbird.Get(ctx, id) } }) return value, err @@ -12865,10 +13749,10 @@ func withNetbirdSettingsID(id int) netbirdsettingsOption { } } -// withNetbirdSettings sets the old NetbirdSettings of the mutation. -func withNetbirdSettings(node *NetbirdSettings) netbirdsettingsOption { - return func(m *NetbirdSettingsMutation) { - m.oldValue = func(context.Context) (*NetbirdSettings, error) { +// withNetbird sets the old Netbird of the mutation. +func withNetbird(node *Netbird) netbirdOption { + return func(m *NetbirdMutation) { + m.oldValue = func(context.Context) (*Netbird, error) { return node, nil } m.id = &node.ID @@ -12877,7 +13761,7 @@ func withNetbirdSettings(node *NetbirdSettings) netbirdsettingsOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m NetbirdSettingsMutation) Client() *Client { +func (m NetbirdMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -12885,7 +13769,7 @@ func (m NetbirdSettingsMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m NetbirdSettingsMutation) Tx() (*Tx, error) { +func (m NetbirdMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -12896,7 +13780,7 @@ func (m NetbirdSettingsMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *NetbirdSettingsMutation) ID() (id int, exists bool) { +func (m *NetbirdMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -12907,7 +13791,7 @@ func (m *NetbirdSettingsMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *NetbirdSettingsMutation) IDs(ctx context.Context) ([]int, error) { +func (m *NetbirdMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -12916,1088 +13800,679 @@ func (m *NetbirdSettingsMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().NetbirdSettings.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Netbird.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetManagementURL sets the "management_url" field. -func (m *NetbirdSettingsMutation) SetManagementURL(s string) { - m.management_url = &s +// SetVersion sets the "version" field. +func (m *NetbirdMutation) SetVersion(s string) { + m.version = &s } -// ManagementURL returns the value of the "management_url" field in the mutation. -func (m *NetbirdSettingsMutation) ManagementURL() (r string, exists bool) { - v := m.management_url +// Version returns the value of the "version" field in the mutation. +func (m *NetbirdMutation) Version() (r string, exists bool) { + v := m.version if v == nil { return } return *v, true } -// OldManagementURL returns the old "management_url" field's value of the NetbirdSettings entity. -// If the NetbirdSettings object wasn't provided to the builder, the object is fetched from the database. +// OldVersion returns the old "version" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdSettingsMutation) OldManagementURL(ctx context.Context) (v string, err error) { +func (m *NetbirdMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManagementURL is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManagementURL requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldManagementURL: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.ManagementURL, nil + return oldValue.Version, nil } -// ClearManagementURL clears the value of the "management_url" field. -func (m *NetbirdSettingsMutation) ClearManagementURL() { - m.management_url = nil - m.clearedFields[netbirdsettings.FieldManagementURL] = struct{}{} +// ResetVersion resets all changes to the "version" field. +func (m *NetbirdMutation) ResetVersion() { + m.version = nil } -// ManagementURLCleared returns if the "management_url" field was cleared in this mutation. -func (m *NetbirdSettingsMutation) ManagementURLCleared() bool { - _, ok := m.clearedFields[netbirdsettings.FieldManagementURL] - return ok +// SetInstalled sets the "installed" field. +func (m *NetbirdMutation) SetInstalled(b bool) { + m.installed = &b } -// ResetManagementURL resets all changes to the "management_url" field. -func (m *NetbirdSettingsMutation) ResetManagementURL() { - m.management_url = nil - delete(m.clearedFields, netbirdsettings.FieldManagementURL) +// Installed returns the value of the "installed" field in the mutation. +func (m *NetbirdMutation) Installed() (r bool, exists bool) { + v := m.installed + if v == nil { + return + } + return *v, true } -// SetAccessToken sets the "access_token" field. -func (m *NetbirdSettingsMutation) SetAccessToken(s string) { - m.access_token = &s +// OldInstalled returns the old "installed" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetbirdMutation) OldInstalled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldInstalled is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldInstalled requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldInstalled: %w", err) + } + return oldValue.Installed, nil } -// AccessToken returns the value of the "access_token" field in the mutation. -func (m *NetbirdSettingsMutation) AccessToken() (r string, exists bool) { - v := m.access_token +// ResetInstalled resets all changes to the "installed" field. +func (m *NetbirdMutation) ResetInstalled() { + m.installed = nil +} + +// SetServiceStatus sets the "service_status" field. +func (m *NetbirdMutation) SetServiceStatus(s string) { + m.service_status = &s +} + +// ServiceStatus returns the value of the "service_status" field in the mutation. +func (m *NetbirdMutation) ServiceStatus() (r string, exists bool) { + v := m.service_status if v == nil { return } return *v, true } -// OldAccessToken returns the old "access_token" field's value of the NetbirdSettings entity. -// If the NetbirdSettings object wasn't provided to the builder, the object is fetched from the database. +// OldServiceStatus returns the old "service_status" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetbirdSettingsMutation) OldAccessToken(ctx context.Context) (v string, err error) { +func (m *NetbirdMutation) OldServiceStatus(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") + return v, errors.New("OldServiceStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAccessToken requires an ID field in the mutation") + return v, errors.New("OldServiceStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) + return v, fmt.Errorf("querying old value for OldServiceStatus: %w", err) } - return oldValue.AccessToken, nil + return oldValue.ServiceStatus, nil } -// ClearAccessToken clears the value of the "access_token" field. -func (m *NetbirdSettingsMutation) ClearAccessToken() { - m.access_token = nil - m.clearedFields[netbirdsettings.FieldAccessToken] = struct{}{} +// ResetServiceStatus resets all changes to the "service_status" field. +func (m *NetbirdMutation) ResetServiceStatus() { + m.service_status = nil } -// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. -func (m *NetbirdSettingsMutation) AccessTokenCleared() bool { - _, ok := m.clearedFields[netbirdsettings.FieldAccessToken] - return ok +// SetIP sets the "ip" field. +func (m *NetbirdMutation) SetIP(s string) { + m.ip = &s } -// ResetAccessToken resets all changes to the "access_token" field. -func (m *NetbirdSettingsMutation) ResetAccessToken() { - m.access_token = nil - delete(m.clearedFields, netbirdsettings.FieldAccessToken) +// IP returns the value of the "ip" field in the mutation. +func (m *NetbirdMutation) IP() (r string, exists bool) { + v := m.ip + if v == nil { + return + } + return *v, true } -// AddTenantIDs adds the "tenant" edge to the Tenant entity by ids. -func (m *NetbirdSettingsMutation) AddTenantIDs(ids ...int) { - if m.tenant == nil { - m.tenant = make(map[int]struct{}) +// OldIP returns the old "ip" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetbirdMutation) OldIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIP is only allowed on UpdateOne operations") } - for i := range ids { - m.tenant[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIP: %w", err) } + return oldValue.IP, nil } -// ClearTenant clears the "tenant" edge to the Tenant entity. -func (m *NetbirdSettingsMutation) ClearTenant() { - m.clearedtenant = true +// ClearIP clears the value of the "ip" field. +func (m *NetbirdMutation) ClearIP() { + m.ip = nil + m.clearedFields[netbird.FieldIP] = struct{}{} } -// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. -func (m *NetbirdSettingsMutation) TenantCleared() bool { - return m.clearedtenant +// IPCleared returns if the "ip" field was cleared in this mutation. +func (m *NetbirdMutation) IPCleared() bool { + _, ok := m.clearedFields[netbird.FieldIP] + return ok } -// RemoveTenantIDs removes the "tenant" edge to the Tenant entity by IDs. -func (m *NetbirdSettingsMutation) RemoveTenantIDs(ids ...int) { - if m.removedtenant == nil { - m.removedtenant = make(map[int]struct{}) - } - for i := range ids { - delete(m.tenant, ids[i]) - m.removedtenant[ids[i]] = struct{}{} - } +// ResetIP resets all changes to the "ip" field. +func (m *NetbirdMutation) ResetIP() { + m.ip = nil + delete(m.clearedFields, netbird.FieldIP) } -// RemovedTenant returns the removed IDs of the "tenant" edge to the Tenant entity. -func (m *NetbirdSettingsMutation) RemovedTenantIDs() (ids []int) { - for id := range m.removedtenant { - ids = append(ids, id) - } - return +// SetProfile sets the "profile" field. +func (m *NetbirdMutation) SetProfile(s string) { + m.profile = &s } -// TenantIDs returns the "tenant" edge IDs in the mutation. -func (m *NetbirdSettingsMutation) TenantIDs() (ids []int) { - for id := range m.tenant { - ids = append(ids, id) +// Profile returns the value of the "profile" field in the mutation. +func (m *NetbirdMutation) Profile() (r string, exists bool) { + v := m.profile + if v == nil { + return } - return + return *v, true } -// ResetTenant resets all changes to the "tenant" edge. -func (m *NetbirdSettingsMutation) ResetTenant() { - m.tenant = nil - m.clearedtenant = false - m.removedtenant = nil +// OldProfile returns the old "profile" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetbirdMutation) OldProfile(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProfile is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProfile requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProfile: %w", err) + } + return oldValue.Profile, nil } -// Where appends a list predicates to the NetbirdSettingsMutation builder. -func (m *NetbirdSettingsMutation) Where(ps ...predicate.NetbirdSettings) { - m.predicates = append(m.predicates, ps...) +// ClearProfile clears the value of the "profile" field. +func (m *NetbirdMutation) ClearProfile() { + m.profile = nil + m.clearedFields[netbird.FieldProfile] = struct{}{} } -// WhereP appends storage-level predicates to the NetbirdSettingsMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *NetbirdSettingsMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.NetbirdSettings, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// ProfileCleared returns if the "profile" field was cleared in this mutation. +func (m *NetbirdMutation) ProfileCleared() bool { + _, ok := m.clearedFields[netbird.FieldProfile] + return ok } -// Op returns the operation name. -func (m *NetbirdSettingsMutation) Op() Op { - return m.op +// ResetProfile resets all changes to the "profile" field. +func (m *NetbirdMutation) ResetProfile() { + m.profile = nil + delete(m.clearedFields, netbird.FieldProfile) } -// SetOp allows setting the mutation operation. -func (m *NetbirdSettingsMutation) SetOp(op Op) { - m.op = op +// SetManagementURL sets the "management_url" field. +func (m *NetbirdMutation) SetManagementURL(s string) { + m.management_url = &s } -// Type returns the node type of this mutation (NetbirdSettings). -func (m *NetbirdSettingsMutation) Type() string { - return m.typ +// ManagementURL returns the value of the "management_url" field in the mutation. +func (m *NetbirdMutation) ManagementURL() (r string, exists bool) { + v := m.management_url + if v == nil { + return + } + return *v, true } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *NetbirdSettingsMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.management_url != nil { - fields = append(fields, netbirdsettings.FieldManagementURL) +// OldManagementURL returns the old "management_url" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetbirdMutation) OldManagementURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldManagementURL is only allowed on UpdateOne operations") } - if m.access_token != nil { - fields = append(fields, netbirdsettings.FieldAccessToken) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldManagementURL requires an ID field in the mutation") } - return fields + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldManagementURL: %w", err) + } + return oldValue.ManagementURL, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *NetbirdSettingsMutation) Field(name string) (ent.Value, bool) { - switch name { - case netbirdsettings.FieldManagementURL: - return m.ManagementURL() - case netbirdsettings.FieldAccessToken: - return m.AccessToken() - } - return nil, false +// ClearManagementURL clears the value of the "management_url" field. +func (m *NetbirdMutation) ClearManagementURL() { + m.management_url = nil + m.clearedFields[netbird.FieldManagementURL] = struct{}{} } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *NetbirdSettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case netbirdsettings.FieldManagementURL: - return m.OldManagementURL(ctx) - case netbirdsettings.FieldAccessToken: - return m.OldAccessToken(ctx) - } - return nil, fmt.Errorf("unknown NetbirdSettings field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *NetbirdSettingsMutation) SetField(name string, value ent.Value) error { - switch name { - case netbirdsettings.FieldManagementURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManagementURL(v) - return nil - case netbirdsettings.FieldAccessToken: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAccessToken(v) - return nil - } - return fmt.Errorf("unknown NetbirdSettings field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *NetbirdSettingsMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *NetbirdSettingsMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *NetbirdSettingsMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown NetbirdSettings numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *NetbirdSettingsMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(netbirdsettings.FieldManagementURL) { - fields = append(fields, netbirdsettings.FieldManagementURL) - } - if m.FieldCleared(netbirdsettings.FieldAccessToken) { - fields = append(fields, netbirdsettings.FieldAccessToken) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *NetbirdSettingsMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// ManagementURLCleared returns if the "management_url" field was cleared in this mutation. +func (m *NetbirdMutation) ManagementURLCleared() bool { + _, ok := m.clearedFields[netbird.FieldManagementURL] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *NetbirdSettingsMutation) ClearField(name string) error { - switch name { - case netbirdsettings.FieldManagementURL: - m.ClearManagementURL() - return nil - case netbirdsettings.FieldAccessToken: - m.ClearAccessToken() - return nil - } - return fmt.Errorf("unknown NetbirdSettings nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *NetbirdSettingsMutation) ResetField(name string) error { - switch name { - case netbirdsettings.FieldManagementURL: - m.ResetManagementURL() - return nil - case netbirdsettings.FieldAccessToken: - m.ResetAccessToken() - return nil - } - return fmt.Errorf("unknown NetbirdSettings field %s", name) +// ResetManagementURL resets all changes to the "management_url" field. +func (m *NetbirdMutation) ResetManagementURL() { + m.management_url = nil + delete(m.clearedFields, netbird.FieldManagementURL) } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *NetbirdSettingsMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.tenant != nil { - edges = append(edges, netbirdsettings.EdgeTenant) - } - return edges +// SetManagementConnected sets the "management_connected" field. +func (m *NetbirdMutation) SetManagementConnected(b bool) { + m.management_connected = &b } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *NetbirdSettingsMutation) AddedIDs(name string) []ent.Value { - switch name { - case netbirdsettings.EdgeTenant: - ids := make([]ent.Value, 0, len(m.tenant)) - for id := range m.tenant { - ids = append(ids, id) - } - return ids +// ManagementConnected returns the value of the "management_connected" field in the mutation. +func (m *NetbirdMutation) ManagementConnected() (r bool, exists bool) { + v := m.management_connected + if v == nil { + return } - return nil + return *v, true } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *NetbirdSettingsMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedtenant != nil { - edges = append(edges, netbirdsettings.EdgeTenant) +// OldManagementConnected returns the old "management_connected" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetbirdMutation) OldManagementConnected(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldManagementConnected is only allowed on UpdateOne operations") } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *NetbirdSettingsMutation) RemovedIDs(name string) []ent.Value { - switch name { - case netbirdsettings.EdgeTenant: - ids := make([]ent.Value, 0, len(m.removedtenant)) - for id := range m.removedtenant { - ids = append(ids, id) - } - return ids + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldManagementConnected requires an ID field in the mutation") } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NetbirdSettingsMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedtenant { - edges = append(edges, netbirdsettings.EdgeTenant) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldManagementConnected: %w", err) } - return edges + return oldValue.ManagementConnected, nil } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *NetbirdSettingsMutation) EdgeCleared(name string) bool { - switch name { - case netbirdsettings.EdgeTenant: - return m.clearedtenant - } - return false +// ResetManagementConnected resets all changes to the "management_connected" field. +func (m *NetbirdMutation) ResetManagementConnected() { + m.management_connected = nil } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *NetbirdSettingsMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown NetbirdSettings unique edge %s", name) +// SetSignalURL sets the "signal_url" field. +func (m *NetbirdMutation) SetSignalURL(s string) { + m.signal_url = &s } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *NetbirdSettingsMutation) ResetEdge(name string) error { - switch name { - case netbirdsettings.EdgeTenant: - m.ResetTenant() - return nil +// SignalURL returns the value of the "signal_url" field in the mutation. +func (m *NetbirdMutation) SignalURL() (r string, exists bool) { + v := m.signal_url + if v == nil { + return } - return fmt.Errorf("unknown NetbirdSettings edge %s", name) -} - -// NetworkAdapterMutation represents an operation that mutates the NetworkAdapter nodes in the graph. -type NetworkAdapterMutation struct { - config - op Op - typ string - id *int - name *string - mac_address *string - addresses *string - subnet *string - default_gateway *string - dns_servers *string - dns_domain *string - dhcp_enabled *bool - dhcp_lease_obtained *time.Time - dhcp_lease_expired *time.Time - speed *string - virtual *bool - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*NetworkAdapter, error) - predicates []predicate.NetworkAdapter + return *v, true } -var _ ent.Mutation = (*NetworkAdapterMutation)(nil) - -// networkadapterOption allows management of the mutation configuration using functional options. -type networkadapterOption func(*NetworkAdapterMutation) - -// newNetworkAdapterMutation creates new mutation for the NetworkAdapter entity. -func newNetworkAdapterMutation(c config, op Op, opts ...networkadapterOption) *NetworkAdapterMutation { - m := &NetworkAdapterMutation{ - config: c, - op: op, - typ: TypeNetworkAdapter, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) +// OldSignalURL returns the old "signal_url" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetbirdMutation) OldSignalURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSignalURL is only allowed on UpdateOne operations") } - return m -} - -// withNetworkAdapterID sets the ID field of the mutation. -func withNetworkAdapterID(id int) networkadapterOption { - return func(m *NetworkAdapterMutation) { - var ( - err error - once sync.Once - value *NetworkAdapter - ) - m.oldValue = func(ctx context.Context) (*NetworkAdapter, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().NetworkAdapter.Get(ctx, id) - } - }) - return value, err - } - m.id = &id + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSignalURL requires an ID field in the mutation") } -} - -// withNetworkAdapter sets the old NetworkAdapter of the mutation. -func withNetworkAdapter(node *NetworkAdapter) networkadapterOption { - return func(m *NetworkAdapterMutation) { - m.oldValue = func(context.Context) (*NetworkAdapter, error) { - return node, nil - } - m.id = &node.ID + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSignalURL: %w", err) } + return oldValue.SignalURL, nil } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m NetworkAdapterMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m NetworkAdapterMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// ClearSignalURL clears the value of the "signal_url" field. +func (m *NetbirdMutation) ClearSignalURL() { + m.signal_url = nil + m.clearedFields[netbird.FieldSignalURL] = struct{}{} } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *NetworkAdapterMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true +// SignalURLCleared returns if the "signal_url" field was cleared in this mutation. +func (m *NetbirdMutation) SignalURLCleared() bool { + _, ok := m.clearedFields[netbird.FieldSignalURL] + return ok } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *NetworkAdapterMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().NetworkAdapter.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } +// ResetSignalURL resets all changes to the "signal_url" field. +func (m *NetbirdMutation) ResetSignalURL() { + m.signal_url = nil + delete(m.clearedFields, netbird.FieldSignalURL) } -// SetName sets the "name" field. -func (m *NetworkAdapterMutation) SetName(s string) { - m.name = &s +// SetSignalConnected sets the "signal_connected" field. +func (m *NetbirdMutation) SetSignalConnected(b bool) { + m.signal_connected = &b } -// Name returns the value of the "name" field in the mutation. -func (m *NetworkAdapterMutation) Name() (r string, exists bool) { - v := m.name +// SignalConnected returns the value of the "signal_connected" field in the mutation. +func (m *NetbirdMutation) SignalConnected() (r bool, exists bool) { + v := m.signal_connected if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// OldSignalConnected returns the old "signal_connected" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldName(ctx context.Context) (v string, err error) { +func (m *NetbirdMutation) OldSignalConnected(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldSignalConnected is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldSignalConnected requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldSignalConnected: %w", err) } - return oldValue.Name, nil + return oldValue.SignalConnected, nil } -// ResetName resets all changes to the "name" field. -func (m *NetworkAdapterMutation) ResetName() { - m.name = nil +// ResetSignalConnected resets all changes to the "signal_connected" field. +func (m *NetbirdMutation) ResetSignalConnected() { + m.signal_connected = nil } -// SetMACAddress sets the "mac_address" field. -func (m *NetworkAdapterMutation) SetMACAddress(s string) { - m.mac_address = &s +// SetSSHEnabled sets the "ssh_enabled" field. +func (m *NetbirdMutation) SetSSHEnabled(b bool) { + m.ssh_enabled = &b } -// MACAddress returns the value of the "mac_address" field in the mutation. -func (m *NetworkAdapterMutation) MACAddress() (r string, exists bool) { - v := m.mac_address +// SSHEnabled returns the value of the "ssh_enabled" field in the mutation. +func (m *NetbirdMutation) SSHEnabled() (r bool, exists bool) { + v := m.ssh_enabled if v == nil { return } return *v, true } -// OldMACAddress returns the old "mac_address" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// OldSSHEnabled returns the old "ssh_enabled" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldMACAddress(ctx context.Context) (v string, err error) { +func (m *NetbirdMutation) OldSSHEnabled(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMACAddress is only allowed on UpdateOne operations") + return v, errors.New("OldSSHEnabled is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMACAddress requires an ID field in the mutation") + return v, errors.New("OldSSHEnabled requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMACAddress: %w", err) + return v, fmt.Errorf("querying old value for OldSSHEnabled: %w", err) } - return oldValue.MACAddress, nil + return oldValue.SSHEnabled, nil } -// ResetMACAddress resets all changes to the "mac_address" field. -func (m *NetworkAdapterMutation) ResetMACAddress() { - m.mac_address = nil +// ResetSSHEnabled resets all changes to the "ssh_enabled" field. +func (m *NetbirdMutation) ResetSSHEnabled() { + m.ssh_enabled = nil } -// SetAddresses sets the "addresses" field. -func (m *NetworkAdapterMutation) SetAddresses(s string) { - m.addresses = &s +// SetPeersTotal sets the "peers_total" field. +func (m *NetbirdMutation) SetPeersTotal(i int) { + m.peers_total = &i + m.addpeers_total = nil } -// Addresses returns the value of the "addresses" field in the mutation. -func (m *NetworkAdapterMutation) Addresses() (r string, exists bool) { - v := m.addresses +// PeersTotal returns the value of the "peers_total" field in the mutation. +func (m *NetbirdMutation) PeersTotal() (r int, exists bool) { + v := m.peers_total if v == nil { return } return *v, true } -// OldAddresses returns the old "addresses" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// OldPeersTotal returns the old "peers_total" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldAddresses(ctx context.Context) (v string, err error) { +func (m *NetbirdMutation) OldPeersTotal(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAddresses is only allowed on UpdateOne operations") + return v, errors.New("OldPeersTotal is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAddresses requires an ID field in the mutation") + return v, errors.New("OldPeersTotal requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAddresses: %w", err) + return v, fmt.Errorf("querying old value for OldPeersTotal: %w", err) } - return oldValue.Addresses, nil -} - -// ResetAddresses resets all changes to the "addresses" field. -func (m *NetworkAdapterMutation) ResetAddresses() { - m.addresses = nil + return oldValue.PeersTotal, nil } -// SetSubnet sets the "subnet" field. -func (m *NetworkAdapterMutation) SetSubnet(s string) { - m.subnet = &s +// AddPeersTotal adds i to the "peers_total" field. +func (m *NetbirdMutation) AddPeersTotal(i int) { + if m.addpeers_total != nil { + *m.addpeers_total += i + } else { + m.addpeers_total = &i + } } -// Subnet returns the value of the "subnet" field in the mutation. -func (m *NetworkAdapterMutation) Subnet() (r string, exists bool) { - v := m.subnet +// AddedPeersTotal returns the value that was added to the "peers_total" field in this mutation. +func (m *NetbirdMutation) AddedPeersTotal() (r int, exists bool) { + v := m.addpeers_total if v == nil { return } return *v, true } -// OldSubnet returns the old "subnet" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldSubnet(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSubnet is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSubnet requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSubnet: %w", err) - } - return oldValue.Subnet, nil -} - -// ClearSubnet clears the value of the "subnet" field. -func (m *NetworkAdapterMutation) ClearSubnet() { - m.subnet = nil - m.clearedFields[networkadapter.FieldSubnet] = struct{}{} +// ClearPeersTotal clears the value of the "peers_total" field. +func (m *NetbirdMutation) ClearPeersTotal() { + m.peers_total = nil + m.addpeers_total = nil + m.clearedFields[netbird.FieldPeersTotal] = struct{}{} } -// SubnetCleared returns if the "subnet" field was cleared in this mutation. -func (m *NetworkAdapterMutation) SubnetCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldSubnet] +// PeersTotalCleared returns if the "peers_total" field was cleared in this mutation. +func (m *NetbirdMutation) PeersTotalCleared() bool { + _, ok := m.clearedFields[netbird.FieldPeersTotal] return ok } -// ResetSubnet resets all changes to the "subnet" field. -func (m *NetworkAdapterMutation) ResetSubnet() { - m.subnet = nil - delete(m.clearedFields, networkadapter.FieldSubnet) +// ResetPeersTotal resets all changes to the "peers_total" field. +func (m *NetbirdMutation) ResetPeersTotal() { + m.peers_total = nil + m.addpeers_total = nil + delete(m.clearedFields, netbird.FieldPeersTotal) } -// SetDefaultGateway sets the "default_gateway" field. -func (m *NetworkAdapterMutation) SetDefaultGateway(s string) { - m.default_gateway = &s +// SetPeersConnected sets the "peers_connected" field. +func (m *NetbirdMutation) SetPeersConnected(i int) { + m.peers_connected = &i + m.addpeers_connected = nil } -// DefaultGateway returns the value of the "default_gateway" field in the mutation. -func (m *NetworkAdapterMutation) DefaultGateway() (r string, exists bool) { - v := m.default_gateway +// PeersConnected returns the value of the "peers_connected" field in the mutation. +func (m *NetbirdMutation) PeersConnected() (r int, exists bool) { + v := m.peers_connected if v == nil { return } return *v, true } -// OldDefaultGateway returns the old "default_gateway" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// OldPeersConnected returns the old "peers_connected" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldDefaultGateway(ctx context.Context) (v string, err error) { +func (m *NetbirdMutation) OldPeersConnected(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDefaultGateway is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDefaultGateway requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDefaultGateway: %w", err) - } - return oldValue.DefaultGateway, nil -} - -// ClearDefaultGateway clears the value of the "default_gateway" field. -func (m *NetworkAdapterMutation) ClearDefaultGateway() { - m.default_gateway = nil - m.clearedFields[networkadapter.FieldDefaultGateway] = struct{}{} -} - -// DefaultGatewayCleared returns if the "default_gateway" field was cleared in this mutation. -func (m *NetworkAdapterMutation) DefaultGatewayCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldDefaultGateway] - return ok -} - -// ResetDefaultGateway resets all changes to the "default_gateway" field. -func (m *NetworkAdapterMutation) ResetDefaultGateway() { - m.default_gateway = nil - delete(m.clearedFields, networkadapter.FieldDefaultGateway) -} - -// SetDNSServers sets the "dns_servers" field. -func (m *NetworkAdapterMutation) SetDNSServers(s string) { - m.dns_servers = &s -} - -// DNSServers returns the value of the "dns_servers" field in the mutation. -func (m *NetworkAdapterMutation) DNSServers() (r string, exists bool) { - v := m.dns_servers - if v == nil { - return - } - return *v, true -} - -// OldDNSServers returns the old "dns_servers" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldDNSServers(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDNSServers is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDNSServers requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDNSServers: %w", err) - } - return oldValue.DNSServers, nil -} - -// ClearDNSServers clears the value of the "dns_servers" field. -func (m *NetworkAdapterMutation) ClearDNSServers() { - m.dns_servers = nil - m.clearedFields[networkadapter.FieldDNSServers] = struct{}{} -} - -// DNSServersCleared returns if the "dns_servers" field was cleared in this mutation. -func (m *NetworkAdapterMutation) DNSServersCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldDNSServers] - return ok -} - -// ResetDNSServers resets all changes to the "dns_servers" field. -func (m *NetworkAdapterMutation) ResetDNSServers() { - m.dns_servers = nil - delete(m.clearedFields, networkadapter.FieldDNSServers) -} - -// SetDNSDomain sets the "dns_domain" field. -func (m *NetworkAdapterMutation) SetDNSDomain(s string) { - m.dns_domain = &s -} - -// DNSDomain returns the value of the "dns_domain" field in the mutation. -func (m *NetworkAdapterMutation) DNSDomain() (r string, exists bool) { - v := m.dns_domain - if v == nil { - return - } - return *v, true -} - -// OldDNSDomain returns the old "dns_domain" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldDNSDomain(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDNSDomain is only allowed on UpdateOne operations") + return v, errors.New("OldPeersConnected is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDNSDomain requires an ID field in the mutation") + return v, errors.New("OldPeersConnected requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDNSDomain: %w", err) - } - return oldValue.DNSDomain, nil -} - -// ClearDNSDomain clears the value of the "dns_domain" field. -func (m *NetworkAdapterMutation) ClearDNSDomain() { - m.dns_domain = nil - m.clearedFields[networkadapter.FieldDNSDomain] = struct{}{} -} - -// DNSDomainCleared returns if the "dns_domain" field was cleared in this mutation. -func (m *NetworkAdapterMutation) DNSDomainCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldDNSDomain] - return ok -} - -// ResetDNSDomain resets all changes to the "dns_domain" field. -func (m *NetworkAdapterMutation) ResetDNSDomain() { - m.dns_domain = nil - delete(m.clearedFields, networkadapter.FieldDNSDomain) -} - -// SetDhcpEnabled sets the "dhcp_enabled" field. -func (m *NetworkAdapterMutation) SetDhcpEnabled(b bool) { - m.dhcp_enabled = &b -} - -// DhcpEnabled returns the value of the "dhcp_enabled" field in the mutation. -func (m *NetworkAdapterMutation) DhcpEnabled() (r bool, exists bool) { - v := m.dhcp_enabled - if v == nil { - return + return v, fmt.Errorf("querying old value for OldPeersConnected: %w", err) } - return *v, true + return oldValue.PeersConnected, nil } -// OldDhcpEnabled returns the old "dhcp_enabled" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldDhcpEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDhcpEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDhcpEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDhcpEnabled: %w", err) +// AddPeersConnected adds i to the "peers_connected" field. +func (m *NetbirdMutation) AddPeersConnected(i int) { + if m.addpeers_connected != nil { + *m.addpeers_connected += i + } else { + m.addpeers_connected = &i } - return oldValue.DhcpEnabled, nil -} - -// ClearDhcpEnabled clears the value of the "dhcp_enabled" field. -func (m *NetworkAdapterMutation) ClearDhcpEnabled() { - m.dhcp_enabled = nil - m.clearedFields[networkadapter.FieldDhcpEnabled] = struct{}{} -} - -// DhcpEnabledCleared returns if the "dhcp_enabled" field was cleared in this mutation. -func (m *NetworkAdapterMutation) DhcpEnabledCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldDhcpEnabled] - return ok -} - -// ResetDhcpEnabled resets all changes to the "dhcp_enabled" field. -func (m *NetworkAdapterMutation) ResetDhcpEnabled() { - m.dhcp_enabled = nil - delete(m.clearedFields, networkadapter.FieldDhcpEnabled) -} - -// SetDhcpLeaseObtained sets the "dhcp_lease_obtained" field. -func (m *NetworkAdapterMutation) SetDhcpLeaseObtained(t time.Time) { - m.dhcp_lease_obtained = &t } -// DhcpLeaseObtained returns the value of the "dhcp_lease_obtained" field in the mutation. -func (m *NetworkAdapterMutation) DhcpLeaseObtained() (r time.Time, exists bool) { - v := m.dhcp_lease_obtained +// AddedPeersConnected returns the value that was added to the "peers_connected" field in this mutation. +func (m *NetbirdMutation) AddedPeersConnected() (r int, exists bool) { + v := m.addpeers_connected if v == nil { return } return *v, true } -// OldDhcpLeaseObtained returns the old "dhcp_lease_obtained" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldDhcpLeaseObtained(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDhcpLeaseObtained is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDhcpLeaseObtained requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDhcpLeaseObtained: %w", err) - } - return oldValue.DhcpLeaseObtained, nil -} - -// ClearDhcpLeaseObtained clears the value of the "dhcp_lease_obtained" field. -func (m *NetworkAdapterMutation) ClearDhcpLeaseObtained() { - m.dhcp_lease_obtained = nil - m.clearedFields[networkadapter.FieldDhcpLeaseObtained] = struct{}{} +// ClearPeersConnected clears the value of the "peers_connected" field. +func (m *NetbirdMutation) ClearPeersConnected() { + m.peers_connected = nil + m.addpeers_connected = nil + m.clearedFields[netbird.FieldPeersConnected] = struct{}{} } -// DhcpLeaseObtainedCleared returns if the "dhcp_lease_obtained" field was cleared in this mutation. -func (m *NetworkAdapterMutation) DhcpLeaseObtainedCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldDhcpLeaseObtained] +// PeersConnectedCleared returns if the "peers_connected" field was cleared in this mutation. +func (m *NetbirdMutation) PeersConnectedCleared() bool { + _, ok := m.clearedFields[netbird.FieldPeersConnected] return ok } -// ResetDhcpLeaseObtained resets all changes to the "dhcp_lease_obtained" field. -func (m *NetworkAdapterMutation) ResetDhcpLeaseObtained() { - m.dhcp_lease_obtained = nil - delete(m.clearedFields, networkadapter.FieldDhcpLeaseObtained) +// ResetPeersConnected resets all changes to the "peers_connected" field. +func (m *NetbirdMutation) ResetPeersConnected() { + m.peers_connected = nil + m.addpeers_connected = nil + delete(m.clearedFields, netbird.FieldPeersConnected) } -// SetDhcpLeaseExpired sets the "dhcp_lease_expired" field. -func (m *NetworkAdapterMutation) SetDhcpLeaseExpired(t time.Time) { - m.dhcp_lease_expired = &t +// SetProfilesAvailable sets the "profiles_available" field. +func (m *NetbirdMutation) SetProfilesAvailable(s string) { + m.profiles_available = &s } -// DhcpLeaseExpired returns the value of the "dhcp_lease_expired" field in the mutation. -func (m *NetworkAdapterMutation) DhcpLeaseExpired() (r time.Time, exists bool) { - v := m.dhcp_lease_expired +// ProfilesAvailable returns the value of the "profiles_available" field in the mutation. +func (m *NetbirdMutation) ProfilesAvailable() (r string, exists bool) { + v := m.profiles_available if v == nil { return } return *v, true } -// OldDhcpLeaseExpired returns the old "dhcp_lease_expired" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// OldProfilesAvailable returns the old "profiles_available" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldDhcpLeaseExpired(ctx context.Context) (v time.Time, err error) { +func (m *NetbirdMutation) OldProfilesAvailable(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDhcpLeaseExpired is only allowed on UpdateOne operations") + return v, errors.New("OldProfilesAvailable is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDhcpLeaseExpired requires an ID field in the mutation") + return v, errors.New("OldProfilesAvailable requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDhcpLeaseExpired: %w", err) + return v, fmt.Errorf("querying old value for OldProfilesAvailable: %w", err) } - return oldValue.DhcpLeaseExpired, nil + return oldValue.ProfilesAvailable, nil } -// ClearDhcpLeaseExpired clears the value of the "dhcp_lease_expired" field. -func (m *NetworkAdapterMutation) ClearDhcpLeaseExpired() { - m.dhcp_lease_expired = nil - m.clearedFields[networkadapter.FieldDhcpLeaseExpired] = struct{}{} +// ClearProfilesAvailable clears the value of the "profiles_available" field. +func (m *NetbirdMutation) ClearProfilesAvailable() { + m.profiles_available = nil + m.clearedFields[netbird.FieldProfilesAvailable] = struct{}{} } -// DhcpLeaseExpiredCleared returns if the "dhcp_lease_expired" field was cleared in this mutation. -func (m *NetworkAdapterMutation) DhcpLeaseExpiredCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldDhcpLeaseExpired] +// ProfilesAvailableCleared returns if the "profiles_available" field was cleared in this mutation. +func (m *NetbirdMutation) ProfilesAvailableCleared() bool { + _, ok := m.clearedFields[netbird.FieldProfilesAvailable] return ok } -// ResetDhcpLeaseExpired resets all changes to the "dhcp_lease_expired" field. -func (m *NetworkAdapterMutation) ResetDhcpLeaseExpired() { - m.dhcp_lease_expired = nil - delete(m.clearedFields, networkadapter.FieldDhcpLeaseExpired) -} - -// SetSpeed sets the "speed" field. -func (m *NetworkAdapterMutation) SetSpeed(s string) { - m.speed = &s -} - -// Speed returns the value of the "speed" field in the mutation. -func (m *NetworkAdapterMutation) Speed() (r string, exists bool) { - v := m.speed - if v == nil { - return - } - return *v, true -} - -// OldSpeed returns the old "speed" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldSpeed(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSpeed is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSpeed requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSpeed: %w", err) - } - return oldValue.Speed, nil -} - -// ResetSpeed resets all changes to the "speed" field. -func (m *NetworkAdapterMutation) ResetSpeed() { - m.speed = nil +// ResetProfilesAvailable resets all changes to the "profiles_available" field. +func (m *NetbirdMutation) ResetProfilesAvailable() { + m.profiles_available = nil + delete(m.clearedFields, netbird.FieldProfilesAvailable) } -// SetVirtual sets the "virtual" field. -func (m *NetworkAdapterMutation) SetVirtual(b bool) { - m.virtual = &b +// SetDNSServer sets the "dns_server" field. +func (m *NetbirdMutation) SetDNSServer(s string) { + m.dns_server = &s } -// Virtual returns the value of the "virtual" field in the mutation. -func (m *NetworkAdapterMutation) Virtual() (r bool, exists bool) { - v := m.virtual +// DNSServer returns the value of the "dns_server" field in the mutation. +func (m *NetbirdMutation) DNSServer() (r string, exists bool) { + v := m.dns_server if v == nil { return } return *v, true } -// OldVirtual returns the old "virtual" field's value of the NetworkAdapter entity. -// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// OldDNSServer returns the old "dns_server" field's value of the Netbird entity. +// If the Netbird object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkAdapterMutation) OldVirtual(ctx context.Context) (v bool, err error) { +func (m *NetbirdMutation) OldDNSServer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVirtual is only allowed on UpdateOne operations") + return v, errors.New("OldDNSServer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVirtual requires an ID field in the mutation") + return v, errors.New("OldDNSServer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVirtual: %w", err) + return v, fmt.Errorf("querying old value for OldDNSServer: %w", err) } - return oldValue.Virtual, nil + return oldValue.DNSServer, nil } -// ClearVirtual clears the value of the "virtual" field. -func (m *NetworkAdapterMutation) ClearVirtual() { - m.virtual = nil - m.clearedFields[networkadapter.FieldVirtual] = struct{}{} +// ClearDNSServer clears the value of the "dns_server" field. +func (m *NetbirdMutation) ClearDNSServer() { + m.dns_server = nil + m.clearedFields[netbird.FieldDNSServer] = struct{}{} } -// VirtualCleared returns if the "virtual" field was cleared in this mutation. -func (m *NetworkAdapterMutation) VirtualCleared() bool { - _, ok := m.clearedFields[networkadapter.FieldVirtual] +// DNSServerCleared returns if the "dns_server" field was cleared in this mutation. +func (m *NetbirdMutation) DNSServerCleared() bool { + _, ok := m.clearedFields[netbird.FieldDNSServer] return ok } -// ResetVirtual resets all changes to the "virtual" field. -func (m *NetworkAdapterMutation) ResetVirtual() { - m.virtual = nil - delete(m.clearedFields, networkadapter.FieldVirtual) +// ResetDNSServer resets all changes to the "dns_server" field. +func (m *NetbirdMutation) ResetDNSServer() { + m.dns_server = nil + delete(m.clearedFields, netbird.FieldDNSServer) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *NetworkAdapterMutation) SetOwnerID(id string) { +func (m *NetbirdMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *NetworkAdapterMutation) ClearOwner() { +func (m *NetbirdMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *NetworkAdapterMutation) OwnerCleared() bool { +func (m *NetbirdMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *NetworkAdapterMutation) OwnerID() (id string, exists bool) { +func (m *NetbirdMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -14007,7 +14482,7 @@ func (m *NetworkAdapterMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *NetworkAdapterMutation) OwnerIDs() (ids []string) { +func (m *NetbirdMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -14015,20 +14490,20 @@ func (m *NetworkAdapterMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *NetworkAdapterMutation) ResetOwner() { +func (m *NetbirdMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the NetworkAdapterMutation builder. -func (m *NetworkAdapterMutation) Where(ps ...predicate.NetworkAdapter) { +// Where appends a list predicates to the NetbirdMutation builder. +func (m *NetbirdMutation) Where(ps ...predicate.Netbird) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the NetworkAdapterMutation builder. Using this method, +// WhereP appends storage-level predicates to the NetbirdMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *NetworkAdapterMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.NetworkAdapter, len(ps)) +func (m *NetbirdMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Netbird, len(ps)) for i := range ps { p[i] = ps[i] } @@ -14036,60 +14511,66 @@ func (m *NetworkAdapterMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *NetworkAdapterMutation) Op() Op { +func (m *NetbirdMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *NetworkAdapterMutation) SetOp(op Op) { +func (m *NetbirdMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (NetworkAdapter). -func (m *NetworkAdapterMutation) Type() string { +// Type returns the node type of this mutation (Netbird). +func (m *NetbirdMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *NetworkAdapterMutation) Fields() []string { - fields := make([]string, 0, 12) - if m.name != nil { - fields = append(fields, networkadapter.FieldName) +func (m *NetbirdMutation) Fields() []string { + fields := make([]string, 0, 14) + if m.version != nil { + fields = append(fields, netbird.FieldVersion) } - if m.mac_address != nil { - fields = append(fields, networkadapter.FieldMACAddress) + if m.installed != nil { + fields = append(fields, netbird.FieldInstalled) } - if m.addresses != nil { - fields = append(fields, networkadapter.FieldAddresses) + if m.service_status != nil { + fields = append(fields, netbird.FieldServiceStatus) } - if m.subnet != nil { - fields = append(fields, networkadapter.FieldSubnet) + if m.ip != nil { + fields = append(fields, netbird.FieldIP) } - if m.default_gateway != nil { - fields = append(fields, networkadapter.FieldDefaultGateway) + if m.profile != nil { + fields = append(fields, netbird.FieldProfile) } - if m.dns_servers != nil { - fields = append(fields, networkadapter.FieldDNSServers) + if m.management_url != nil { + fields = append(fields, netbird.FieldManagementURL) } - if m.dns_domain != nil { - fields = append(fields, networkadapter.FieldDNSDomain) + if m.management_connected != nil { + fields = append(fields, netbird.FieldManagementConnected) } - if m.dhcp_enabled != nil { - fields = append(fields, networkadapter.FieldDhcpEnabled) + if m.signal_url != nil { + fields = append(fields, netbird.FieldSignalURL) } - if m.dhcp_lease_obtained != nil { - fields = append(fields, networkadapter.FieldDhcpLeaseObtained) + if m.signal_connected != nil { + fields = append(fields, netbird.FieldSignalConnected) } - if m.dhcp_lease_expired != nil { - fields = append(fields, networkadapter.FieldDhcpLeaseExpired) + if m.ssh_enabled != nil { + fields = append(fields, netbird.FieldSSHEnabled) } - if m.speed != nil { - fields = append(fields, networkadapter.FieldSpeed) + if m.peers_total != nil { + fields = append(fields, netbird.FieldPeersTotal) } - if m.virtual != nil { - fields = append(fields, networkadapter.FieldVirtual) + if m.peers_connected != nil { + fields = append(fields, netbird.FieldPeersConnected) + } + if m.profiles_available != nil { + fields = append(fields, netbird.FieldProfilesAvailable) + } + if m.dns_server != nil { + fields = append(fields, netbird.FieldDNSServer) } return fields } @@ -14097,32 +14578,36 @@ func (m *NetworkAdapterMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *NetworkAdapterMutation) Field(name string) (ent.Value, bool) { +func (m *NetbirdMutation) Field(name string) (ent.Value, bool) { switch name { - case networkadapter.FieldName: - return m.Name() - case networkadapter.FieldMACAddress: - return m.MACAddress() - case networkadapter.FieldAddresses: - return m.Addresses() - case networkadapter.FieldSubnet: - return m.Subnet() - case networkadapter.FieldDefaultGateway: - return m.DefaultGateway() - case networkadapter.FieldDNSServers: - return m.DNSServers() - case networkadapter.FieldDNSDomain: - return m.DNSDomain() - case networkadapter.FieldDhcpEnabled: - return m.DhcpEnabled() - case networkadapter.FieldDhcpLeaseObtained: - return m.DhcpLeaseObtained() - case networkadapter.FieldDhcpLeaseExpired: - return m.DhcpLeaseExpired() - case networkadapter.FieldSpeed: - return m.Speed() - case networkadapter.FieldVirtual: - return m.Virtual() + case netbird.FieldVersion: + return m.Version() + case netbird.FieldInstalled: + return m.Installed() + case netbird.FieldServiceStatus: + return m.ServiceStatus() + case netbird.FieldIP: + return m.IP() + case netbird.FieldProfile: + return m.Profile() + case netbird.FieldManagementURL: + return m.ManagementURL() + case netbird.FieldManagementConnected: + return m.ManagementConnected() + case netbird.FieldSignalURL: + return m.SignalURL() + case netbird.FieldSignalConnected: + return m.SignalConnected() + case netbird.FieldSSHEnabled: + return m.SSHEnabled() + case netbird.FieldPeersTotal: + return m.PeersTotal() + case netbird.FieldPeersConnected: + return m.PeersConnected() + case netbird.FieldProfilesAvailable: + return m.ProfilesAvailable() + case netbird.FieldDNSServer: + return m.DNSServer() } return nil, false } @@ -14130,279 +14615,330 @@ func (m *NetworkAdapterMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *NetworkAdapterMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *NetbirdMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case networkadapter.FieldName: - return m.OldName(ctx) - case networkadapter.FieldMACAddress: - return m.OldMACAddress(ctx) - case networkadapter.FieldAddresses: - return m.OldAddresses(ctx) - case networkadapter.FieldSubnet: - return m.OldSubnet(ctx) - case networkadapter.FieldDefaultGateway: - return m.OldDefaultGateway(ctx) - case networkadapter.FieldDNSServers: - return m.OldDNSServers(ctx) - case networkadapter.FieldDNSDomain: - return m.OldDNSDomain(ctx) - case networkadapter.FieldDhcpEnabled: - return m.OldDhcpEnabled(ctx) - case networkadapter.FieldDhcpLeaseObtained: - return m.OldDhcpLeaseObtained(ctx) - case networkadapter.FieldDhcpLeaseExpired: - return m.OldDhcpLeaseExpired(ctx) - case networkadapter.FieldSpeed: - return m.OldSpeed(ctx) - case networkadapter.FieldVirtual: - return m.OldVirtual(ctx) + case netbird.FieldVersion: + return m.OldVersion(ctx) + case netbird.FieldInstalled: + return m.OldInstalled(ctx) + case netbird.FieldServiceStatus: + return m.OldServiceStatus(ctx) + case netbird.FieldIP: + return m.OldIP(ctx) + case netbird.FieldProfile: + return m.OldProfile(ctx) + case netbird.FieldManagementURL: + return m.OldManagementURL(ctx) + case netbird.FieldManagementConnected: + return m.OldManagementConnected(ctx) + case netbird.FieldSignalURL: + return m.OldSignalURL(ctx) + case netbird.FieldSignalConnected: + return m.OldSignalConnected(ctx) + case netbird.FieldSSHEnabled: + return m.OldSSHEnabled(ctx) + case netbird.FieldPeersTotal: + return m.OldPeersTotal(ctx) + case netbird.FieldPeersConnected: + return m.OldPeersConnected(ctx) + case netbird.FieldProfilesAvailable: + return m.OldProfilesAvailable(ctx) + case netbird.FieldDNSServer: + return m.OldDNSServer(ctx) } - return nil, fmt.Errorf("unknown NetworkAdapter field %s", name) + return nil, fmt.Errorf("unknown Netbird field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NetworkAdapterMutation) SetField(name string, value ent.Value) error { +func (m *NetbirdMutation) SetField(name string, value ent.Value) error { switch name { - case networkadapter.FieldName: + case netbird.FieldVersion: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetVersion(v) return nil - case networkadapter.FieldMACAddress: - v, ok := value.(string) + case netbird.FieldInstalled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetMACAddress(v) + m.SetInstalled(v) return nil - case networkadapter.FieldAddresses: + case netbird.FieldServiceStatus: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAddresses(v) + m.SetServiceStatus(v) return nil - case networkadapter.FieldSubnet: + case netbird.FieldIP: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSubnet(v) + m.SetIP(v) return nil - case networkadapter.FieldDefaultGateway: + case netbird.FieldProfile: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDefaultGateway(v) + m.SetProfile(v) return nil - case networkadapter.FieldDNSServers: + case netbird.FieldManagementURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDNSServers(v) + m.SetManagementURL(v) return nil - case networkadapter.FieldDNSDomain: + case netbird.FieldManagementConnected: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetManagementConnected(v) + return nil + case netbird.FieldSignalURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDNSDomain(v) + m.SetSignalURL(v) return nil - case networkadapter.FieldDhcpEnabled: + case netbird.FieldSignalConnected: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDhcpEnabled(v) + m.SetSignalConnected(v) return nil - case networkadapter.FieldDhcpLeaseObtained: - v, ok := value.(time.Time) + case netbird.FieldSSHEnabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDhcpLeaseObtained(v) + m.SetSSHEnabled(v) return nil - case networkadapter.FieldDhcpLeaseExpired: - v, ok := value.(time.Time) + case netbird.FieldPeersTotal: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDhcpLeaseExpired(v) + m.SetPeersTotal(v) return nil - case networkadapter.FieldSpeed: + case netbird.FieldPeersConnected: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPeersConnected(v) + return nil + case netbird.FieldProfilesAvailable: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSpeed(v) + m.SetProfilesAvailable(v) return nil - case networkadapter.FieldVirtual: - v, ok := value.(bool) + case netbird.FieldDNSServer: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVirtual(v) + m.SetDNSServer(v) return nil } - return fmt.Errorf("unknown NetworkAdapter field %s", name) + return fmt.Errorf("unknown Netbird field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *NetworkAdapterMutation) AddedFields() []string { - return nil +func (m *NetbirdMutation) AddedFields() []string { + var fields []string + if m.addpeers_total != nil { + fields = append(fields, netbird.FieldPeersTotal) + } + if m.addpeers_connected != nil { + fields = append(fields, netbird.FieldPeersConnected) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *NetworkAdapterMutation) AddedField(name string) (ent.Value, bool) { +func (m *NetbirdMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case netbird.FieldPeersTotal: + return m.AddedPeersTotal() + case netbird.FieldPeersConnected: + return m.AddedPeersConnected() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *NetworkAdapterMutation) AddField(name string, value ent.Value) error { +func (m *NetbirdMutation) AddField(name string, value ent.Value) error { switch name { + case netbird.FieldPeersTotal: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPeersTotal(v) + return nil + case netbird.FieldPeersConnected: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPeersConnected(v) + return nil } - return fmt.Errorf("unknown NetworkAdapter numeric field %s", name) + return fmt.Errorf("unknown Netbird numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *NetworkAdapterMutation) ClearedFields() []string { +func (m *NetbirdMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(networkadapter.FieldSubnet) { - fields = append(fields, networkadapter.FieldSubnet) + if m.FieldCleared(netbird.FieldIP) { + fields = append(fields, netbird.FieldIP) } - if m.FieldCleared(networkadapter.FieldDefaultGateway) { - fields = append(fields, networkadapter.FieldDefaultGateway) + if m.FieldCleared(netbird.FieldProfile) { + fields = append(fields, netbird.FieldProfile) } - if m.FieldCleared(networkadapter.FieldDNSServers) { - fields = append(fields, networkadapter.FieldDNSServers) + if m.FieldCleared(netbird.FieldManagementURL) { + fields = append(fields, netbird.FieldManagementURL) } - if m.FieldCleared(networkadapter.FieldDNSDomain) { - fields = append(fields, networkadapter.FieldDNSDomain) + if m.FieldCleared(netbird.FieldSignalURL) { + fields = append(fields, netbird.FieldSignalURL) } - if m.FieldCleared(networkadapter.FieldDhcpEnabled) { - fields = append(fields, networkadapter.FieldDhcpEnabled) + if m.FieldCleared(netbird.FieldPeersTotal) { + fields = append(fields, netbird.FieldPeersTotal) } - if m.FieldCleared(networkadapter.FieldDhcpLeaseObtained) { - fields = append(fields, networkadapter.FieldDhcpLeaseObtained) + if m.FieldCleared(netbird.FieldPeersConnected) { + fields = append(fields, netbird.FieldPeersConnected) } - if m.FieldCleared(networkadapter.FieldDhcpLeaseExpired) { - fields = append(fields, networkadapter.FieldDhcpLeaseExpired) + if m.FieldCleared(netbird.FieldProfilesAvailable) { + fields = append(fields, netbird.FieldProfilesAvailable) } - if m.FieldCleared(networkadapter.FieldVirtual) { - fields = append(fields, networkadapter.FieldVirtual) + if m.FieldCleared(netbird.FieldDNSServer) { + fields = append(fields, netbird.FieldDNSServer) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *NetworkAdapterMutation) FieldCleared(name string) bool { +func (m *NetbirdMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *NetworkAdapterMutation) ClearField(name string) error { +func (m *NetbirdMutation) ClearField(name string) error { switch name { - case networkadapter.FieldSubnet: - m.ClearSubnet() + case netbird.FieldIP: + m.ClearIP() return nil - case networkadapter.FieldDefaultGateway: - m.ClearDefaultGateway() + case netbird.FieldProfile: + m.ClearProfile() return nil - case networkadapter.FieldDNSServers: - m.ClearDNSServers() + case netbird.FieldManagementURL: + m.ClearManagementURL() return nil - case networkadapter.FieldDNSDomain: - m.ClearDNSDomain() + case netbird.FieldSignalURL: + m.ClearSignalURL() return nil - case networkadapter.FieldDhcpEnabled: - m.ClearDhcpEnabled() + case netbird.FieldPeersTotal: + m.ClearPeersTotal() return nil - case networkadapter.FieldDhcpLeaseObtained: - m.ClearDhcpLeaseObtained() + case netbird.FieldPeersConnected: + m.ClearPeersConnected() return nil - case networkadapter.FieldDhcpLeaseExpired: - m.ClearDhcpLeaseExpired() + case netbird.FieldProfilesAvailable: + m.ClearProfilesAvailable() return nil - case networkadapter.FieldVirtual: - m.ClearVirtual() + case netbird.FieldDNSServer: + m.ClearDNSServer() return nil } - return fmt.Errorf("unknown NetworkAdapter nullable field %s", name) + return fmt.Errorf("unknown Netbird nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *NetworkAdapterMutation) ResetField(name string) error { +func (m *NetbirdMutation) ResetField(name string) error { switch name { - case networkadapter.FieldName: - m.ResetName() + case netbird.FieldVersion: + m.ResetVersion() return nil - case networkadapter.FieldMACAddress: - m.ResetMACAddress() + case netbird.FieldInstalled: + m.ResetInstalled() return nil - case networkadapter.FieldAddresses: - m.ResetAddresses() + case netbird.FieldServiceStatus: + m.ResetServiceStatus() return nil - case networkadapter.FieldSubnet: - m.ResetSubnet() + case netbird.FieldIP: + m.ResetIP() return nil - case networkadapter.FieldDefaultGateway: - m.ResetDefaultGateway() + case netbird.FieldProfile: + m.ResetProfile() return nil - case networkadapter.FieldDNSServers: - m.ResetDNSServers() + case netbird.FieldManagementURL: + m.ResetManagementURL() return nil - case networkadapter.FieldDNSDomain: - m.ResetDNSDomain() + case netbird.FieldManagementConnected: + m.ResetManagementConnected() return nil - case networkadapter.FieldDhcpEnabled: - m.ResetDhcpEnabled() + case netbird.FieldSignalURL: + m.ResetSignalURL() return nil - case networkadapter.FieldDhcpLeaseObtained: - m.ResetDhcpLeaseObtained() + case netbird.FieldSignalConnected: + m.ResetSignalConnected() return nil - case networkadapter.FieldDhcpLeaseExpired: - m.ResetDhcpLeaseExpired() + case netbird.FieldSSHEnabled: + m.ResetSSHEnabled() return nil - case networkadapter.FieldSpeed: - m.ResetSpeed() + case netbird.FieldPeersTotal: + m.ResetPeersTotal() return nil - case networkadapter.FieldVirtual: - m.ResetVirtual() + case netbird.FieldPeersConnected: + m.ResetPeersConnected() + return nil + case netbird.FieldProfilesAvailable: + m.ResetProfilesAvailable() + return nil + case netbird.FieldDNSServer: + m.ResetDNSServer() return nil } - return fmt.Errorf("unknown NetworkAdapter field %s", name) + return fmt.Errorf("unknown Netbird field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *NetworkAdapterMutation) AddedEdges() []string { +func (m *NetbirdMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, networkadapter.EdgeOwner) + edges = append(edges, netbird.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *NetworkAdapterMutation) AddedIDs(name string) []ent.Value { +func (m *NetbirdMutation) AddedIDs(name string) []ent.Value { switch name { - case networkadapter.EdgeOwner: + case netbird.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -14411,31 +14947,31 @@ func (m *NetworkAdapterMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *NetworkAdapterMutation) RemovedEdges() []string { +func (m *NetbirdMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *NetworkAdapterMutation) RemovedIDs(name string) []ent.Value { +func (m *NetbirdMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NetworkAdapterMutation) ClearedEdges() []string { +func (m *NetbirdMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, networkadapter.EdgeOwner) + edges = append(edges, netbird.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *NetworkAdapterMutation) EdgeCleared(name string) bool { +func (m *NetbirdMutation) EdgeCleared(name string) bool { switch name { - case networkadapter.EdgeOwner: + case netbird.EdgeOwner: return m.clearedowner } return false @@ -14443,60 +14979,54 @@ func (m *NetworkAdapterMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *NetworkAdapterMutation) ClearEdge(name string) error { +func (m *NetbirdMutation) ClearEdge(name string) error { switch name { - case networkadapter.EdgeOwner: + case netbird.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown NetworkAdapter unique edge %s", name) + return fmt.Errorf("unknown Netbird unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *NetworkAdapterMutation) ResetEdge(name string) error { +func (m *NetbirdMutation) ResetEdge(name string) error { switch name { - case networkadapter.EdgeOwner: + case netbird.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown NetworkAdapter edge %s", name) + return fmt.Errorf("unknown Netbird edge %s", name) } -// OperatingSystemMutation represents an operation that mutates the OperatingSystem nodes in the graph. -type OperatingSystemMutation struct { +// NetbirdSettingsMutation represents an operation that mutates the NetbirdSettings nodes in the graph. +type NetbirdSettingsMutation struct { config - op Op - typ string - id *int - _type *string - version *string - description *string - edition *string - install_date *time.Time - arch *string - username *string - last_bootup_time *time.Time - domain *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*OperatingSystem, error) - predicates []predicate.OperatingSystem + op Op + typ string + id *int + management_url *string + access_token *string + clearedFields map[string]struct{} + tenant map[int]struct{} + removedtenant map[int]struct{} + clearedtenant bool + done bool + oldValue func(context.Context) (*NetbirdSettings, error) + predicates []predicate.NetbirdSettings } -var _ ent.Mutation = (*OperatingSystemMutation)(nil) +var _ ent.Mutation = (*NetbirdSettingsMutation)(nil) -// operatingsystemOption allows management of the mutation configuration using functional options. -type operatingsystemOption func(*OperatingSystemMutation) +// netbirdsettingsOption allows management of the mutation configuration using functional options. +type netbirdsettingsOption func(*NetbirdSettingsMutation) -// newOperatingSystemMutation creates new mutation for the OperatingSystem entity. -func newOperatingSystemMutation(c config, op Op, opts ...operatingsystemOption) *OperatingSystemMutation { - m := &OperatingSystemMutation{ +// newNetbirdSettingsMutation creates new mutation for the NetbirdSettings entity. +func newNetbirdSettingsMutation(c config, op Op, opts ...netbirdsettingsOption) *NetbirdSettingsMutation { + m := &NetbirdSettingsMutation{ config: c, op: op, - typ: TypeOperatingSystem, + typ: TypeNetbirdSettings, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -14505,20 +15035,20 @@ func newOperatingSystemMutation(c config, op Op, opts ...operatingsystemOption) return m } -// withOperatingSystemID sets the ID field of the mutation. -func withOperatingSystemID(id int) operatingsystemOption { - return func(m *OperatingSystemMutation) { +// withNetbirdSettingsID sets the ID field of the mutation. +func withNetbirdSettingsID(id int) netbirdsettingsOption { + return func(m *NetbirdSettingsMutation) { var ( err error once sync.Once - value *OperatingSystem + value *NetbirdSettings ) - m.oldValue = func(ctx context.Context) (*OperatingSystem, error) { + m.oldValue = func(ctx context.Context) (*NetbirdSettings, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().OperatingSystem.Get(ctx, id) + value, err = m.Client().NetbirdSettings.Get(ctx, id) } }) return value, err @@ -14527,10 +15057,10 @@ func withOperatingSystemID(id int) operatingsystemOption { } } -// withOperatingSystem sets the old OperatingSystem of the mutation. -func withOperatingSystem(node *OperatingSystem) operatingsystemOption { - return func(m *OperatingSystemMutation) { - m.oldValue = func(context.Context) (*OperatingSystem, error) { +// withNetbirdSettings sets the old NetbirdSettings of the mutation. +func withNetbirdSettings(node *NetbirdSettings) netbirdsettingsOption { + return func(m *NetbirdSettingsMutation) { + m.oldValue = func(context.Context) (*NetbirdSettings, error) { return node, nil } m.id = &node.ID @@ -14539,7 +15069,7 @@ func withOperatingSystem(node *OperatingSystem) operatingsystemOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m OperatingSystemMutation) Client() *Client { +func (m NetbirdSettingsMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -14547,7 +15077,7 @@ func (m OperatingSystemMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m OperatingSystemMutation) Tx() (*Tx, error) { +func (m NetbirdSettingsMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -14558,7 +15088,7 @@ func (m OperatingSystemMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *OperatingSystemMutation) ID() (id int, exists bool) { +func (m *NetbirdSettingsMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -14569,7 +15099,7 @@ func (m *OperatingSystemMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *OperatingSystemMutation) IDs(ctx context.Context) ([]int, error) { +func (m *NetbirdSettingsMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -14578,462 +15108,173 @@ func (m *OperatingSystemMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().OperatingSystem.Query().Where(m.predicates...).IDs(ctx) + return m.Client().NetbirdSettings.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetType sets the "type" field. -func (m *OperatingSystemMutation) SetType(s string) { - m._type = &s +// SetManagementURL sets the "management_url" field. +func (m *NetbirdSettingsMutation) SetManagementURL(s string) { + m.management_url = &s } -// GetType returns the value of the "type" field in the mutation. -func (m *OperatingSystemMutation) GetType() (r string, exists bool) { - v := m._type +// ManagementURL returns the value of the "management_url" field in the mutation. +func (m *NetbirdSettingsMutation) ManagementURL() (r string, exists bool) { + v := m.management_url if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. +// OldManagementURL returns the old "management_url" field's value of the NetbirdSettings entity. +// If the NetbirdSettings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldType(ctx context.Context) (v string, err error) { +func (m *NetbirdSettingsMutation) OldManagementURL(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldManagementURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldManagementURL requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldManagementURL: %w", err) } - return oldValue.Type, nil + return oldValue.ManagementURL, nil } -// ClearType clears the value of the "type" field. -func (m *OperatingSystemMutation) ClearType() { - m._type = nil - m.clearedFields[operatingsystem.FieldType] = struct{}{} +// ClearManagementURL clears the value of the "management_url" field. +func (m *NetbirdSettingsMutation) ClearManagementURL() { + m.management_url = nil + m.clearedFields[netbirdsettings.FieldManagementURL] = struct{}{} } -// TypeCleared returns if the "type" field was cleared in this mutation. -func (m *OperatingSystemMutation) TypeCleared() bool { - _, ok := m.clearedFields[operatingsystem.FieldType] +// ManagementURLCleared returns if the "management_url" field was cleared in this mutation. +func (m *NetbirdSettingsMutation) ManagementURLCleared() bool { + _, ok := m.clearedFields[netbirdsettings.FieldManagementURL] return ok } -// ResetType resets all changes to the "type" field. -func (m *OperatingSystemMutation) ResetType() { - m._type = nil - delete(m.clearedFields, operatingsystem.FieldType) +// ResetManagementURL resets all changes to the "management_url" field. +func (m *NetbirdSettingsMutation) ResetManagementURL() { + m.management_url = nil + delete(m.clearedFields, netbirdsettings.FieldManagementURL) } -// SetVersion sets the "version" field. -func (m *OperatingSystemMutation) SetVersion(s string) { - m.version = &s +// SetAccessToken sets the "access_token" field. +func (m *NetbirdSettingsMutation) SetAccessToken(s string) { + m.access_token = &s } -// Version returns the value of the "version" field in the mutation. -func (m *OperatingSystemMutation) Version() (r string, exists bool) { - v := m.version +// AccessToken returns the value of the "access_token" field in the mutation. +func (m *NetbirdSettingsMutation) AccessToken() (r string, exists bool) { + v := m.access_token if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. +// OldAccessToken returns the old "access_token" field's value of the NetbirdSettings entity. +// If the NetbirdSettings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldVersion(ctx context.Context) (v string, err error) { +func (m *NetbirdSettingsMutation) OldAccessToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldAccessToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) + return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) } - return oldValue.Version, nil + return oldValue.AccessToken, nil } -// ResetVersion resets all changes to the "version" field. -func (m *OperatingSystemMutation) ResetVersion() { - m.version = nil +// ClearAccessToken clears the value of the "access_token" field. +func (m *NetbirdSettingsMutation) ClearAccessToken() { + m.access_token = nil + m.clearedFields[netbirdsettings.FieldAccessToken] = struct{}{} } -// SetDescription sets the "description" field. -func (m *OperatingSystemMutation) SetDescription(s string) { - m.description = &s +// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. +func (m *NetbirdSettingsMutation) AccessTokenCleared() bool { + _, ok := m.clearedFields[netbirdsettings.FieldAccessToken] + return ok } -// Description returns the value of the "description" field in the mutation. -func (m *OperatingSystemMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true +// ResetAccessToken resets all changes to the "access_token" field. +func (m *NetbirdSettingsMutation) ResetAccessToken() { + m.access_token = nil + delete(m.clearedFields, netbirdsettings.FieldAccessToken) } -// OldDescription returns the old "description" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") +// AddTenantIDs adds the "tenant" edge to the Tenant entity by ids. +func (m *NetbirdSettingsMutation) AddTenantIDs(ids ...int) { + if m.tenant == nil { + m.tenant = make(map[int]struct{}) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + for i := range ids { + m.tenant[ids[i]] = struct{}{} } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *OperatingSystemMutation) ResetDescription() { - m.description = nil -} - -// SetEdition sets the "edition" field. -func (m *OperatingSystemMutation) SetEdition(s string) { - m.edition = &s -} - -// Edition returns the value of the "edition" field in the mutation. -func (m *OperatingSystemMutation) Edition() (r string, exists bool) { - v := m.edition - if v == nil { - return - } - return *v, true -} - -// OldEdition returns the old "edition" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldEdition(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEdition is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEdition requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEdition: %w", err) - } - return oldValue.Edition, nil -} - -// ClearEdition clears the value of the "edition" field. -func (m *OperatingSystemMutation) ClearEdition() { - m.edition = nil - m.clearedFields[operatingsystem.FieldEdition] = struct{}{} -} - -// EditionCleared returns if the "edition" field was cleared in this mutation. -func (m *OperatingSystemMutation) EditionCleared() bool { - _, ok := m.clearedFields[operatingsystem.FieldEdition] - return ok -} - -// ResetEdition resets all changes to the "edition" field. -func (m *OperatingSystemMutation) ResetEdition() { - m.edition = nil - delete(m.clearedFields, operatingsystem.FieldEdition) -} - -// SetInstallDate sets the "install_date" field. -func (m *OperatingSystemMutation) SetInstallDate(t time.Time) { - m.install_date = &t -} - -// InstallDate returns the value of the "install_date" field in the mutation. -func (m *OperatingSystemMutation) InstallDate() (r time.Time, exists bool) { - v := m.install_date - if v == nil { - return - } - return *v, true -} - -// OldInstallDate returns the old "install_date" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldInstallDate(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInstallDate is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInstallDate requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldInstallDate: %w", err) - } - return oldValue.InstallDate, nil -} - -// ClearInstallDate clears the value of the "install_date" field. -func (m *OperatingSystemMutation) ClearInstallDate() { - m.install_date = nil - m.clearedFields[operatingsystem.FieldInstallDate] = struct{}{} -} - -// InstallDateCleared returns if the "install_date" field was cleared in this mutation. -func (m *OperatingSystemMutation) InstallDateCleared() bool { - _, ok := m.clearedFields[operatingsystem.FieldInstallDate] - return ok -} - -// ResetInstallDate resets all changes to the "install_date" field. -func (m *OperatingSystemMutation) ResetInstallDate() { - m.install_date = nil - delete(m.clearedFields, operatingsystem.FieldInstallDate) -} - -// SetArch sets the "arch" field. -func (m *OperatingSystemMutation) SetArch(s string) { - m.arch = &s -} - -// Arch returns the value of the "arch" field in the mutation. -func (m *OperatingSystemMutation) Arch() (r string, exists bool) { - v := m.arch - if v == nil { - return - } - return *v, true -} - -// OldArch returns the old "arch" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldArch(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArch is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArch requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArch: %w", err) - } - return oldValue.Arch, nil -} - -// ClearArch clears the value of the "arch" field. -func (m *OperatingSystemMutation) ClearArch() { - m.arch = nil - m.clearedFields[operatingsystem.FieldArch] = struct{}{} -} - -// ArchCleared returns if the "arch" field was cleared in this mutation. -func (m *OperatingSystemMutation) ArchCleared() bool { - _, ok := m.clearedFields[operatingsystem.FieldArch] - return ok -} - -// ResetArch resets all changes to the "arch" field. -func (m *OperatingSystemMutation) ResetArch() { - m.arch = nil - delete(m.clearedFields, operatingsystem.FieldArch) -} - -// SetUsername sets the "username" field. -func (m *OperatingSystemMutation) SetUsername(s string) { - m.username = &s -} - -// Username returns the value of the "username" field in the mutation. -func (m *OperatingSystemMutation) Username() (r string, exists bool) { - v := m.username - if v == nil { - return - } - return *v, true -} - -// OldUsername returns the old "username" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldUsername(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsername is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsername requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUsername: %w", err) - } - return oldValue.Username, nil -} - -// ResetUsername resets all changes to the "username" field. -func (m *OperatingSystemMutation) ResetUsername() { - m.username = nil -} - -// SetLastBootupTime sets the "last_bootup_time" field. -func (m *OperatingSystemMutation) SetLastBootupTime(t time.Time) { - m.last_bootup_time = &t -} - -// LastBootupTime returns the value of the "last_bootup_time" field in the mutation. -func (m *OperatingSystemMutation) LastBootupTime() (r time.Time, exists bool) { - v := m.last_bootup_time - if v == nil { - return - } - return *v, true -} - -// OldLastBootupTime returns the old "last_bootup_time" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldLastBootupTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastBootupTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastBootupTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastBootupTime: %w", err) - } - return oldValue.LastBootupTime, nil -} - -// ClearLastBootupTime clears the value of the "last_bootup_time" field. -func (m *OperatingSystemMutation) ClearLastBootupTime() { - m.last_bootup_time = nil - m.clearedFields[operatingsystem.FieldLastBootupTime] = struct{}{} -} - -// LastBootupTimeCleared returns if the "last_bootup_time" field was cleared in this mutation. -func (m *OperatingSystemMutation) LastBootupTimeCleared() bool { - _, ok := m.clearedFields[operatingsystem.FieldLastBootupTime] - return ok -} - -// ResetLastBootupTime resets all changes to the "last_bootup_time" field. -func (m *OperatingSystemMutation) ResetLastBootupTime() { - m.last_bootup_time = nil - delete(m.clearedFields, operatingsystem.FieldLastBootupTime) } -// SetDomain sets the "domain" field. -func (m *OperatingSystemMutation) SetDomain(s string) { - m.domain = &s +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *NetbirdSettingsMutation) ClearTenant() { + m.clearedtenant = true } -// Domain returns the value of the "domain" field in the mutation. -func (m *OperatingSystemMutation) Domain() (r string, exists bool) { - v := m.domain - if v == nil { - return - } - return *v, true +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *NetbirdSettingsMutation) TenantCleared() bool { + return m.clearedtenant } -// OldDomain returns the old "domain" field's value of the OperatingSystem entity. -// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OperatingSystemMutation) OldDomain(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDomain is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDomain requires an ID field in the mutation") +// RemoveTenantIDs removes the "tenant" edge to the Tenant entity by IDs. +func (m *NetbirdSettingsMutation) RemoveTenantIDs(ids ...int) { + if m.removedtenant == nil { + m.removedtenant = make(map[int]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDomain: %w", err) + for i := range ids { + delete(m.tenant, ids[i]) + m.removedtenant[ids[i]] = struct{}{} } - return oldValue.Domain, nil -} - -// ClearDomain clears the value of the "domain" field. -func (m *OperatingSystemMutation) ClearDomain() { - m.domain = nil - m.clearedFields[operatingsystem.FieldDomain] = struct{}{} -} - -// DomainCleared returns if the "domain" field was cleared in this mutation. -func (m *OperatingSystemMutation) DomainCleared() bool { - _, ok := m.clearedFields[operatingsystem.FieldDomain] - return ok -} - -// ResetDomain resets all changes to the "domain" field. -func (m *OperatingSystemMutation) ResetDomain() { - m.domain = nil - delete(m.clearedFields, operatingsystem.FieldDomain) -} - -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *OperatingSystemMutation) SetOwnerID(id string) { - m.owner = &id -} - -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *OperatingSystemMutation) ClearOwner() { - m.clearedowner = true -} - -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *OperatingSystemMutation) OwnerCleared() bool { - return m.clearedowner } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *OperatingSystemMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true +// RemovedTenant returns the removed IDs of the "tenant" edge to the Tenant entity. +func (m *NetbirdSettingsMutation) RemovedTenantIDs() (ids []int) { + for id := range m.removedtenant { + ids = append(ids, id) } return } -// OwnerIDs returns the "owner" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *OperatingSystemMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { - ids = append(ids, *id) +// TenantIDs returns the "tenant" edge IDs in the mutation. +func (m *NetbirdSettingsMutation) TenantIDs() (ids []int) { + for id := range m.tenant { + ids = append(ids, id) } return } -// ResetOwner resets all changes to the "owner" edge. -func (m *OperatingSystemMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ResetTenant resets all changes to the "tenant" edge. +func (m *NetbirdSettingsMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false + m.removedtenant = nil } -// Where appends a list predicates to the OperatingSystemMutation builder. -func (m *OperatingSystemMutation) Where(ps ...predicate.OperatingSystem) { +// Where appends a list predicates to the NetbirdSettingsMutation builder. +func (m *NetbirdSettingsMutation) Where(ps ...predicate.NetbirdSettings) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the OperatingSystemMutation builder. Using this method, +// WhereP appends storage-level predicates to the NetbirdSettingsMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *OperatingSystemMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.OperatingSystem, len(ps)) +func (m *NetbirdSettingsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.NetbirdSettings, len(ps)) for i := range ps { p[i] = ps[i] } @@ -15041,51 +15282,30 @@ func (m *OperatingSystemMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *OperatingSystemMutation) Op() Op { +func (m *NetbirdSettingsMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *OperatingSystemMutation) SetOp(op Op) { +func (m *NetbirdSettingsMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (OperatingSystem). -func (m *OperatingSystemMutation) Type() string { +// Type returns the node type of this mutation (NetbirdSettings). +func (m *NetbirdSettingsMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *OperatingSystemMutation) Fields() []string { - fields := make([]string, 0, 9) - if m._type != nil { - fields = append(fields, operatingsystem.FieldType) - } - if m.version != nil { - fields = append(fields, operatingsystem.FieldVersion) - } - if m.description != nil { - fields = append(fields, operatingsystem.FieldDescription) - } - if m.edition != nil { - fields = append(fields, operatingsystem.FieldEdition) - } - if m.install_date != nil { - fields = append(fields, operatingsystem.FieldInstallDate) - } - if m.arch != nil { - fields = append(fields, operatingsystem.FieldArch) - } - if m.username != nil { - fields = append(fields, operatingsystem.FieldUsername) - } - if m.last_bootup_time != nil { - fields = append(fields, operatingsystem.FieldLastBootupTime) +func (m *NetbirdSettingsMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.management_url != nil { + fields = append(fields, netbirdsettings.FieldManagementURL) } - if m.domain != nil { - fields = append(fields, operatingsystem.FieldDomain) + if m.access_token != nil { + fields = append(fields, netbirdsettings.FieldAccessToken) } return fields } @@ -15093,26 +15313,12 @@ func (m *OperatingSystemMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *OperatingSystemMutation) Field(name string) (ent.Value, bool) { +func (m *NetbirdSettingsMutation) Field(name string) (ent.Value, bool) { switch name { - case operatingsystem.FieldType: - return m.GetType() - case operatingsystem.FieldVersion: - return m.Version() - case operatingsystem.FieldDescription: - return m.Description() - case operatingsystem.FieldEdition: - return m.Edition() - case operatingsystem.FieldInstallDate: - return m.InstallDate() - case operatingsystem.FieldArch: - return m.Arch() - case operatingsystem.FieldUsername: - return m.Username() - case operatingsystem.FieldLastBootupTime: - return m.LastBootupTime() - case operatingsystem.FieldDomain: - return m.Domain() + case netbirdsettings.FieldManagementURL: + return m.ManagementURL() + case netbirdsettings.FieldAccessToken: + return m.AccessToken() } return nil, false } @@ -15120,321 +15326,230 @@ func (m *OperatingSystemMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *OperatingSystemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *NetbirdSettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case operatingsystem.FieldType: - return m.OldType(ctx) - case operatingsystem.FieldVersion: - return m.OldVersion(ctx) - case operatingsystem.FieldDescription: - return m.OldDescription(ctx) - case operatingsystem.FieldEdition: - return m.OldEdition(ctx) - case operatingsystem.FieldInstallDate: - return m.OldInstallDate(ctx) - case operatingsystem.FieldArch: - return m.OldArch(ctx) - case operatingsystem.FieldUsername: - return m.OldUsername(ctx) - case operatingsystem.FieldLastBootupTime: - return m.OldLastBootupTime(ctx) - case operatingsystem.FieldDomain: - return m.OldDomain(ctx) + case netbirdsettings.FieldManagementURL: + return m.OldManagementURL(ctx) + case netbirdsettings.FieldAccessToken: + return m.OldAccessToken(ctx) } - return nil, fmt.Errorf("unknown OperatingSystem field %s", name) + return nil, fmt.Errorf("unknown NetbirdSettings field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *OperatingSystemMutation) SetField(name string, value ent.Value) error { +func (m *NetbirdSettingsMutation) SetField(name string, value ent.Value) error { switch name { - case operatingsystem.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case operatingsystem.FieldVersion: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVersion(v) - return nil - case operatingsystem.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case operatingsystem.FieldEdition: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEdition(v) - return nil - case operatingsystem.FieldInstallDate: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetInstallDate(v) - return nil - case operatingsystem.FieldArch: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetArch(v) - return nil - case operatingsystem.FieldUsername: + case netbirdsettings.FieldManagementURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUsername(v) - return nil - case operatingsystem.FieldLastBootupTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastBootupTime(v) + m.SetManagementURL(v) return nil - case operatingsystem.FieldDomain: + case netbirdsettings.FieldAccessToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDomain(v) + m.SetAccessToken(v) return nil } - return fmt.Errorf("unknown OperatingSystem field %s", name) + return fmt.Errorf("unknown NetbirdSettings field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *OperatingSystemMutation) AddedFields() []string { +func (m *NetbirdSettingsMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *OperatingSystemMutation) AddedField(name string) (ent.Value, bool) { +func (m *NetbirdSettingsMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *OperatingSystemMutation) AddField(name string, value ent.Value) error { +func (m *NetbirdSettingsMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown OperatingSystem numeric field %s", name) + return fmt.Errorf("unknown NetbirdSettings numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *OperatingSystemMutation) ClearedFields() []string { +func (m *NetbirdSettingsMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(operatingsystem.FieldType) { - fields = append(fields, operatingsystem.FieldType) + if m.FieldCleared(netbirdsettings.FieldManagementURL) { + fields = append(fields, netbirdsettings.FieldManagementURL) } - if m.FieldCleared(operatingsystem.FieldEdition) { - fields = append(fields, operatingsystem.FieldEdition) - } - if m.FieldCleared(operatingsystem.FieldInstallDate) { - fields = append(fields, operatingsystem.FieldInstallDate) - } - if m.FieldCleared(operatingsystem.FieldArch) { - fields = append(fields, operatingsystem.FieldArch) - } - if m.FieldCleared(operatingsystem.FieldLastBootupTime) { - fields = append(fields, operatingsystem.FieldLastBootupTime) - } - if m.FieldCleared(operatingsystem.FieldDomain) { - fields = append(fields, operatingsystem.FieldDomain) + if m.FieldCleared(netbirdsettings.FieldAccessToken) { + fields = append(fields, netbirdsettings.FieldAccessToken) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *OperatingSystemMutation) FieldCleared(name string) bool { +func (m *NetbirdSettingsMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *OperatingSystemMutation) ClearField(name string) error { +func (m *NetbirdSettingsMutation) ClearField(name string) error { switch name { - case operatingsystem.FieldType: - m.ClearType() - return nil - case operatingsystem.FieldEdition: - m.ClearEdition() - return nil - case operatingsystem.FieldInstallDate: - m.ClearInstallDate() - return nil - case operatingsystem.FieldArch: - m.ClearArch() - return nil - case operatingsystem.FieldLastBootupTime: - m.ClearLastBootupTime() + case netbirdsettings.FieldManagementURL: + m.ClearManagementURL() return nil - case operatingsystem.FieldDomain: - m.ClearDomain() + case netbirdsettings.FieldAccessToken: + m.ClearAccessToken() return nil } - return fmt.Errorf("unknown OperatingSystem nullable field %s", name) + return fmt.Errorf("unknown NetbirdSettings nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *OperatingSystemMutation) ResetField(name string) error { +func (m *NetbirdSettingsMutation) ResetField(name string) error { switch name { - case operatingsystem.FieldType: - m.ResetType() - return nil - case operatingsystem.FieldVersion: - m.ResetVersion() - return nil - case operatingsystem.FieldDescription: - m.ResetDescription() - return nil - case operatingsystem.FieldEdition: - m.ResetEdition() - return nil - case operatingsystem.FieldInstallDate: - m.ResetInstallDate() - return nil - case operatingsystem.FieldArch: - m.ResetArch() - return nil - case operatingsystem.FieldUsername: - m.ResetUsername() - return nil - case operatingsystem.FieldLastBootupTime: - m.ResetLastBootupTime() + case netbirdsettings.FieldManagementURL: + m.ResetManagementURL() return nil - case operatingsystem.FieldDomain: - m.ResetDomain() + case netbirdsettings.FieldAccessToken: + m.ResetAccessToken() return nil } - return fmt.Errorf("unknown OperatingSystem field %s", name) + return fmt.Errorf("unknown NetbirdSettings field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *OperatingSystemMutation) AddedEdges() []string { +func (m *NetbirdSettingsMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, operatingsystem.EdgeOwner) + if m.tenant != nil { + edges = append(edges, netbirdsettings.EdgeTenant) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *OperatingSystemMutation) AddedIDs(name string) []ent.Value { +func (m *NetbirdSettingsMutation) AddedIDs(name string) []ent.Value { switch name { - case operatingsystem.EdgeOwner: - if id := m.owner; id != nil { - return []ent.Value{*id} + case netbirdsettings.EdgeTenant: + ids := make([]ent.Value, 0, len(m.tenant)) + for id := range m.tenant { + ids = append(ids, id) } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *OperatingSystemMutation) RemovedEdges() []string { +func (m *NetbirdSettingsMutation) RemovedEdges() []string { edges := make([]string, 0, 1) + if m.removedtenant != nil { + edges = append(edges, netbirdsettings.EdgeTenant) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *OperatingSystemMutation) RemovedIDs(name string) []ent.Value { +func (m *NetbirdSettingsMutation) RemovedIDs(name string) []ent.Value { + switch name { + case netbirdsettings.EdgeTenant: + ids := make([]ent.Value, 0, len(m.removedtenant)) + for id := range m.removedtenant { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *OperatingSystemMutation) ClearedEdges() []string { +func (m *NetbirdSettingsMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, operatingsystem.EdgeOwner) + if m.clearedtenant { + edges = append(edges, netbirdsettings.EdgeTenant) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *OperatingSystemMutation) EdgeCleared(name string) bool { +func (m *NetbirdSettingsMutation) EdgeCleared(name string) bool { switch name { - case operatingsystem.EdgeOwner: - return m.clearedowner + case netbirdsettings.EdgeTenant: + return m.clearedtenant } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *OperatingSystemMutation) ClearEdge(name string) error { +func (m *NetbirdSettingsMutation) ClearEdge(name string) error { switch name { - case operatingsystem.EdgeOwner: - m.ClearOwner() - return nil } - return fmt.Errorf("unknown OperatingSystem unique edge %s", name) + return fmt.Errorf("unknown NetbirdSettings unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *OperatingSystemMutation) ResetEdge(name string) error { +func (m *NetbirdSettingsMutation) ResetEdge(name string) error { switch name { - case operatingsystem.EdgeOwner: - m.ResetOwner() + case netbirdsettings.EdgeTenant: + m.ResetTenant() return nil } - return fmt.Errorf("unknown OperatingSystem edge %s", name) + return fmt.Errorf("unknown NetbirdSettings edge %s", name) } -// OrgMetadataMutation represents an operation that mutates the OrgMetadata nodes in the graph. -type OrgMetadataMutation struct { +// NetworkAdapterMutation represents an operation that mutates the NetworkAdapter nodes in the graph. +type NetworkAdapterMutation struct { config - op Op - typ string - id *int - name *string - description *string - clearedFields map[string]struct{} - metadata map[int]struct{} - removedmetadata map[int]struct{} - clearedmetadata bool - tenant *int - clearedtenant bool - done bool - oldValue func(context.Context) (*OrgMetadata, error) - predicates []predicate.OrgMetadata + op Op + typ string + id *int + name *string + mac_address *string + addresses *string + subnet *string + default_gateway *string + dns_servers *string + dns_domain *string + dhcp_enabled *bool + dhcp_lease_obtained *time.Time + dhcp_lease_expired *time.Time + speed *string + virtual *bool + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*NetworkAdapter, error) + predicates []predicate.NetworkAdapter } -var _ ent.Mutation = (*OrgMetadataMutation)(nil) +var _ ent.Mutation = (*NetworkAdapterMutation)(nil) -// orgmetadataOption allows management of the mutation configuration using functional options. -type orgmetadataOption func(*OrgMetadataMutation) +// networkadapterOption allows management of the mutation configuration using functional options. +type networkadapterOption func(*NetworkAdapterMutation) -// newOrgMetadataMutation creates new mutation for the OrgMetadata entity. -func newOrgMetadataMutation(c config, op Op, opts ...orgmetadataOption) *OrgMetadataMutation { - m := &OrgMetadataMutation{ +// newNetworkAdapterMutation creates new mutation for the NetworkAdapter entity. +func newNetworkAdapterMutation(c config, op Op, opts ...networkadapterOption) *NetworkAdapterMutation { + m := &NetworkAdapterMutation{ config: c, op: op, - typ: TypeOrgMetadata, + typ: TypeNetworkAdapter, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -15443,20 +15558,20 @@ func newOrgMetadataMutation(c config, op Op, opts ...orgmetadataOption) *OrgMeta return m } -// withOrgMetadataID sets the ID field of the mutation. -func withOrgMetadataID(id int) orgmetadataOption { - return func(m *OrgMetadataMutation) { +// withNetworkAdapterID sets the ID field of the mutation. +func withNetworkAdapterID(id int) networkadapterOption { + return func(m *NetworkAdapterMutation) { var ( err error once sync.Once - value *OrgMetadata + value *NetworkAdapter ) - m.oldValue = func(ctx context.Context) (*OrgMetadata, error) { + m.oldValue = func(ctx context.Context) (*NetworkAdapter, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().OrgMetadata.Get(ctx, id) + value, err = m.Client().NetworkAdapter.Get(ctx, id) } }) return value, err @@ -15465,10 +15580,10 @@ func withOrgMetadataID(id int) orgmetadataOption { } } -// withOrgMetadata sets the old OrgMetadata of the mutation. -func withOrgMetadata(node *OrgMetadata) orgmetadataOption { - return func(m *OrgMetadataMutation) { - m.oldValue = func(context.Context) (*OrgMetadata, error) { +// withNetworkAdapter sets the old NetworkAdapter of the mutation. +func withNetworkAdapter(node *NetworkAdapter) networkadapterOption { + return func(m *NetworkAdapterMutation) { + m.oldValue = func(context.Context) (*NetworkAdapter, error) { return node, nil } m.id = &node.ID @@ -15477,7 +15592,7 @@ func withOrgMetadata(node *OrgMetadata) orgmetadataOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m OrgMetadataMutation) Client() *Client { +func (m NetworkAdapterMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -15485,7 +15600,7 @@ func (m OrgMetadataMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m OrgMetadataMutation) Tx() (*Tx, error) { +func (m NetworkAdapterMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -15496,7 +15611,7 @@ func (m OrgMetadataMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *OrgMetadataMutation) ID() (id int, exists bool) { +func (m *NetworkAdapterMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -15507,7 +15622,7 @@ func (m *OrgMetadataMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *OrgMetadataMutation) IDs(ctx context.Context) ([]int, error) { +func (m *NetworkAdapterMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -15516,19 +15631,19 @@ func (m *OrgMetadataMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().OrgMetadata.Query().Where(m.predicates...).IDs(ctx) + return m.Client().NetworkAdapter.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetName sets the "name" field. -func (m *OrgMetadataMutation) SetName(s string) { +func (m *NetworkAdapterMutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. -func (m *OrgMetadataMutation) Name() (r string, exists bool) { +func (m *NetworkAdapterMutation) Name() (r string, exists bool) { v := m.name if v == nil { return @@ -15536,10 +15651,10 @@ func (m *OrgMetadataMutation) Name() (r string, exists bool) { return *v, true } -// OldName returns the old "name" field's value of the OrgMetadata entity. -// If the OrgMetadata object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OrgMetadataMutation) OldName(ctx context.Context) (v string, err error) { +func (m *NetworkAdapterMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldName is only allowed on UpdateOne operations") } @@ -15554,727 +15669,527 @@ func (m *OrgMetadataMutation) OldName(ctx context.Context) (v string, err error) } // ResetName resets all changes to the "name" field. -func (m *OrgMetadataMutation) ResetName() { +func (m *NetworkAdapterMutation) ResetName() { m.name = nil } -// SetDescription sets the "description" field. -func (m *OrgMetadataMutation) SetDescription(s string) { - m.description = &s +// SetMACAddress sets the "mac_address" field. +func (m *NetworkAdapterMutation) SetMACAddress(s string) { + m.mac_address = &s } -// Description returns the value of the "description" field in the mutation. -func (m *OrgMetadataMutation) Description() (r string, exists bool) { - v := m.description +// MACAddress returns the value of the "mac_address" field in the mutation. +func (m *NetworkAdapterMutation) MACAddress() (r string, exists bool) { + v := m.mac_address if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the OrgMetadata entity. -// If the OrgMetadata object wasn't provided to the builder, the object is fetched from the database. +// OldMACAddress returns the old "mac_address" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OrgMetadataMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *NetworkAdapterMutation) OldMACAddress(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldMACAddress is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldMACAddress requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldMACAddress: %w", err) } - return oldValue.Description, nil + return oldValue.MACAddress, nil } -// ClearDescription clears the value of the "description" field. -func (m *OrgMetadataMutation) ClearDescription() { - m.description = nil - m.clearedFields[orgmetadata.FieldDescription] = struct{}{} +// ResetMACAddress resets all changes to the "mac_address" field. +func (m *NetworkAdapterMutation) ResetMACAddress() { + m.mac_address = nil } -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *OrgMetadataMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[orgmetadata.FieldDescription] - return ok +// SetAddresses sets the "addresses" field. +func (m *NetworkAdapterMutation) SetAddresses(s string) { + m.addresses = &s } -// ResetDescription resets all changes to the "description" field. -func (m *OrgMetadataMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, orgmetadata.FieldDescription) +// Addresses returns the value of the "addresses" field in the mutation. +func (m *NetworkAdapterMutation) Addresses() (r string, exists bool) { + v := m.addresses + if v == nil { + return + } + return *v, true } -// AddMetadatumIDs adds the "metadata" edge to the Metadata entity by ids. -func (m *OrgMetadataMutation) AddMetadatumIDs(ids ...int) { - if m.metadata == nil { - m.metadata = make(map[int]struct{}) +// OldAddresses returns the old "addresses" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetworkAdapterMutation) OldAddresses(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAddresses is only allowed on UpdateOne operations") } - for i := range ids { - m.metadata[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAddresses requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAddresses: %w", err) } + return oldValue.Addresses, nil } -// ClearMetadata clears the "metadata" edge to the Metadata entity. -func (m *OrgMetadataMutation) ClearMetadata() { - m.clearedmetadata = true +// ResetAddresses resets all changes to the "addresses" field. +func (m *NetworkAdapterMutation) ResetAddresses() { + m.addresses = nil } -// MetadataCleared reports if the "metadata" edge to the Metadata entity was cleared. -func (m *OrgMetadataMutation) MetadataCleared() bool { - return m.clearedmetadata +// SetSubnet sets the "subnet" field. +func (m *NetworkAdapterMutation) SetSubnet(s string) { + m.subnet = &s } -// RemoveMetadatumIDs removes the "metadata" edge to the Metadata entity by IDs. -func (m *OrgMetadataMutation) RemoveMetadatumIDs(ids ...int) { - if m.removedmetadata == nil { - m.removedmetadata = make(map[int]struct{}) - } - for i := range ids { - delete(m.metadata, ids[i]) - m.removedmetadata[ids[i]] = struct{}{} +// Subnet returns the value of the "subnet" field in the mutation. +func (m *NetworkAdapterMutation) Subnet() (r string, exists bool) { + v := m.subnet + if v == nil { + return } + return *v, true } -// RemovedMetadata returns the removed IDs of the "metadata" edge to the Metadata entity. -func (m *OrgMetadataMutation) RemovedMetadataIDs() (ids []int) { - for id := range m.removedmetadata { - ids = append(ids, id) +// OldSubnet returns the old "subnet" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetworkAdapterMutation) OldSubnet(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubnet is only allowed on UpdateOne operations") } - return -} - -// MetadataIDs returns the "metadata" edge IDs in the mutation. -func (m *OrgMetadataMutation) MetadataIDs() (ids []int) { - for id := range m.metadata { - ids = append(ids, id) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubnet requires an ID field in the mutation") } - return + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubnet: %w", err) + } + return oldValue.Subnet, nil } -// ResetMetadata resets all changes to the "metadata" edge. -func (m *OrgMetadataMutation) ResetMetadata() { - m.metadata = nil - m.clearedmetadata = false - m.removedmetadata = nil +// ClearSubnet clears the value of the "subnet" field. +func (m *NetworkAdapterMutation) ClearSubnet() { + m.subnet = nil + m.clearedFields[networkadapter.FieldSubnet] = struct{}{} } -// SetTenantID sets the "tenant" edge to the Tenant entity by id. -func (m *OrgMetadataMutation) SetTenantID(id int) { - m.tenant = &id +// SubnetCleared returns if the "subnet" field was cleared in this mutation. +func (m *NetworkAdapterMutation) SubnetCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldSubnet] + return ok } -// ClearTenant clears the "tenant" edge to the Tenant entity. -func (m *OrgMetadataMutation) ClearTenant() { - m.clearedtenant = true +// ResetSubnet resets all changes to the "subnet" field. +func (m *NetworkAdapterMutation) ResetSubnet() { + m.subnet = nil + delete(m.clearedFields, networkadapter.FieldSubnet) } -// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. -func (m *OrgMetadataMutation) TenantCleared() bool { - return m.clearedtenant +// SetDefaultGateway sets the "default_gateway" field. +func (m *NetworkAdapterMutation) SetDefaultGateway(s string) { + m.default_gateway = &s } -// TenantID returns the "tenant" edge ID in the mutation. -func (m *OrgMetadataMutation) TenantID() (id int, exists bool) { - if m.tenant != nil { - return *m.tenant, true +// DefaultGateway returns the value of the "default_gateway" field in the mutation. +func (m *NetworkAdapterMutation) DefaultGateway() (r string, exists bool) { + v := m.default_gateway + if v == nil { + return } - return + return *v, true } -// TenantIDs returns the "tenant" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TenantID instead. It exists only for internal usage by the builders. -func (m *OrgMetadataMutation) TenantIDs() (ids []int) { - if id := m.tenant; id != nil { - ids = append(ids, *id) +// OldDefaultGateway returns the old "default_gateway" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetworkAdapterMutation) OldDefaultGateway(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultGateway is only allowed on UpdateOne operations") } - return -} - -// ResetTenant resets all changes to the "tenant" edge. -func (m *OrgMetadataMutation) ResetTenant() { - m.tenant = nil - m.clearedtenant = false + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultGateway requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultGateway: %w", err) + } + return oldValue.DefaultGateway, nil } -// Where appends a list predicates to the OrgMetadataMutation builder. -func (m *OrgMetadataMutation) Where(ps ...predicate.OrgMetadata) { - m.predicates = append(m.predicates, ps...) +// ClearDefaultGateway clears the value of the "default_gateway" field. +func (m *NetworkAdapterMutation) ClearDefaultGateway() { + m.default_gateway = nil + m.clearedFields[networkadapter.FieldDefaultGateway] = struct{}{} } -// WhereP appends storage-level predicates to the OrgMetadataMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *OrgMetadataMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.OrgMetadata, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// DefaultGatewayCleared returns if the "default_gateway" field was cleared in this mutation. +func (m *NetworkAdapterMutation) DefaultGatewayCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldDefaultGateway] + return ok } -// Op returns the operation name. -func (m *OrgMetadataMutation) Op() Op { - return m.op +// ResetDefaultGateway resets all changes to the "default_gateway" field. +func (m *NetworkAdapterMutation) ResetDefaultGateway() { + m.default_gateway = nil + delete(m.clearedFields, networkadapter.FieldDefaultGateway) } -// SetOp allows setting the mutation operation. -func (m *OrgMetadataMutation) SetOp(op Op) { - m.op = op +// SetDNSServers sets the "dns_servers" field. +func (m *NetworkAdapterMutation) SetDNSServers(s string) { + m.dns_servers = &s } -// Type returns the node type of this mutation (OrgMetadata). -func (m *OrgMetadataMutation) Type() string { - return m.typ +// DNSServers returns the value of the "dns_servers" field in the mutation. +func (m *NetworkAdapterMutation) DNSServers() (r string, exists bool) { + v := m.dns_servers + if v == nil { + return + } + return *v, true } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *OrgMetadataMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.name != nil { - fields = append(fields, orgmetadata.FieldName) +// OldDNSServers returns the old "dns_servers" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetworkAdapterMutation) OldDNSServers(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDNSServers is only allowed on UpdateOne operations") } - if m.description != nil { - fields = append(fields, orgmetadata.FieldDescription) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDNSServers requires an ID field in the mutation") } - return fields + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDNSServers: %w", err) + } + return oldValue.DNSServers, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *OrgMetadataMutation) Field(name string) (ent.Value, bool) { - switch name { - case orgmetadata.FieldName: - return m.Name() - case orgmetadata.FieldDescription: - return m.Description() - } - return nil, false +// ClearDNSServers clears the value of the "dns_servers" field. +func (m *NetworkAdapterMutation) ClearDNSServers() { + m.dns_servers = nil + m.clearedFields[networkadapter.FieldDNSServers] = struct{}{} } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *OrgMetadataMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case orgmetadata.FieldName: - return m.OldName(ctx) - case orgmetadata.FieldDescription: - return m.OldDescription(ctx) - } - return nil, fmt.Errorf("unknown OrgMetadata field %s", name) +// DNSServersCleared returns if the "dns_servers" field was cleared in this mutation. +func (m *NetworkAdapterMutation) DNSServersCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldDNSServers] + return ok } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *OrgMetadataMutation) SetField(name string, value ent.Value) error { - switch name { - case orgmetadata.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case orgmetadata.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - } - return fmt.Errorf("unknown OrgMetadata field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *OrgMetadataMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *OrgMetadataMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *OrgMetadataMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown OrgMetadata numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *OrgMetadataMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(orgmetadata.FieldDescription) { - fields = append(fields, orgmetadata.FieldDescription) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *OrgMetadataMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok +// ResetDNSServers resets all changes to the "dns_servers" field. +func (m *NetworkAdapterMutation) ResetDNSServers() { + m.dns_servers = nil + delete(m.clearedFields, networkadapter.FieldDNSServers) } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *OrgMetadataMutation) ClearField(name string) error { - switch name { - case orgmetadata.FieldDescription: - m.ClearDescription() - return nil - } - return fmt.Errorf("unknown OrgMetadata nullable field %s", name) +// SetDNSDomain sets the "dns_domain" field. +func (m *NetworkAdapterMutation) SetDNSDomain(s string) { + m.dns_domain = &s } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *OrgMetadataMutation) ResetField(name string) error { - switch name { - case orgmetadata.FieldName: - m.ResetName() - return nil - case orgmetadata.FieldDescription: - m.ResetDescription() - return nil +// DNSDomain returns the value of the "dns_domain" field in the mutation. +func (m *NetworkAdapterMutation) DNSDomain() (r string, exists bool) { + v := m.dns_domain + if v == nil { + return } - return fmt.Errorf("unknown OrgMetadata field %s", name) + return *v, true } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *OrgMetadataMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.metadata != nil { - edges = append(edges, orgmetadata.EdgeMetadata) - } - if m.tenant != nil { - edges = append(edges, orgmetadata.EdgeTenant) +// OldDNSDomain returns the old "dns_domain" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetworkAdapterMutation) OldDNSDomain(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDNSDomain is only allowed on UpdateOne operations") } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *OrgMetadataMutation) AddedIDs(name string) []ent.Value { - switch name { - case orgmetadata.EdgeMetadata: - ids := make([]ent.Value, 0, len(m.metadata)) - for id := range m.metadata { - ids = append(ids, id) - } - return ids - case orgmetadata.EdgeTenant: - if id := m.tenant; id != nil { - return []ent.Value{*id} - } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDNSDomain requires an ID field in the mutation") } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *OrgMetadataMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - if m.removedmetadata != nil { - edges = append(edges, orgmetadata.EdgeMetadata) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDNSDomain: %w", err) } - return edges + return oldValue.DNSDomain, nil } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *OrgMetadataMutation) RemovedIDs(name string) []ent.Value { - switch name { - case orgmetadata.EdgeMetadata: - ids := make([]ent.Value, 0, len(m.removedmetadata)) - for id := range m.removedmetadata { - ids = append(ids, id) - } - return ids - } - return nil +// ClearDNSDomain clears the value of the "dns_domain" field. +func (m *NetworkAdapterMutation) ClearDNSDomain() { + m.dns_domain = nil + m.clearedFields[networkadapter.FieldDNSDomain] = struct{}{} } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *OrgMetadataMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedmetadata { - edges = append(edges, orgmetadata.EdgeMetadata) - } - if m.clearedtenant { - edges = append(edges, orgmetadata.EdgeTenant) - } - return edges +// DNSDomainCleared returns if the "dns_domain" field was cleared in this mutation. +func (m *NetworkAdapterMutation) DNSDomainCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldDNSDomain] + return ok } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *OrgMetadataMutation) EdgeCleared(name string) bool { - switch name { - case orgmetadata.EdgeMetadata: - return m.clearedmetadata - case orgmetadata.EdgeTenant: - return m.clearedtenant - } - return false +// ResetDNSDomain resets all changes to the "dns_domain" field. +func (m *NetworkAdapterMutation) ResetDNSDomain() { + m.dns_domain = nil + delete(m.clearedFields, networkadapter.FieldDNSDomain) } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *OrgMetadataMutation) ClearEdge(name string) error { - switch name { - case orgmetadata.EdgeTenant: - m.ClearTenant() - return nil - } - return fmt.Errorf("unknown OrgMetadata unique edge %s", name) +// SetDhcpEnabled sets the "dhcp_enabled" field. +func (m *NetworkAdapterMutation) SetDhcpEnabled(b bool) { + m.dhcp_enabled = &b } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *OrgMetadataMutation) ResetEdge(name string) error { - switch name { - case orgmetadata.EdgeMetadata: - m.ResetMetadata() - return nil - case orgmetadata.EdgeTenant: - m.ResetTenant() - return nil +// DhcpEnabled returns the value of the "dhcp_enabled" field in the mutation. +func (m *NetworkAdapterMutation) DhcpEnabled() (r bool, exists bool) { + v := m.dhcp_enabled + if v == nil { + return } - return fmt.Errorf("unknown OrgMetadata edge %s", name) -} - -// PhysicalDiskMutation represents an operation that mutates the PhysicalDisk nodes in the graph. -type PhysicalDiskMutation struct { - config - op Op - typ string - id *int - device_id *string - model *string - serial_number *string - size_in_units *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*PhysicalDisk, error) - predicates []predicate.PhysicalDisk + return *v, true } -var _ ent.Mutation = (*PhysicalDiskMutation)(nil) - -// physicaldiskOption allows management of the mutation configuration using functional options. -type physicaldiskOption func(*PhysicalDiskMutation) - -// newPhysicalDiskMutation creates new mutation for the PhysicalDisk entity. -func newPhysicalDiskMutation(c config, op Op, opts ...physicaldiskOption) *PhysicalDiskMutation { - m := &PhysicalDiskMutation{ - config: c, - op: op, - typ: TypePhysicalDisk, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) +// OldDhcpEnabled returns the old "dhcp_enabled" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NetworkAdapterMutation) OldDhcpEnabled(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDhcpEnabled is only allowed on UpdateOne operations") } - return m -} - -// withPhysicalDiskID sets the ID field of the mutation. -func withPhysicalDiskID(id int) physicaldiskOption { - return func(m *PhysicalDiskMutation) { - var ( - err error - once sync.Once - value *PhysicalDisk - ) - m.oldValue = func(ctx context.Context) (*PhysicalDisk, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().PhysicalDisk.Get(ctx, id) - } - }) - return value, err - } - m.id = &id + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDhcpEnabled requires an ID field in the mutation") } -} - -// withPhysicalDisk sets the old PhysicalDisk of the mutation. -func withPhysicalDisk(node *PhysicalDisk) physicaldiskOption { - return func(m *PhysicalDiskMutation) { - m.oldValue = func(context.Context) (*PhysicalDisk, error) { - return node, nil - } - m.id = &node.ID + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDhcpEnabled: %w", err) } + return oldValue.DhcpEnabled, nil } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m PhysicalDiskMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m PhysicalDiskMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// ClearDhcpEnabled clears the value of the "dhcp_enabled" field. +func (m *NetworkAdapterMutation) ClearDhcpEnabled() { + m.dhcp_enabled = nil + m.clearedFields[networkadapter.FieldDhcpEnabled] = struct{}{} } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PhysicalDiskMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true +// DhcpEnabledCleared returns if the "dhcp_enabled" field was cleared in this mutation. +func (m *NetworkAdapterMutation) DhcpEnabledCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldDhcpEnabled] + return ok } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PhysicalDiskMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().PhysicalDisk.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } +// ResetDhcpEnabled resets all changes to the "dhcp_enabled" field. +func (m *NetworkAdapterMutation) ResetDhcpEnabled() { + m.dhcp_enabled = nil + delete(m.clearedFields, networkadapter.FieldDhcpEnabled) } -// SetDeviceID sets the "device_id" field. -func (m *PhysicalDiskMutation) SetDeviceID(s string) { - m.device_id = &s +// SetDhcpLeaseObtained sets the "dhcp_lease_obtained" field. +func (m *NetworkAdapterMutation) SetDhcpLeaseObtained(t time.Time) { + m.dhcp_lease_obtained = &t } -// DeviceID returns the value of the "device_id" field in the mutation. -func (m *PhysicalDiskMutation) DeviceID() (r string, exists bool) { - v := m.device_id +// DhcpLeaseObtained returns the value of the "dhcp_lease_obtained" field in the mutation. +func (m *NetworkAdapterMutation) DhcpLeaseObtained() (r time.Time, exists bool) { + v := m.dhcp_lease_obtained if v == nil { return } return *v, true } -// OldDeviceID returns the old "device_id" field's value of the PhysicalDisk entity. -// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldDhcpLeaseObtained returns the old "dhcp_lease_obtained" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhysicalDiskMutation) OldDeviceID(ctx context.Context) (v string, err error) { +func (m *NetworkAdapterMutation) OldDhcpLeaseObtained(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeviceID is only allowed on UpdateOne operations") + return v, errors.New("OldDhcpLeaseObtained is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeviceID requires an ID field in the mutation") + return v, errors.New("OldDhcpLeaseObtained requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeviceID: %w", err) + return v, fmt.Errorf("querying old value for OldDhcpLeaseObtained: %w", err) } - return oldValue.DeviceID, nil + return oldValue.DhcpLeaseObtained, nil } -// ResetDeviceID resets all changes to the "device_id" field. -func (m *PhysicalDiskMutation) ResetDeviceID() { - m.device_id = nil +// ClearDhcpLeaseObtained clears the value of the "dhcp_lease_obtained" field. +func (m *NetworkAdapterMutation) ClearDhcpLeaseObtained() { + m.dhcp_lease_obtained = nil + m.clearedFields[networkadapter.FieldDhcpLeaseObtained] = struct{}{} } -// SetModel sets the "model" field. -func (m *PhysicalDiskMutation) SetModel(s string) { - m.model = &s +// DhcpLeaseObtainedCleared returns if the "dhcp_lease_obtained" field was cleared in this mutation. +func (m *NetworkAdapterMutation) DhcpLeaseObtainedCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldDhcpLeaseObtained] + return ok } -// Model returns the value of the "model" field in the mutation. -func (m *PhysicalDiskMutation) Model() (r string, exists bool) { - v := m.model +// ResetDhcpLeaseObtained resets all changes to the "dhcp_lease_obtained" field. +func (m *NetworkAdapterMutation) ResetDhcpLeaseObtained() { + m.dhcp_lease_obtained = nil + delete(m.clearedFields, networkadapter.FieldDhcpLeaseObtained) +} + +// SetDhcpLeaseExpired sets the "dhcp_lease_expired" field. +func (m *NetworkAdapterMutation) SetDhcpLeaseExpired(t time.Time) { + m.dhcp_lease_expired = &t +} + +// DhcpLeaseExpired returns the value of the "dhcp_lease_expired" field in the mutation. +func (m *NetworkAdapterMutation) DhcpLeaseExpired() (r time.Time, exists bool) { + v := m.dhcp_lease_expired if v == nil { return } return *v, true } -// OldModel returns the old "model" field's value of the PhysicalDisk entity. -// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldDhcpLeaseExpired returns the old "dhcp_lease_expired" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhysicalDiskMutation) OldModel(ctx context.Context) (v string, err error) { +func (m *NetworkAdapterMutation) OldDhcpLeaseExpired(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModel is only allowed on UpdateOne operations") + return v, errors.New("OldDhcpLeaseExpired is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModel requires an ID field in the mutation") + return v, errors.New("OldDhcpLeaseExpired requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModel: %w", err) + return v, fmt.Errorf("querying old value for OldDhcpLeaseExpired: %w", err) } - return oldValue.Model, nil + return oldValue.DhcpLeaseExpired, nil } -// ClearModel clears the value of the "model" field. -func (m *PhysicalDiskMutation) ClearModel() { - m.model = nil - m.clearedFields[physicaldisk.FieldModel] = struct{}{} +// ClearDhcpLeaseExpired clears the value of the "dhcp_lease_expired" field. +func (m *NetworkAdapterMutation) ClearDhcpLeaseExpired() { + m.dhcp_lease_expired = nil + m.clearedFields[networkadapter.FieldDhcpLeaseExpired] = struct{}{} } -// ModelCleared returns if the "model" field was cleared in this mutation. -func (m *PhysicalDiskMutation) ModelCleared() bool { - _, ok := m.clearedFields[physicaldisk.FieldModel] +// DhcpLeaseExpiredCleared returns if the "dhcp_lease_expired" field was cleared in this mutation. +func (m *NetworkAdapterMutation) DhcpLeaseExpiredCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldDhcpLeaseExpired] return ok } -// ResetModel resets all changes to the "model" field. -func (m *PhysicalDiskMutation) ResetModel() { - m.model = nil - delete(m.clearedFields, physicaldisk.FieldModel) +// ResetDhcpLeaseExpired resets all changes to the "dhcp_lease_expired" field. +func (m *NetworkAdapterMutation) ResetDhcpLeaseExpired() { + m.dhcp_lease_expired = nil + delete(m.clearedFields, networkadapter.FieldDhcpLeaseExpired) } -// SetSerialNumber sets the "serial_number" field. -func (m *PhysicalDiskMutation) SetSerialNumber(s string) { - m.serial_number = &s +// SetSpeed sets the "speed" field. +func (m *NetworkAdapterMutation) SetSpeed(s string) { + m.speed = &s } -// SerialNumber returns the value of the "serial_number" field in the mutation. -func (m *PhysicalDiskMutation) SerialNumber() (r string, exists bool) { - v := m.serial_number +// Speed returns the value of the "speed" field in the mutation. +func (m *NetworkAdapterMutation) Speed() (r string, exists bool) { + v := m.speed if v == nil { return } return *v, true } -// OldSerialNumber returns the old "serial_number" field's value of the PhysicalDisk entity. -// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldSpeed returns the old "speed" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhysicalDiskMutation) OldSerialNumber(ctx context.Context) (v string, err error) { +func (m *NetworkAdapterMutation) OldSpeed(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") + return v, errors.New("OldSpeed is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSerialNumber requires an ID field in the mutation") + return v, errors.New("OldSpeed requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) + return v, fmt.Errorf("querying old value for OldSpeed: %w", err) } - return oldValue.SerialNumber, nil -} - -// ClearSerialNumber clears the value of the "serial_number" field. -func (m *PhysicalDiskMutation) ClearSerialNumber() { - m.serial_number = nil - m.clearedFields[physicaldisk.FieldSerialNumber] = struct{}{} -} - -// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. -func (m *PhysicalDiskMutation) SerialNumberCleared() bool { - _, ok := m.clearedFields[physicaldisk.FieldSerialNumber] - return ok + return oldValue.Speed, nil } -// ResetSerialNumber resets all changes to the "serial_number" field. -func (m *PhysicalDiskMutation) ResetSerialNumber() { - m.serial_number = nil - delete(m.clearedFields, physicaldisk.FieldSerialNumber) +// ResetSpeed resets all changes to the "speed" field. +func (m *NetworkAdapterMutation) ResetSpeed() { + m.speed = nil } -// SetSizeInUnits sets the "size_in_units" field. -func (m *PhysicalDiskMutation) SetSizeInUnits(s string) { - m.size_in_units = &s +// SetVirtual sets the "virtual" field. +func (m *NetworkAdapterMutation) SetVirtual(b bool) { + m.virtual = &b } -// SizeInUnits returns the value of the "size_in_units" field in the mutation. -func (m *PhysicalDiskMutation) SizeInUnits() (r string, exists bool) { - v := m.size_in_units +// Virtual returns the value of the "virtual" field in the mutation. +func (m *NetworkAdapterMutation) Virtual() (r bool, exists bool) { + v := m.virtual if v == nil { return } return *v, true } -// OldSizeInUnits returns the old "size_in_units" field's value of the PhysicalDisk entity. -// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. +// OldVirtual returns the old "virtual" field's value of the NetworkAdapter entity. +// If the NetworkAdapter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PhysicalDiskMutation) OldSizeInUnits(ctx context.Context) (v string, err error) { +func (m *NetworkAdapterMutation) OldVirtual(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSizeInUnits is only allowed on UpdateOne operations") + return v, errors.New("OldVirtual is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSizeInUnits requires an ID field in the mutation") + return v, errors.New("OldVirtual requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSizeInUnits: %w", err) + return v, fmt.Errorf("querying old value for OldVirtual: %w", err) } - return oldValue.SizeInUnits, nil + return oldValue.Virtual, nil } -// ClearSizeInUnits clears the value of the "size_in_units" field. -func (m *PhysicalDiskMutation) ClearSizeInUnits() { - m.size_in_units = nil - m.clearedFields[physicaldisk.FieldSizeInUnits] = struct{}{} +// ClearVirtual clears the value of the "virtual" field. +func (m *NetworkAdapterMutation) ClearVirtual() { + m.virtual = nil + m.clearedFields[networkadapter.FieldVirtual] = struct{}{} } -// SizeInUnitsCleared returns if the "size_in_units" field was cleared in this mutation. -func (m *PhysicalDiskMutation) SizeInUnitsCleared() bool { - _, ok := m.clearedFields[physicaldisk.FieldSizeInUnits] +// VirtualCleared returns if the "virtual" field was cleared in this mutation. +func (m *NetworkAdapterMutation) VirtualCleared() bool { + _, ok := m.clearedFields[networkadapter.FieldVirtual] return ok } -// ResetSizeInUnits resets all changes to the "size_in_units" field. -func (m *PhysicalDiskMutation) ResetSizeInUnits() { - m.size_in_units = nil - delete(m.clearedFields, physicaldisk.FieldSizeInUnits) +// ResetVirtual resets all changes to the "virtual" field. +func (m *NetworkAdapterMutation) ResetVirtual() { + m.virtual = nil + delete(m.clearedFields, networkadapter.FieldVirtual) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *PhysicalDiskMutation) SetOwnerID(id string) { +func (m *NetworkAdapterMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *PhysicalDiskMutation) ClearOwner() { +func (m *NetworkAdapterMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *PhysicalDiskMutation) OwnerCleared() bool { +func (m *NetworkAdapterMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *PhysicalDiskMutation) OwnerID() (id string, exists bool) { +func (m *NetworkAdapterMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -16284,7 +16199,7 @@ func (m *PhysicalDiskMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *PhysicalDiskMutation) OwnerIDs() (ids []string) { +func (m *NetworkAdapterMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -16292,20 +16207,20 @@ func (m *PhysicalDiskMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *PhysicalDiskMutation) ResetOwner() { +func (m *NetworkAdapterMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the PhysicalDiskMutation builder. -func (m *PhysicalDiskMutation) Where(ps ...predicate.PhysicalDisk) { +// Where appends a list predicates to the NetworkAdapterMutation builder. +func (m *NetworkAdapterMutation) Where(ps ...predicate.NetworkAdapter) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the PhysicalDiskMutation builder. Using this method, +// WhereP appends storage-level predicates to the NetworkAdapterMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PhysicalDiskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.PhysicalDisk, len(ps)) +func (m *NetworkAdapterMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.NetworkAdapter, len(ps)) for i := range ps { p[i] = ps[i] } @@ -16313,36 +16228,60 @@ func (m *PhysicalDiskMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *PhysicalDiskMutation) Op() Op { +func (m *NetworkAdapterMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *PhysicalDiskMutation) SetOp(op Op) { +func (m *NetworkAdapterMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (PhysicalDisk). -func (m *PhysicalDiskMutation) Type() string { +// Type returns the node type of this mutation (NetworkAdapter). +func (m *NetworkAdapterMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *PhysicalDiskMutation) Fields() []string { - fields := make([]string, 0, 4) - if m.device_id != nil { - fields = append(fields, physicaldisk.FieldDeviceID) +func (m *NetworkAdapterMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.name != nil { + fields = append(fields, networkadapter.FieldName) } - if m.model != nil { - fields = append(fields, physicaldisk.FieldModel) + if m.mac_address != nil { + fields = append(fields, networkadapter.FieldMACAddress) } - if m.serial_number != nil { - fields = append(fields, physicaldisk.FieldSerialNumber) + if m.addresses != nil { + fields = append(fields, networkadapter.FieldAddresses) } - if m.size_in_units != nil { - fields = append(fields, physicaldisk.FieldSizeInUnits) + if m.subnet != nil { + fields = append(fields, networkadapter.FieldSubnet) + } + if m.default_gateway != nil { + fields = append(fields, networkadapter.FieldDefaultGateway) + } + if m.dns_servers != nil { + fields = append(fields, networkadapter.FieldDNSServers) + } + if m.dns_domain != nil { + fields = append(fields, networkadapter.FieldDNSDomain) + } + if m.dhcp_enabled != nil { + fields = append(fields, networkadapter.FieldDhcpEnabled) + } + if m.dhcp_lease_obtained != nil { + fields = append(fields, networkadapter.FieldDhcpLeaseObtained) + } + if m.dhcp_lease_expired != nil { + fields = append(fields, networkadapter.FieldDhcpLeaseExpired) + } + if m.speed != nil { + fields = append(fields, networkadapter.FieldSpeed) + } + if m.virtual != nil { + fields = append(fields, networkadapter.FieldVirtual) } return fields } @@ -16350,16 +16289,32 @@ func (m *PhysicalDiskMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *PhysicalDiskMutation) Field(name string) (ent.Value, bool) { +func (m *NetworkAdapterMutation) Field(name string) (ent.Value, bool) { switch name { - case physicaldisk.FieldDeviceID: - return m.DeviceID() - case physicaldisk.FieldModel: - return m.Model() - case physicaldisk.FieldSerialNumber: - return m.SerialNumber() - case physicaldisk.FieldSizeInUnits: - return m.SizeInUnits() + case networkadapter.FieldName: + return m.Name() + case networkadapter.FieldMACAddress: + return m.MACAddress() + case networkadapter.FieldAddresses: + return m.Addresses() + case networkadapter.FieldSubnet: + return m.Subnet() + case networkadapter.FieldDefaultGateway: + return m.DefaultGateway() + case networkadapter.FieldDNSServers: + return m.DNSServers() + case networkadapter.FieldDNSDomain: + return m.DNSDomain() + case networkadapter.FieldDhcpEnabled: + return m.DhcpEnabled() + case networkadapter.FieldDhcpLeaseObtained: + return m.DhcpLeaseObtained() + case networkadapter.FieldDhcpLeaseExpired: + return m.DhcpLeaseExpired() + case networkadapter.FieldSpeed: + return m.Speed() + case networkadapter.FieldVirtual: + return m.Virtual() } return nil, false } @@ -16367,153 +16322,279 @@ func (m *PhysicalDiskMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *PhysicalDiskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *NetworkAdapterMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case physicaldisk.FieldDeviceID: - return m.OldDeviceID(ctx) - case physicaldisk.FieldModel: - return m.OldModel(ctx) - case physicaldisk.FieldSerialNumber: - return m.OldSerialNumber(ctx) - case physicaldisk.FieldSizeInUnits: - return m.OldSizeInUnits(ctx) + case networkadapter.FieldName: + return m.OldName(ctx) + case networkadapter.FieldMACAddress: + return m.OldMACAddress(ctx) + case networkadapter.FieldAddresses: + return m.OldAddresses(ctx) + case networkadapter.FieldSubnet: + return m.OldSubnet(ctx) + case networkadapter.FieldDefaultGateway: + return m.OldDefaultGateway(ctx) + case networkadapter.FieldDNSServers: + return m.OldDNSServers(ctx) + case networkadapter.FieldDNSDomain: + return m.OldDNSDomain(ctx) + case networkadapter.FieldDhcpEnabled: + return m.OldDhcpEnabled(ctx) + case networkadapter.FieldDhcpLeaseObtained: + return m.OldDhcpLeaseObtained(ctx) + case networkadapter.FieldDhcpLeaseExpired: + return m.OldDhcpLeaseExpired(ctx) + case networkadapter.FieldSpeed: + return m.OldSpeed(ctx) + case networkadapter.FieldVirtual: + return m.OldVirtual(ctx) } - return nil, fmt.Errorf("unknown PhysicalDisk field %s", name) + return nil, fmt.Errorf("unknown NetworkAdapter field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *PhysicalDiskMutation) SetField(name string, value ent.Value) error { +func (m *NetworkAdapterMutation) SetField(name string, value ent.Value) error { switch name { - case physicaldisk.FieldDeviceID: + case networkadapter.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDeviceID(v) + m.SetName(v) return nil - case physicaldisk.FieldModel: + case networkadapter.FieldMACAddress: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModel(v) + m.SetMACAddress(v) return nil - case physicaldisk.FieldSerialNumber: + case networkadapter.FieldAddresses: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSerialNumber(v) + m.SetAddresses(v) return nil - case physicaldisk.FieldSizeInUnits: + case networkadapter.FieldSubnet: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSizeInUnits(v) + m.SetSubnet(v) + return nil + case networkadapter.FieldDefaultGateway: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultGateway(v) + return nil + case networkadapter.FieldDNSServers: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDNSServers(v) + return nil + case networkadapter.FieldDNSDomain: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDNSDomain(v) + return nil + case networkadapter.FieldDhcpEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDhcpEnabled(v) + return nil + case networkadapter.FieldDhcpLeaseObtained: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDhcpLeaseObtained(v) + return nil + case networkadapter.FieldDhcpLeaseExpired: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDhcpLeaseExpired(v) + return nil + case networkadapter.FieldSpeed: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpeed(v) + return nil + case networkadapter.FieldVirtual: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVirtual(v) return nil } - return fmt.Errorf("unknown PhysicalDisk field %s", name) + return fmt.Errorf("unknown NetworkAdapter field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *PhysicalDiskMutation) AddedFields() []string { +func (m *NetworkAdapterMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *PhysicalDiskMutation) AddedField(name string) (ent.Value, bool) { +func (m *NetworkAdapterMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *PhysicalDiskMutation) AddField(name string, value ent.Value) error { +func (m *NetworkAdapterMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown PhysicalDisk numeric field %s", name) + return fmt.Errorf("unknown NetworkAdapter numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *PhysicalDiskMutation) ClearedFields() []string { +func (m *NetworkAdapterMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(physicaldisk.FieldModel) { - fields = append(fields, physicaldisk.FieldModel) + if m.FieldCleared(networkadapter.FieldSubnet) { + fields = append(fields, networkadapter.FieldSubnet) } - if m.FieldCleared(physicaldisk.FieldSerialNumber) { - fields = append(fields, physicaldisk.FieldSerialNumber) + if m.FieldCleared(networkadapter.FieldDefaultGateway) { + fields = append(fields, networkadapter.FieldDefaultGateway) } - if m.FieldCleared(physicaldisk.FieldSizeInUnits) { - fields = append(fields, physicaldisk.FieldSizeInUnits) + if m.FieldCleared(networkadapter.FieldDNSServers) { + fields = append(fields, networkadapter.FieldDNSServers) + } + if m.FieldCleared(networkadapter.FieldDNSDomain) { + fields = append(fields, networkadapter.FieldDNSDomain) + } + if m.FieldCleared(networkadapter.FieldDhcpEnabled) { + fields = append(fields, networkadapter.FieldDhcpEnabled) + } + if m.FieldCleared(networkadapter.FieldDhcpLeaseObtained) { + fields = append(fields, networkadapter.FieldDhcpLeaseObtained) + } + if m.FieldCleared(networkadapter.FieldDhcpLeaseExpired) { + fields = append(fields, networkadapter.FieldDhcpLeaseExpired) + } + if m.FieldCleared(networkadapter.FieldVirtual) { + fields = append(fields, networkadapter.FieldVirtual) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *PhysicalDiskMutation) FieldCleared(name string) bool { +func (m *NetworkAdapterMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *PhysicalDiskMutation) ClearField(name string) error { +func (m *NetworkAdapterMutation) ClearField(name string) error { switch name { - case physicaldisk.FieldModel: - m.ClearModel() + case networkadapter.FieldSubnet: + m.ClearSubnet() return nil - case physicaldisk.FieldSerialNumber: - m.ClearSerialNumber() + case networkadapter.FieldDefaultGateway: + m.ClearDefaultGateway() return nil - case physicaldisk.FieldSizeInUnits: - m.ClearSizeInUnits() + case networkadapter.FieldDNSServers: + m.ClearDNSServers() + return nil + case networkadapter.FieldDNSDomain: + m.ClearDNSDomain() + return nil + case networkadapter.FieldDhcpEnabled: + m.ClearDhcpEnabled() + return nil + case networkadapter.FieldDhcpLeaseObtained: + m.ClearDhcpLeaseObtained() + return nil + case networkadapter.FieldDhcpLeaseExpired: + m.ClearDhcpLeaseExpired() + return nil + case networkadapter.FieldVirtual: + m.ClearVirtual() return nil } - return fmt.Errorf("unknown PhysicalDisk nullable field %s", name) + return fmt.Errorf("unknown NetworkAdapter nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *PhysicalDiskMutation) ResetField(name string) error { +func (m *NetworkAdapterMutation) ResetField(name string) error { switch name { - case physicaldisk.FieldDeviceID: - m.ResetDeviceID() + case networkadapter.FieldName: + m.ResetName() return nil - case physicaldisk.FieldModel: - m.ResetModel() + case networkadapter.FieldMACAddress: + m.ResetMACAddress() return nil - case physicaldisk.FieldSerialNumber: - m.ResetSerialNumber() + case networkadapter.FieldAddresses: + m.ResetAddresses() return nil - case physicaldisk.FieldSizeInUnits: - m.ResetSizeInUnits() + case networkadapter.FieldSubnet: + m.ResetSubnet() + return nil + case networkadapter.FieldDefaultGateway: + m.ResetDefaultGateway() + return nil + case networkadapter.FieldDNSServers: + m.ResetDNSServers() + return nil + case networkadapter.FieldDNSDomain: + m.ResetDNSDomain() + return nil + case networkadapter.FieldDhcpEnabled: + m.ResetDhcpEnabled() + return nil + case networkadapter.FieldDhcpLeaseObtained: + m.ResetDhcpLeaseObtained() + return nil + case networkadapter.FieldDhcpLeaseExpired: + m.ResetDhcpLeaseExpired() + return nil + case networkadapter.FieldSpeed: + m.ResetSpeed() + return nil + case networkadapter.FieldVirtual: + m.ResetVirtual() return nil } - return fmt.Errorf("unknown PhysicalDisk field %s", name) + return fmt.Errorf("unknown NetworkAdapter field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *PhysicalDiskMutation) AddedEdges() []string { +func (m *NetworkAdapterMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, physicaldisk.EdgeOwner) + edges = append(edges, networkadapter.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *PhysicalDiskMutation) AddedIDs(name string) []ent.Value { +func (m *NetworkAdapterMutation) AddedIDs(name string) []ent.Value { switch name { - case physicaldisk.EdgeOwner: + case networkadapter.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -16522,31 +16603,31 @@ func (m *PhysicalDiskMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *PhysicalDiskMutation) RemovedEdges() []string { +func (m *NetworkAdapterMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *PhysicalDiskMutation) RemovedIDs(name string) []ent.Value { +func (m *NetworkAdapterMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PhysicalDiskMutation) ClearedEdges() []string { +func (m *NetworkAdapterMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, physicaldisk.EdgeOwner) + edges = append(edges, networkadapter.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *PhysicalDiskMutation) EdgeCleared(name string) bool { +func (m *NetworkAdapterMutation) EdgeCleared(name string) bool { switch name { - case physicaldisk.EdgeOwner: + case networkadapter.EdgeOwner: return m.clearedowner } return false @@ -16554,56 +16635,60 @@ func (m *PhysicalDiskMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *PhysicalDiskMutation) ClearEdge(name string) error { +func (m *NetworkAdapterMutation) ClearEdge(name string) error { switch name { - case physicaldisk.EdgeOwner: + case networkadapter.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown PhysicalDisk unique edge %s", name) + return fmt.Errorf("unknown NetworkAdapter unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *PhysicalDiskMutation) ResetEdge(name string) error { +func (m *NetworkAdapterMutation) ResetEdge(name string) error { switch name { - case physicaldisk.EdgeOwner: + case networkadapter.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown PhysicalDisk edge %s", name) + return fmt.Errorf("unknown NetworkAdapter edge %s", name) } -// PrinterMutation represents an operation that mutates the Printer nodes in the graph. -type PrinterMutation struct { +// OperatingSystemMutation represents an operation that mutates the OperatingSystem nodes in the graph. +type OperatingSystemMutation struct { config - op Op - typ string - id *int - name *string - port *string - is_default *bool - is_network *bool - is_shared *bool - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Printer, error) - predicates []predicate.Printer + op Op + typ string + id *int + _type *string + version *string + description *string + edition *string + install_date *time.Time + arch *string + username *string + last_bootup_time *time.Time + domain *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*OperatingSystem, error) + predicates []predicate.OperatingSystem } -var _ ent.Mutation = (*PrinterMutation)(nil) +var _ ent.Mutation = (*OperatingSystemMutation)(nil) -// printerOption allows management of the mutation configuration using functional options. -type printerOption func(*PrinterMutation) +// operatingsystemOption allows management of the mutation configuration using functional options. +type operatingsystemOption func(*OperatingSystemMutation) -// newPrinterMutation creates new mutation for the Printer entity. -func newPrinterMutation(c config, op Op, opts ...printerOption) *PrinterMutation { - m := &PrinterMutation{ +// newOperatingSystemMutation creates new mutation for the OperatingSystem entity. +func newOperatingSystemMutation(c config, op Op, opts ...operatingsystemOption) *OperatingSystemMutation { + m := &OperatingSystemMutation{ config: c, op: op, - typ: TypePrinter, + typ: TypeOperatingSystem, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -16612,20 +16697,20 @@ func newPrinterMutation(c config, op Op, opts ...printerOption) *PrinterMutation return m } -// withPrinterID sets the ID field of the mutation. -func withPrinterID(id int) printerOption { - return func(m *PrinterMutation) { +// withOperatingSystemID sets the ID field of the mutation. +func withOperatingSystemID(id int) operatingsystemOption { + return func(m *OperatingSystemMutation) { var ( err error once sync.Once - value *Printer + value *OperatingSystem ) - m.oldValue = func(ctx context.Context) (*Printer, error) { + m.oldValue = func(ctx context.Context) (*OperatingSystem, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Printer.Get(ctx, id) + value, err = m.Client().OperatingSystem.Get(ctx, id) } }) return value, err @@ -16634,10 +16719,10 @@ func withPrinterID(id int) printerOption { } } -// withPrinter sets the old Printer of the mutation. -func withPrinter(node *Printer) printerOption { - return func(m *PrinterMutation) { - m.oldValue = func(context.Context) (*Printer, error) { +// withOperatingSystem sets the old OperatingSystem of the mutation. +func withOperatingSystem(node *OperatingSystem) operatingsystemOption { + return func(m *OperatingSystemMutation) { + m.oldValue = func(context.Context) (*OperatingSystem, error) { return node, nil } m.id = &node.ID @@ -16646,7 +16731,7 @@ func withPrinter(node *Printer) printerOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m PrinterMutation) Client() *Client { +func (m OperatingSystemMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -16654,7 +16739,7 @@ func (m PrinterMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m PrinterMutation) Tx() (*Tx, error) { +func (m OperatingSystemMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -16665,7 +16750,7 @@ func (m PrinterMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *PrinterMutation) ID() (id int, exists bool) { +func (m *OperatingSystemMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -16676,7 +16761,7 @@ func (m *PrinterMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *PrinterMutation) IDs(ctx context.Context) ([]int, error) { +func (m *OperatingSystemMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -16685,261 +16770,431 @@ func (m *PrinterMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Printer.Query().Where(m.predicates...).IDs(ctx) + return m.Client().OperatingSystem.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetName sets the "name" field. -func (m *PrinterMutation) SetName(s string) { - m.name = &s +// SetType sets the "type" field. +func (m *OperatingSystemMutation) SetType(s string) { + m._type = &s } -// Name returns the value of the "name" field in the mutation. -func (m *PrinterMutation) Name() (r string, exists bool) { - v := m.name +// GetType returns the value of the "type" field in the mutation. +func (m *OperatingSystemMutation) GetType() (r string, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the Printer entity. -// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrinterMutation) OldName(ctx context.Context) (v string, err error) { +func (m *OperatingSystemMutation) OldType(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.Name, nil + return oldValue.Type, nil } -// ResetName resets all changes to the "name" field. -func (m *PrinterMutation) ResetName() { - m.name = nil +// ClearType clears the value of the "type" field. +func (m *OperatingSystemMutation) ClearType() { + m._type = nil + m.clearedFields[operatingsystem.FieldType] = struct{}{} } -// SetPort sets the "port" field. -func (m *PrinterMutation) SetPort(s string) { - m.port = &s +// TypeCleared returns if the "type" field was cleared in this mutation. +func (m *OperatingSystemMutation) TypeCleared() bool { + _, ok := m.clearedFields[operatingsystem.FieldType] + return ok } -// Port returns the value of the "port" field in the mutation. -func (m *PrinterMutation) Port() (r string, exists bool) { - v := m.port - if v == nil { - return - } - return *v, true +// ResetType resets all changes to the "type" field. +func (m *OperatingSystemMutation) ResetType() { + m._type = nil + delete(m.clearedFields, operatingsystem.FieldType) } -// OldPort returns the old "port" field's value of the Printer entity. -// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// SetVersion sets the "version" field. +func (m *OperatingSystemMutation) SetVersion(s string) { + m.version = &s +} + +// Version returns the value of the "version" field in the mutation. +func (m *OperatingSystemMutation) Version() (r string, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// OldVersion returns the old "version" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrinterMutation) OldPort(ctx context.Context) (v string, err error) { +func (m *OperatingSystemMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPort is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPort requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPort: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.Port, nil + return oldValue.Version, nil } -// ClearPort clears the value of the "port" field. -func (m *PrinterMutation) ClearPort() { - m.port = nil - m.clearedFields[printer.FieldPort] = struct{}{} +// ResetVersion resets all changes to the "version" field. +func (m *OperatingSystemMutation) ResetVersion() { + m.version = nil } -// PortCleared returns if the "port" field was cleared in this mutation. -func (m *PrinterMutation) PortCleared() bool { - _, ok := m.clearedFields[printer.FieldPort] +// SetDescription sets the "description" field. +func (m *OperatingSystemMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *OperatingSystemMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *OperatingSystemMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *OperatingSystemMutation) ResetDescription() { + m.description = nil +} + +// SetEdition sets the "edition" field. +func (m *OperatingSystemMutation) SetEdition(s string) { + m.edition = &s +} + +// Edition returns the value of the "edition" field in the mutation. +func (m *OperatingSystemMutation) Edition() (r string, exists bool) { + v := m.edition + if v == nil { + return + } + return *v, true +} + +// OldEdition returns the old "edition" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *OperatingSystemMutation) OldEdition(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEdition is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEdition requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEdition: %w", err) + } + return oldValue.Edition, nil +} + +// ClearEdition clears the value of the "edition" field. +func (m *OperatingSystemMutation) ClearEdition() { + m.edition = nil + m.clearedFields[operatingsystem.FieldEdition] = struct{}{} +} + +// EditionCleared returns if the "edition" field was cleared in this mutation. +func (m *OperatingSystemMutation) EditionCleared() bool { + _, ok := m.clearedFields[operatingsystem.FieldEdition] return ok } -// ResetPort resets all changes to the "port" field. -func (m *PrinterMutation) ResetPort() { - m.port = nil - delete(m.clearedFields, printer.FieldPort) +// ResetEdition resets all changes to the "edition" field. +func (m *OperatingSystemMutation) ResetEdition() { + m.edition = nil + delete(m.clearedFields, operatingsystem.FieldEdition) } -// SetIsDefault sets the "is_default" field. -func (m *PrinterMutation) SetIsDefault(b bool) { - m.is_default = &b +// SetInstallDate sets the "install_date" field. +func (m *OperatingSystemMutation) SetInstallDate(t time.Time) { + m.install_date = &t } -// IsDefault returns the value of the "is_default" field in the mutation. -func (m *PrinterMutation) IsDefault() (r bool, exists bool) { - v := m.is_default +// InstallDate returns the value of the "install_date" field in the mutation. +func (m *OperatingSystemMutation) InstallDate() (r time.Time, exists bool) { + v := m.install_date if v == nil { return } return *v, true } -// OldIsDefault returns the old "is_default" field's value of the Printer entity. -// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// OldInstallDate returns the old "install_date" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrinterMutation) OldIsDefault(ctx context.Context) (v bool, err error) { +func (m *OperatingSystemMutation) OldInstallDate(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") + return v, errors.New("OldInstallDate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsDefault requires an ID field in the mutation") + return v, errors.New("OldInstallDate requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) + return v, fmt.Errorf("querying old value for OldInstallDate: %w", err) } - return oldValue.IsDefault, nil + return oldValue.InstallDate, nil } -// ClearIsDefault clears the value of the "is_default" field. -func (m *PrinterMutation) ClearIsDefault() { - m.is_default = nil - m.clearedFields[printer.FieldIsDefault] = struct{}{} +// ClearInstallDate clears the value of the "install_date" field. +func (m *OperatingSystemMutation) ClearInstallDate() { + m.install_date = nil + m.clearedFields[operatingsystem.FieldInstallDate] = struct{}{} } -// IsDefaultCleared returns if the "is_default" field was cleared in this mutation. -func (m *PrinterMutation) IsDefaultCleared() bool { - _, ok := m.clearedFields[printer.FieldIsDefault] +// InstallDateCleared returns if the "install_date" field was cleared in this mutation. +func (m *OperatingSystemMutation) InstallDateCleared() bool { + _, ok := m.clearedFields[operatingsystem.FieldInstallDate] return ok } -// ResetIsDefault resets all changes to the "is_default" field. -func (m *PrinterMutation) ResetIsDefault() { - m.is_default = nil - delete(m.clearedFields, printer.FieldIsDefault) +// ResetInstallDate resets all changes to the "install_date" field. +func (m *OperatingSystemMutation) ResetInstallDate() { + m.install_date = nil + delete(m.clearedFields, operatingsystem.FieldInstallDate) } -// SetIsNetwork sets the "is_network" field. -func (m *PrinterMutation) SetIsNetwork(b bool) { - m.is_network = &b +// SetArch sets the "arch" field. +func (m *OperatingSystemMutation) SetArch(s string) { + m.arch = &s } -// IsNetwork returns the value of the "is_network" field in the mutation. -func (m *PrinterMutation) IsNetwork() (r bool, exists bool) { - v := m.is_network +// Arch returns the value of the "arch" field in the mutation. +func (m *OperatingSystemMutation) Arch() (r string, exists bool) { + v := m.arch if v == nil { return } return *v, true } -// OldIsNetwork returns the old "is_network" field's value of the Printer entity. -// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// OldArch returns the old "arch" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrinterMutation) OldIsNetwork(ctx context.Context) (v bool, err error) { +func (m *OperatingSystemMutation) OldArch(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsNetwork is only allowed on UpdateOne operations") + return v, errors.New("OldArch is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsNetwork requires an ID field in the mutation") + return v, errors.New("OldArch requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIsNetwork: %w", err) + return v, fmt.Errorf("querying old value for OldArch: %w", err) } - return oldValue.IsNetwork, nil + return oldValue.Arch, nil } -// ClearIsNetwork clears the value of the "is_network" field. -func (m *PrinterMutation) ClearIsNetwork() { - m.is_network = nil - m.clearedFields[printer.FieldIsNetwork] = struct{}{} +// ClearArch clears the value of the "arch" field. +func (m *OperatingSystemMutation) ClearArch() { + m.arch = nil + m.clearedFields[operatingsystem.FieldArch] = struct{}{} } -// IsNetworkCleared returns if the "is_network" field was cleared in this mutation. -func (m *PrinterMutation) IsNetworkCleared() bool { - _, ok := m.clearedFields[printer.FieldIsNetwork] +// ArchCleared returns if the "arch" field was cleared in this mutation. +func (m *OperatingSystemMutation) ArchCleared() bool { + _, ok := m.clearedFields[operatingsystem.FieldArch] return ok } -// ResetIsNetwork resets all changes to the "is_network" field. -func (m *PrinterMutation) ResetIsNetwork() { - m.is_network = nil - delete(m.clearedFields, printer.FieldIsNetwork) +// ResetArch resets all changes to the "arch" field. +func (m *OperatingSystemMutation) ResetArch() { + m.arch = nil + delete(m.clearedFields, operatingsystem.FieldArch) } -// SetIsShared sets the "is_shared" field. -func (m *PrinterMutation) SetIsShared(b bool) { - m.is_shared = &b +// SetUsername sets the "username" field. +func (m *OperatingSystemMutation) SetUsername(s string) { + m.username = &s } -// IsShared returns the value of the "is_shared" field in the mutation. -func (m *PrinterMutation) IsShared() (r bool, exists bool) { - v := m.is_shared +// Username returns the value of the "username" field in the mutation. +func (m *OperatingSystemMutation) Username() (r string, exists bool) { + v := m.username if v == nil { return } return *v, true } -// OldIsShared returns the old "is_shared" field's value of the Printer entity. -// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// OldUsername returns the old "username" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrinterMutation) OldIsShared(ctx context.Context) (v bool, err error) { +func (m *OperatingSystemMutation) OldUsername(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsShared is only allowed on UpdateOne operations") + return v, errors.New("OldUsername is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsShared requires an ID field in the mutation") + return v, errors.New("OldUsername requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIsShared: %w", err) + return v, fmt.Errorf("querying old value for OldUsername: %w", err) } - return oldValue.IsShared, nil + return oldValue.Username, nil } -// ClearIsShared clears the value of the "is_shared" field. -func (m *PrinterMutation) ClearIsShared() { - m.is_shared = nil - m.clearedFields[printer.FieldIsShared] = struct{}{} +// ResetUsername resets all changes to the "username" field. +func (m *OperatingSystemMutation) ResetUsername() { + m.username = nil } -// IsSharedCleared returns if the "is_shared" field was cleared in this mutation. -func (m *PrinterMutation) IsSharedCleared() bool { - _, ok := m.clearedFields[printer.FieldIsShared] +// SetLastBootupTime sets the "last_bootup_time" field. +func (m *OperatingSystemMutation) SetLastBootupTime(t time.Time) { + m.last_bootup_time = &t +} + +// LastBootupTime returns the value of the "last_bootup_time" field in the mutation. +func (m *OperatingSystemMutation) LastBootupTime() (r time.Time, exists bool) { + v := m.last_bootup_time + if v == nil { + return + } + return *v, true +} + +// OldLastBootupTime returns the old "last_bootup_time" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *OperatingSystemMutation) OldLastBootupTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastBootupTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastBootupTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastBootupTime: %w", err) + } + return oldValue.LastBootupTime, nil +} + +// ClearLastBootupTime clears the value of the "last_bootup_time" field. +func (m *OperatingSystemMutation) ClearLastBootupTime() { + m.last_bootup_time = nil + m.clearedFields[operatingsystem.FieldLastBootupTime] = struct{}{} +} + +// LastBootupTimeCleared returns if the "last_bootup_time" field was cleared in this mutation. +func (m *OperatingSystemMutation) LastBootupTimeCleared() bool { + _, ok := m.clearedFields[operatingsystem.FieldLastBootupTime] return ok } -// ResetIsShared resets all changes to the "is_shared" field. -func (m *PrinterMutation) ResetIsShared() { - m.is_shared = nil - delete(m.clearedFields, printer.FieldIsShared) +// ResetLastBootupTime resets all changes to the "last_bootup_time" field. +func (m *OperatingSystemMutation) ResetLastBootupTime() { + m.last_bootup_time = nil + delete(m.clearedFields, operatingsystem.FieldLastBootupTime) +} + +// SetDomain sets the "domain" field. +func (m *OperatingSystemMutation) SetDomain(s string) { + m.domain = &s +} + +// Domain returns the value of the "domain" field in the mutation. +func (m *OperatingSystemMutation) Domain() (r string, exists bool) { + v := m.domain + if v == nil { + return + } + return *v, true +} + +// OldDomain returns the old "domain" field's value of the OperatingSystem entity. +// If the OperatingSystem object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *OperatingSystemMutation) OldDomain(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDomain is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDomain requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDomain: %w", err) + } + return oldValue.Domain, nil +} + +// ClearDomain clears the value of the "domain" field. +func (m *OperatingSystemMutation) ClearDomain() { + m.domain = nil + m.clearedFields[operatingsystem.FieldDomain] = struct{}{} +} + +// DomainCleared returns if the "domain" field was cleared in this mutation. +func (m *OperatingSystemMutation) DomainCleared() bool { + _, ok := m.clearedFields[operatingsystem.FieldDomain] + return ok +} + +// ResetDomain resets all changes to the "domain" field. +func (m *OperatingSystemMutation) ResetDomain() { + m.domain = nil + delete(m.clearedFields, operatingsystem.FieldDomain) } // SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *PrinterMutation) SetOwnerID(id string) { +func (m *OperatingSystemMutation) SetOwnerID(id string) { m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *PrinterMutation) ClearOwner() { +func (m *OperatingSystemMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *PrinterMutation) OwnerCleared() bool { +func (m *OperatingSystemMutation) OwnerCleared() bool { return m.clearedowner } // OwnerID returns the "owner" edge ID in the mutation. -func (m *PrinterMutation) OwnerID() (id string, exists bool) { +func (m *OperatingSystemMutation) OwnerID() (id string, exists bool) { if m.owner != nil { return *m.owner, true } @@ -16949,7 +17204,7 @@ func (m *PrinterMutation) OwnerID() (id string, exists bool) { // OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OwnerID instead. It exists only for internal usage by the builders. -func (m *PrinterMutation) OwnerIDs() (ids []string) { +func (m *OperatingSystemMutation) OwnerIDs() (ids []string) { if id := m.owner; id != nil { ids = append(ids, *id) } @@ -16957,20 +17212,20 @@ func (m *PrinterMutation) OwnerIDs() (ids []string) { } // ResetOwner resets all changes to the "owner" edge. -func (m *PrinterMutation) ResetOwner() { +func (m *OperatingSystemMutation) ResetOwner() { m.owner = nil m.clearedowner = false } -// Where appends a list predicates to the PrinterMutation builder. -func (m *PrinterMutation) Where(ps ...predicate.Printer) { +// Where appends a list predicates to the OperatingSystemMutation builder. +func (m *OperatingSystemMutation) Where(ps ...predicate.OperatingSystem) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the PrinterMutation builder. Using this method, +// WhereP appends storage-level predicates to the OperatingSystemMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PrinterMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Printer, len(ps)) +func (m *OperatingSystemMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.OperatingSystem, len(ps)) for i := range ps { p[i] = ps[i] } @@ -16978,39 +17233,51 @@ func (m *PrinterMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *PrinterMutation) Op() Op { +func (m *OperatingSystemMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *PrinterMutation) SetOp(op Op) { +func (m *OperatingSystemMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Printer). -func (m *PrinterMutation) Type() string { +// Type returns the node type of this mutation (OperatingSystem). +func (m *OperatingSystemMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *PrinterMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.name != nil { - fields = append(fields, printer.FieldName) +func (m *OperatingSystemMutation) Fields() []string { + fields := make([]string, 0, 9) + if m._type != nil { + fields = append(fields, operatingsystem.FieldType) } - if m.port != nil { - fields = append(fields, printer.FieldPort) + if m.version != nil { + fields = append(fields, operatingsystem.FieldVersion) } - if m.is_default != nil { - fields = append(fields, printer.FieldIsDefault) + if m.description != nil { + fields = append(fields, operatingsystem.FieldDescription) } - if m.is_network != nil { - fields = append(fields, printer.FieldIsNetwork) + if m.edition != nil { + fields = append(fields, operatingsystem.FieldEdition) } - if m.is_shared != nil { - fields = append(fields, printer.FieldIsShared) + if m.install_date != nil { + fields = append(fields, operatingsystem.FieldInstallDate) + } + if m.arch != nil { + fields = append(fields, operatingsystem.FieldArch) + } + if m.username != nil { + fields = append(fields, operatingsystem.FieldUsername) + } + if m.last_bootup_time != nil { + fields = append(fields, operatingsystem.FieldLastBootupTime) + } + if m.domain != nil { + fields = append(fields, operatingsystem.FieldDomain) } return fields } @@ -17018,18 +17285,26 @@ func (m *PrinterMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *PrinterMutation) Field(name string) (ent.Value, bool) { +func (m *OperatingSystemMutation) Field(name string) (ent.Value, bool) { switch name { - case printer.FieldName: - return m.Name() - case printer.FieldPort: - return m.Port() - case printer.FieldIsDefault: - return m.IsDefault() - case printer.FieldIsNetwork: - return m.IsNetwork() - case printer.FieldIsShared: - return m.IsShared() + case operatingsystem.FieldType: + return m.GetType() + case operatingsystem.FieldVersion: + return m.Version() + case operatingsystem.FieldDescription: + return m.Description() + case operatingsystem.FieldEdition: + return m.Edition() + case operatingsystem.FieldInstallDate: + return m.InstallDate() + case operatingsystem.FieldArch: + return m.Arch() + case operatingsystem.FieldUsername: + return m.Username() + case operatingsystem.FieldLastBootupTime: + return m.LastBootupTime() + case operatingsystem.FieldDomain: + return m.Domain() } return nil, false } @@ -17037,171 +17312,231 @@ func (m *PrinterMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *PrinterMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *OperatingSystemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case printer.FieldName: - return m.OldName(ctx) - case printer.FieldPort: - return m.OldPort(ctx) - case printer.FieldIsDefault: - return m.OldIsDefault(ctx) - case printer.FieldIsNetwork: - return m.OldIsNetwork(ctx) - case printer.FieldIsShared: - return m.OldIsShared(ctx) + case operatingsystem.FieldType: + return m.OldType(ctx) + case operatingsystem.FieldVersion: + return m.OldVersion(ctx) + case operatingsystem.FieldDescription: + return m.OldDescription(ctx) + case operatingsystem.FieldEdition: + return m.OldEdition(ctx) + case operatingsystem.FieldInstallDate: + return m.OldInstallDate(ctx) + case operatingsystem.FieldArch: + return m.OldArch(ctx) + case operatingsystem.FieldUsername: + return m.OldUsername(ctx) + case operatingsystem.FieldLastBootupTime: + return m.OldLastBootupTime(ctx) + case operatingsystem.FieldDomain: + return m.OldDomain(ctx) } - return nil, fmt.Errorf("unknown Printer field %s", name) + return nil, fmt.Errorf("unknown OperatingSystem field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *PrinterMutation) SetField(name string, value ent.Value) error { +func (m *OperatingSystemMutation) SetField(name string, value ent.Value) error { switch name { - case printer.FieldName: + case operatingsystem.FieldType: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetName(v) + m.SetType(v) return nil - case printer.FieldPort: + case operatingsystem.FieldVersion: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPort(v) + m.SetVersion(v) return nil - case printer.FieldIsDefault: - v, ok := value.(bool) + case operatingsystem.FieldDescription: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsDefault(v) + m.SetDescription(v) return nil - case printer.FieldIsNetwork: - v, ok := value.(bool) + case operatingsystem.FieldEdition: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsNetwork(v) + m.SetEdition(v) return nil - case printer.FieldIsShared: - v, ok := value.(bool) + case operatingsystem.FieldInstallDate: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsShared(v) + m.SetInstallDate(v) return nil - } - return fmt.Errorf("unknown Printer field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PrinterMutation) AddedFields() []string { + case operatingsystem.FieldArch: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArch(v) + return nil + case operatingsystem.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case operatingsystem.FieldLastBootupTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastBootupTime(v) + return nil + case operatingsystem.FieldDomain: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDomain(v) + return nil + } + return fmt.Errorf("unknown OperatingSystem field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *OperatingSystemMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *PrinterMutation) AddedField(name string) (ent.Value, bool) { +func (m *OperatingSystemMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *PrinterMutation) AddField(name string, value ent.Value) error { +func (m *OperatingSystemMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Printer numeric field %s", name) + return fmt.Errorf("unknown OperatingSystem numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *PrinterMutation) ClearedFields() []string { +func (m *OperatingSystemMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(printer.FieldPort) { - fields = append(fields, printer.FieldPort) + if m.FieldCleared(operatingsystem.FieldType) { + fields = append(fields, operatingsystem.FieldType) } - if m.FieldCleared(printer.FieldIsDefault) { - fields = append(fields, printer.FieldIsDefault) + if m.FieldCleared(operatingsystem.FieldEdition) { + fields = append(fields, operatingsystem.FieldEdition) } - if m.FieldCleared(printer.FieldIsNetwork) { - fields = append(fields, printer.FieldIsNetwork) + if m.FieldCleared(operatingsystem.FieldInstallDate) { + fields = append(fields, operatingsystem.FieldInstallDate) } - if m.FieldCleared(printer.FieldIsShared) { - fields = append(fields, printer.FieldIsShared) + if m.FieldCleared(operatingsystem.FieldArch) { + fields = append(fields, operatingsystem.FieldArch) + } + if m.FieldCleared(operatingsystem.FieldLastBootupTime) { + fields = append(fields, operatingsystem.FieldLastBootupTime) + } + if m.FieldCleared(operatingsystem.FieldDomain) { + fields = append(fields, operatingsystem.FieldDomain) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *PrinterMutation) FieldCleared(name string) bool { +func (m *OperatingSystemMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *PrinterMutation) ClearField(name string) error { +func (m *OperatingSystemMutation) ClearField(name string) error { switch name { - case printer.FieldPort: - m.ClearPort() + case operatingsystem.FieldType: + m.ClearType() return nil - case printer.FieldIsDefault: - m.ClearIsDefault() + case operatingsystem.FieldEdition: + m.ClearEdition() return nil - case printer.FieldIsNetwork: - m.ClearIsNetwork() + case operatingsystem.FieldInstallDate: + m.ClearInstallDate() return nil - case printer.FieldIsShared: - m.ClearIsShared() + case operatingsystem.FieldArch: + m.ClearArch() + return nil + case operatingsystem.FieldLastBootupTime: + m.ClearLastBootupTime() + return nil + case operatingsystem.FieldDomain: + m.ClearDomain() return nil } - return fmt.Errorf("unknown Printer nullable field %s", name) + return fmt.Errorf("unknown OperatingSystem nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *PrinterMutation) ResetField(name string) error { +func (m *OperatingSystemMutation) ResetField(name string) error { switch name { - case printer.FieldName: - m.ResetName() + case operatingsystem.FieldType: + m.ResetType() return nil - case printer.FieldPort: - m.ResetPort() + case operatingsystem.FieldVersion: + m.ResetVersion() return nil - case printer.FieldIsDefault: - m.ResetIsDefault() + case operatingsystem.FieldDescription: + m.ResetDescription() return nil - case printer.FieldIsNetwork: - m.ResetIsNetwork() + case operatingsystem.FieldEdition: + m.ResetEdition() return nil - case printer.FieldIsShared: - m.ResetIsShared() + case operatingsystem.FieldInstallDate: + m.ResetInstallDate() + return nil + case operatingsystem.FieldArch: + m.ResetArch() + return nil + case operatingsystem.FieldUsername: + m.ResetUsername() + return nil + case operatingsystem.FieldLastBootupTime: + m.ResetLastBootupTime() + return nil + case operatingsystem.FieldDomain: + m.ResetDomain() return nil } - return fmt.Errorf("unknown Printer field %s", name) + return fmt.Errorf("unknown OperatingSystem field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *PrinterMutation) AddedEdges() []string { +func (m *OperatingSystemMutation) AddedEdges() []string { edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, printer.EdgeOwner) + edges = append(edges, operatingsystem.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *PrinterMutation) AddedIDs(name string) []ent.Value { +func (m *OperatingSystemMutation) AddedIDs(name string) []ent.Value { switch name { - case printer.EdgeOwner: + case operatingsystem.EdgeOwner: if id := m.owner; id != nil { return []ent.Value{*id} } @@ -17210,31 +17545,31 @@ func (m *PrinterMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *PrinterMutation) RemovedEdges() []string { +func (m *OperatingSystemMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *PrinterMutation) RemovedIDs(name string) []ent.Value { +func (m *OperatingSystemMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PrinterMutation) ClearedEdges() []string { +func (m *OperatingSystemMutation) ClearedEdges() []string { edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, printer.EdgeOwner) + edges = append(edges, operatingsystem.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *PrinterMutation) EdgeCleared(name string) bool { +func (m *OperatingSystemMutation) EdgeCleared(name string) bool { switch name { - case printer.EdgeOwner: + case operatingsystem.EdgeOwner: return m.clearedowner } return false @@ -17242,64 +17577,56 @@ func (m *PrinterMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *PrinterMutation) ClearEdge(name string) error { +func (m *OperatingSystemMutation) ClearEdge(name string) error { switch name { - case printer.EdgeOwner: + case operatingsystem.EdgeOwner: m.ClearOwner() return nil } - return fmt.Errorf("unknown Printer unique edge %s", name) + return fmt.Errorf("unknown OperatingSystem unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *PrinterMutation) ResetEdge(name string) error { +func (m *OperatingSystemMutation) ResetEdge(name string) error { switch name { - case printer.EdgeOwner: + case operatingsystem.EdgeOwner: m.ResetOwner() return nil } - return fmt.Errorf("unknown Printer edge %s", name) + return fmt.Errorf("unknown OperatingSystem edge %s", name) } -// ProfileMutation represents an operation that mutates the Profile nodes in the graph. -type ProfileMutation struct { +// OrgMetadataMutation represents an operation that mutates the OrgMetadata nodes in the graph. +type OrgMetadataMutation struct { config - op Op - typ string - id *int - name *string - apply_to_all *bool - _type *profile.Type - disabled *bool - clearedFields map[string]struct{} - tags map[int]struct{} - removedtags map[int]struct{} - clearedtags bool - tasks map[int]struct{} - removedtasks map[int]struct{} - clearedtasks bool - issues map[int]struct{} - removedissues map[int]struct{} - clearedissues bool - site *int - clearedsite bool - done bool - oldValue func(context.Context) (*Profile, error) - predicates []predicate.Profile + op Op + typ string + id *int + name *string + description *string + clearedFields map[string]struct{} + metadata map[int]struct{} + removedmetadata map[int]struct{} + clearedmetadata bool + tenant *int + clearedtenant bool + done bool + oldValue func(context.Context) (*OrgMetadata, error) + predicates []predicate.OrgMetadata } -var _ ent.Mutation = (*ProfileMutation)(nil) +var _ ent.Mutation = (*OrgMetadataMutation)(nil) -// profileOption allows management of the mutation configuration using functional options. -type profileOption func(*ProfileMutation) +// orgmetadataOption allows management of the mutation configuration using functional options. +type orgmetadataOption func(*OrgMetadataMutation) -// newProfileMutation creates new mutation for the Profile entity. -func newProfileMutation(c config, op Op, opts ...profileOption) *ProfileMutation { - m := &ProfileMutation{ +// newOrgMetadataMutation creates new mutation for the OrgMetadata entity. +func newOrgMetadataMutation(c config, op Op, opts ...orgmetadataOption) *OrgMetadataMutation { + m := &OrgMetadataMutation{ config: c, op: op, - typ: TypeProfile, + typ: TypeOrgMetadata, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -17308,20 +17635,20 @@ func newProfileMutation(c config, op Op, opts ...profileOption) *ProfileMutation return m } -// withProfileID sets the ID field of the mutation. -func withProfileID(id int) profileOption { - return func(m *ProfileMutation) { +// withOrgMetadataID sets the ID field of the mutation. +func withOrgMetadataID(id int) orgmetadataOption { + return func(m *OrgMetadataMutation) { var ( err error once sync.Once - value *Profile + value *OrgMetadata ) - m.oldValue = func(ctx context.Context) (*Profile, error) { + m.oldValue = func(ctx context.Context) (*OrgMetadata, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Profile.Get(ctx, id) + value, err = m.Client().OrgMetadata.Get(ctx, id) } }) return value, err @@ -17330,10 +17657,10 @@ func withProfileID(id int) profileOption { } } -// withProfile sets the old Profile of the mutation. -func withProfile(node *Profile) profileOption { - return func(m *ProfileMutation) { - m.oldValue = func(context.Context) (*Profile, error) { +// withOrgMetadata sets the old OrgMetadata of the mutation. +func withOrgMetadata(node *OrgMetadata) orgmetadataOption { + return func(m *OrgMetadataMutation) { + m.oldValue = func(context.Context) (*OrgMetadata, error) { return node, nil } m.id = &node.ID @@ -17342,7 +17669,7 @@ func withProfile(node *Profile) profileOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProfileMutation) Client() *Client { +func (m OrgMetadataMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -17350,7 +17677,7 @@ func (m ProfileMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProfileMutation) Tx() (*Tx, error) { +func (m OrgMetadataMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -17361,7 +17688,7 @@ func (m ProfileMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProfileMutation) ID() (id int, exists bool) { +func (m *OrgMetadataMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -17372,7 +17699,7 @@ func (m *ProfileMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProfileMutation) IDs(ctx context.Context) ([]int, error) { +func (m *OrgMetadataMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -17381,19 +17708,19 @@ func (m *ProfileMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Profile.Query().Where(m.predicates...).IDs(ctx) + return m.Client().OrgMetadata.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetName sets the "name" field. -func (m *ProfileMutation) SetName(s string) { +func (m *OrgMetadataMutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. -func (m *ProfileMutation) Name() (r string, exists bool) { +func (m *OrgMetadataMutation) Name() (r string, exists bool) { v := m.name if v == nil { return @@ -17401,10 +17728,10 @@ func (m *ProfileMutation) Name() (r string, exists bool) { return *v, true } -// OldName returns the old "name" field's value of the Profile entity. -// If the Profile object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the OrgMetadata entity. +// If the OrgMetadata object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProfileMutation) OldName(ctx context.Context) (v string, err error) { +func (m *OrgMetadataMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldName is only allowed on UpdateOne operations") } @@ -17419,378 +17746,192 @@ func (m *ProfileMutation) OldName(ctx context.Context) (v string, err error) { } // ResetName resets all changes to the "name" field. -func (m *ProfileMutation) ResetName() { +func (m *OrgMetadataMutation) ResetName() { m.name = nil } -// SetApplyToAll sets the "apply_to_all" field. -func (m *ProfileMutation) SetApplyToAll(b bool) { - m.apply_to_all = &b -} - -// ApplyToAll returns the value of the "apply_to_all" field in the mutation. -func (m *ProfileMutation) ApplyToAll() (r bool, exists bool) { - v := m.apply_to_all - if v == nil { - return - } - return *v, true -} - -// OldApplyToAll returns the old "apply_to_all" field's value of the Profile entity. -// If the Profile object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProfileMutation) OldApplyToAll(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldApplyToAll is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldApplyToAll requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldApplyToAll: %w", err) - } - return oldValue.ApplyToAll, nil -} - -// ResetApplyToAll resets all changes to the "apply_to_all" field. -func (m *ProfileMutation) ResetApplyToAll() { - m.apply_to_all = nil -} - -// SetType sets the "type" field. -func (m *ProfileMutation) SetType(pr profile.Type) { - m._type = &pr +// SetDescription sets the "description" field. +func (m *OrgMetadataMutation) SetDescription(s string) { + m.description = &s } -// GetType returns the value of the "type" field in the mutation. -func (m *ProfileMutation) GetType() (r profile.Type, exists bool) { - v := m._type +// Description returns the value of the "description" field in the mutation. +func (m *OrgMetadataMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the Profile entity. -// If the Profile object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the OrgMetadata entity. +// If the OrgMetadata object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProfileMutation) OldType(ctx context.Context) (v profile.Type, err error) { +func (m *OrgMetadataMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.Type, nil + return oldValue.Description, nil } -// ClearType clears the value of the "type" field. -func (m *ProfileMutation) ClearType() { - m._type = nil - m.clearedFields[profile.FieldType] = struct{}{} +// ClearDescription clears the value of the "description" field. +func (m *OrgMetadataMutation) ClearDescription() { + m.description = nil + m.clearedFields[orgmetadata.FieldDescription] = struct{}{} } -// TypeCleared returns if the "type" field was cleared in this mutation. -func (m *ProfileMutation) TypeCleared() bool { - _, ok := m.clearedFields[profile.FieldType] +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *OrgMetadataMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[orgmetadata.FieldDescription] return ok } -// ResetType resets all changes to the "type" field. -func (m *ProfileMutation) ResetType() { - m._type = nil - delete(m.clearedFields, profile.FieldType) -} - -// SetDisabled sets the "disabled" field. -func (m *ProfileMutation) SetDisabled(b bool) { - m.disabled = &b -} - -// Disabled returns the value of the "disabled" field in the mutation. -func (m *ProfileMutation) Disabled() (r bool, exists bool) { - v := m.disabled - if v == nil { - return - } - return *v, true -} - -// OldDisabled returns the old "disabled" field's value of the Profile entity. -// If the Profile object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProfileMutation) OldDisabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDisabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDisabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDisabled: %w", err) - } - return oldValue.Disabled, nil -} - -// ResetDisabled resets all changes to the "disabled" field. -func (m *ProfileMutation) ResetDisabled() { - m.disabled = nil +// ResetDescription resets all changes to the "description" field. +func (m *OrgMetadataMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, orgmetadata.FieldDescription) } -// AddTagIDs adds the "tags" edge to the Tag entity by ids. -func (m *ProfileMutation) AddTagIDs(ids ...int) { - if m.tags == nil { - m.tags = make(map[int]struct{}) +// AddMetadatumIDs adds the "metadata" edge to the Metadata entity by ids. +func (m *OrgMetadataMutation) AddMetadatumIDs(ids ...int) { + if m.metadata == nil { + m.metadata = make(map[int]struct{}) } for i := range ids { - m.tags[ids[i]] = struct{}{} + m.metadata[ids[i]] = struct{}{} } } -// ClearTags clears the "tags" edge to the Tag entity. -func (m *ProfileMutation) ClearTags() { - m.clearedtags = true +// ClearMetadata clears the "metadata" edge to the Metadata entity. +func (m *OrgMetadataMutation) ClearMetadata() { + m.clearedmetadata = true } -// TagsCleared reports if the "tags" edge to the Tag entity was cleared. -func (m *ProfileMutation) TagsCleared() bool { - return m.clearedtags +// MetadataCleared reports if the "metadata" edge to the Metadata entity was cleared. +func (m *OrgMetadataMutation) MetadataCleared() bool { + return m.clearedmetadata } -// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. -func (m *ProfileMutation) RemoveTagIDs(ids ...int) { - if m.removedtags == nil { - m.removedtags = make(map[int]struct{}) +// RemoveMetadatumIDs removes the "metadata" edge to the Metadata entity by IDs. +func (m *OrgMetadataMutation) RemoveMetadatumIDs(ids ...int) { + if m.removedmetadata == nil { + m.removedmetadata = make(map[int]struct{}) } for i := range ids { - delete(m.tags, ids[i]) - m.removedtags[ids[i]] = struct{}{} + delete(m.metadata, ids[i]) + m.removedmetadata[ids[i]] = struct{}{} } } -// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. -func (m *ProfileMutation) RemovedTagsIDs() (ids []int) { - for id := range m.removedtags { +// RemovedMetadata returns the removed IDs of the "metadata" edge to the Metadata entity. +func (m *OrgMetadataMutation) RemovedMetadataIDs() (ids []int) { + for id := range m.removedmetadata { ids = append(ids, id) } return } -// TagsIDs returns the "tags" edge IDs in the mutation. -func (m *ProfileMutation) TagsIDs() (ids []int) { - for id := range m.tags { +// MetadataIDs returns the "metadata" edge IDs in the mutation. +func (m *OrgMetadataMutation) MetadataIDs() (ids []int) { + for id := range m.metadata { ids = append(ids, id) } return } -// ResetTags resets all changes to the "tags" edge. -func (m *ProfileMutation) ResetTags() { - m.tags = nil - m.clearedtags = false - m.removedtags = nil +// ResetMetadata resets all changes to the "metadata" edge. +func (m *OrgMetadataMutation) ResetMetadata() { + m.metadata = nil + m.clearedmetadata = false + m.removedmetadata = nil } -// AddTaskIDs adds the "tasks" edge to the Task entity by ids. -func (m *ProfileMutation) AddTaskIDs(ids ...int) { - if m.tasks == nil { - m.tasks = make(map[int]struct{}) - } - for i := range ids { - m.tasks[ids[i]] = struct{}{} - } +// SetTenantID sets the "tenant" edge to the Tenant entity by id. +func (m *OrgMetadataMutation) SetTenantID(id int) { + m.tenant = &id } -// ClearTasks clears the "tasks" edge to the Task entity. -func (m *ProfileMutation) ClearTasks() { - m.clearedtasks = true +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *OrgMetadataMutation) ClearTenant() { + m.clearedtenant = true } -// TasksCleared reports if the "tasks" edge to the Task entity was cleared. -func (m *ProfileMutation) TasksCleared() bool { - return m.clearedtasks +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *OrgMetadataMutation) TenantCleared() bool { + return m.clearedtenant } -// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs. -func (m *ProfileMutation) RemoveTaskIDs(ids ...int) { - if m.removedtasks == nil { - m.removedtasks = make(map[int]struct{}) - } - for i := range ids { - delete(m.tasks, ids[i]) - m.removedtasks[ids[i]] = struct{}{} +// TenantID returns the "tenant" edge ID in the mutation. +func (m *OrgMetadataMutation) TenantID() (id int, exists bool) { + if m.tenant != nil { + return *m.tenant, true } + return } -// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity. -func (m *ProfileMutation) RemovedTasksIDs() (ids []int) { - for id := range m.removedtasks { - ids = append(ids, id) +// TenantIDs returns the "tenant" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TenantID instead. It exists only for internal usage by the builders. +func (m *OrgMetadataMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { + ids = append(ids, *id) } return } -// TasksIDs returns the "tasks" edge IDs in the mutation. -func (m *ProfileMutation) TasksIDs() (ids []int) { - for id := range m.tasks { - ids = append(ids, id) - } - return +// ResetTenant resets all changes to the "tenant" edge. +func (m *OrgMetadataMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false } -// ResetTasks resets all changes to the "tasks" edge. -func (m *ProfileMutation) ResetTasks() { - m.tasks = nil - m.clearedtasks = false - m.removedtasks = nil +// Where appends a list predicates to the OrgMetadataMutation builder. +func (m *OrgMetadataMutation) Where(ps ...predicate.OrgMetadata) { + m.predicates = append(m.predicates, ps...) } -// AddIssueIDs adds the "issues" edge to the ProfileIssue entity by ids. -func (m *ProfileMutation) AddIssueIDs(ids ...int) { - if m.issues == nil { - m.issues = make(map[int]struct{}) - } - for i := range ids { - m.issues[ids[i]] = struct{}{} +// WhereP appends storage-level predicates to the OrgMetadataMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *OrgMetadataMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.OrgMetadata, len(ps)) + for i := range ps { + p[i] = ps[i] } -} - -// ClearIssues clears the "issues" edge to the ProfileIssue entity. -func (m *ProfileMutation) ClearIssues() { - m.clearedissues = true -} - -// IssuesCleared reports if the "issues" edge to the ProfileIssue entity was cleared. -func (m *ProfileMutation) IssuesCleared() bool { - return m.clearedissues -} - -// RemoveIssueIDs removes the "issues" edge to the ProfileIssue entity by IDs. -func (m *ProfileMutation) RemoveIssueIDs(ids ...int) { - if m.removedissues == nil { - m.removedissues = make(map[int]struct{}) - } - for i := range ids { - delete(m.issues, ids[i]) - m.removedissues[ids[i]] = struct{}{} - } -} - -// RemovedIssues returns the removed IDs of the "issues" edge to the ProfileIssue entity. -func (m *ProfileMutation) RemovedIssuesIDs() (ids []int) { - for id := range m.removedissues { - ids = append(ids, id) - } - return -} - -// IssuesIDs returns the "issues" edge IDs in the mutation. -func (m *ProfileMutation) IssuesIDs() (ids []int) { - for id := range m.issues { - ids = append(ids, id) - } - return -} - -// ResetIssues resets all changes to the "issues" edge. -func (m *ProfileMutation) ResetIssues() { - m.issues = nil - m.clearedissues = false - m.removedissues = nil -} - -// SetSiteID sets the "site" edge to the Site entity by id. -func (m *ProfileMutation) SetSiteID(id int) { - m.site = &id -} - -// ClearSite clears the "site" edge to the Site entity. -func (m *ProfileMutation) ClearSite() { - m.clearedsite = true -} - -// SiteCleared reports if the "site" edge to the Site entity was cleared. -func (m *ProfileMutation) SiteCleared() bool { - return m.clearedsite -} - -// SiteID returns the "site" edge ID in the mutation. -func (m *ProfileMutation) SiteID() (id int, exists bool) { - if m.site != nil { - return *m.site, true - } - return -} - -// SiteIDs returns the "site" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// SiteID instead. It exists only for internal usage by the builders. -func (m *ProfileMutation) SiteIDs() (ids []int) { - if id := m.site; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetSite resets all changes to the "site" edge. -func (m *ProfileMutation) ResetSite() { - m.site = nil - m.clearedsite = false -} - -// Where appends a list predicates to the ProfileMutation builder. -func (m *ProfileMutation) Where(ps ...predicate.Profile) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ProfileMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProfileMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Profile, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) + m.Where(p...) } // Op returns the operation name. -func (m *ProfileMutation) Op() Op { +func (m *OrgMetadataMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProfileMutation) SetOp(op Op) { +func (m *OrgMetadataMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Profile). -func (m *ProfileMutation) Type() string { +// Type returns the node type of this mutation (OrgMetadata). +func (m *OrgMetadataMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProfileMutation) Fields() []string { - fields := make([]string, 0, 4) +func (m *OrgMetadataMutation) Fields() []string { + fields := make([]string, 0, 2) if m.name != nil { - fields = append(fields, profile.FieldName) - } - if m.apply_to_all != nil { - fields = append(fields, profile.FieldApplyToAll) - } - if m._type != nil { - fields = append(fields, profile.FieldType) + fields = append(fields, orgmetadata.FieldName) } - if m.disabled != nil { - fields = append(fields, profile.FieldDisabled) + if m.description != nil { + fields = append(fields, orgmetadata.FieldDescription) } return fields } @@ -17798,16 +17939,12 @@ func (m *ProfileMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProfileMutation) Field(name string) (ent.Value, bool) { +func (m *OrgMetadataMutation) Field(name string) (ent.Value, bool) { switch name { - case profile.FieldName: + case orgmetadata.FieldName: return m.Name() - case profile.FieldApplyToAll: - return m.ApplyToAll() - case profile.FieldType: - return m.GetType() - case profile.FieldDisabled: - return m.Disabled() + case orgmetadata.FieldDescription: + return m.Description() } return nil, false } @@ -17815,169 +17952,127 @@ func (m *ProfileMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProfileMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *OrgMetadataMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case profile.FieldName: + case orgmetadata.FieldName: return m.OldName(ctx) - case profile.FieldApplyToAll: - return m.OldApplyToAll(ctx) - case profile.FieldType: - return m.OldType(ctx) - case profile.FieldDisabled: - return m.OldDisabled(ctx) + case orgmetadata.FieldDescription: + return m.OldDescription(ctx) } - return nil, fmt.Errorf("unknown Profile field %s", name) + return nil, fmt.Errorf("unknown OrgMetadata field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProfileMutation) SetField(name string, value ent.Value) error { +func (m *OrgMetadataMutation) SetField(name string, value ent.Value) error { switch name { - case profile.FieldName: + case orgmetadata.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil - case profile.FieldApplyToAll: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetApplyToAll(v) - return nil - case profile.FieldType: - v, ok := value.(profile.Type) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case profile.FieldDisabled: - v, ok := value.(bool) + case orgmetadata.FieldDescription: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDisabled(v) + m.SetDescription(v) return nil } - return fmt.Errorf("unknown Profile field %s", name) + return fmt.Errorf("unknown OrgMetadata field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProfileMutation) AddedFields() []string { +func (m *OrgMetadataMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProfileMutation) AddedField(name string) (ent.Value, bool) { +func (m *OrgMetadataMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProfileMutation) AddField(name string, value ent.Value) error { +func (m *OrgMetadataMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Profile numeric field %s", name) + return fmt.Errorf("unknown OrgMetadata numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProfileMutation) ClearedFields() []string { +func (m *OrgMetadataMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(profile.FieldType) { - fields = append(fields, profile.FieldType) + if m.FieldCleared(orgmetadata.FieldDescription) { + fields = append(fields, orgmetadata.FieldDescription) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProfileMutation) FieldCleared(name string) bool { +func (m *OrgMetadataMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProfileMutation) ClearField(name string) error { +func (m *OrgMetadataMutation) ClearField(name string) error { switch name { - case profile.FieldType: - m.ClearType() + case orgmetadata.FieldDescription: + m.ClearDescription() return nil } - return fmt.Errorf("unknown Profile nullable field %s", name) + return fmt.Errorf("unknown OrgMetadata nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProfileMutation) ResetField(name string) error { +func (m *OrgMetadataMutation) ResetField(name string) error { switch name { - case profile.FieldName: + case orgmetadata.FieldName: m.ResetName() return nil - case profile.FieldApplyToAll: - m.ResetApplyToAll() - return nil - case profile.FieldType: - m.ResetType() - return nil - case profile.FieldDisabled: - m.ResetDisabled() + case orgmetadata.FieldDescription: + m.ResetDescription() return nil } - return fmt.Errorf("unknown Profile field %s", name) + return fmt.Errorf("unknown OrgMetadata field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProfileMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.tags != nil { - edges = append(edges, profile.EdgeTags) - } - if m.tasks != nil { - edges = append(edges, profile.EdgeTasks) - } - if m.issues != nil { - edges = append(edges, profile.EdgeIssues) +func (m *OrgMetadataMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.metadata != nil { + edges = append(edges, orgmetadata.EdgeMetadata) } - if m.site != nil { - edges = append(edges, profile.EdgeSite) + if m.tenant != nil { + edges = append(edges, orgmetadata.EdgeTenant) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProfileMutation) AddedIDs(name string) []ent.Value { +func (m *OrgMetadataMutation) AddedIDs(name string) []ent.Value { switch name { - case profile.EdgeTags: - ids := make([]ent.Value, 0, len(m.tags)) - for id := range m.tags { - ids = append(ids, id) - } - return ids - case profile.EdgeTasks: - ids := make([]ent.Value, 0, len(m.tasks)) - for id := range m.tasks { - ids = append(ids, id) - } - return ids - case profile.EdgeIssues: - ids := make([]ent.Value, 0, len(m.issues)) - for id := range m.issues { + case orgmetadata.EdgeMetadata: + ids := make([]ent.Value, 0, len(m.metadata)) + for id := range m.metadata { ids = append(ids, id) } return ids - case profile.EdgeSite: - if id := m.site; id != nil { + case orgmetadata.EdgeTenant: + if id := m.tenant; id != nil { return []ent.Value{*id} } } @@ -17985,39 +18080,21 @@ func (m *ProfileMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProfileMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedtags != nil { - edges = append(edges, profile.EdgeTags) - } - if m.removedtasks != nil { - edges = append(edges, profile.EdgeTasks) - } - if m.removedissues != nil { - edges = append(edges, profile.EdgeIssues) +func (m *OrgMetadataMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedmetadata != nil { + edges = append(edges, orgmetadata.EdgeMetadata) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProfileMutation) RemovedIDs(name string) []ent.Value { +func (m *OrgMetadataMutation) RemovedIDs(name string) []ent.Value { switch name { - case profile.EdgeTags: - ids := make([]ent.Value, 0, len(m.removedtags)) - for id := range m.removedtags { - ids = append(ids, id) - } - return ids - case profile.EdgeTasks: - ids := make([]ent.Value, 0, len(m.removedtasks)) - for id := range m.removedtasks { - ids = append(ids, id) - } - return ids - case profile.EdgeIssues: - ids := make([]ent.Value, 0, len(m.removedissues)) - for id := range m.removedissues { + case orgmetadata.EdgeMetadata: + ids := make([]ent.Value, 0, len(m.removedmetadata)) + for id := range m.removedmetadata { ids = append(ids, id) } return ids @@ -18026,99 +18103,83 @@ func (m *ProfileMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProfileMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedtags { - edges = append(edges, profile.EdgeTags) - } - if m.clearedtasks { - edges = append(edges, profile.EdgeTasks) - } - if m.clearedissues { - edges = append(edges, profile.EdgeIssues) +func (m *OrgMetadataMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedmetadata { + edges = append(edges, orgmetadata.EdgeMetadata) } - if m.clearedsite { - edges = append(edges, profile.EdgeSite) + if m.clearedtenant { + edges = append(edges, orgmetadata.EdgeTenant) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProfileMutation) EdgeCleared(name string) bool { +func (m *OrgMetadataMutation) EdgeCleared(name string) bool { switch name { - case profile.EdgeTags: - return m.clearedtags - case profile.EdgeTasks: - return m.clearedtasks - case profile.EdgeIssues: - return m.clearedissues - case profile.EdgeSite: - return m.clearedsite + case orgmetadata.EdgeMetadata: + return m.clearedmetadata + case orgmetadata.EdgeTenant: + return m.clearedtenant } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProfileMutation) ClearEdge(name string) error { +func (m *OrgMetadataMutation) ClearEdge(name string) error { switch name { - case profile.EdgeSite: - m.ClearSite() + case orgmetadata.EdgeTenant: + m.ClearTenant() return nil } - return fmt.Errorf("unknown Profile unique edge %s", name) + return fmt.Errorf("unknown OrgMetadata unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProfileMutation) ResetEdge(name string) error { +func (m *OrgMetadataMutation) ResetEdge(name string) error { switch name { - case profile.EdgeTags: - m.ResetTags() - return nil - case profile.EdgeTasks: - m.ResetTasks() - return nil - case profile.EdgeIssues: - m.ResetIssues() + case orgmetadata.EdgeMetadata: + m.ResetMetadata() return nil - case profile.EdgeSite: - m.ResetSite() + case orgmetadata.EdgeTenant: + m.ResetTenant() return nil } - return fmt.Errorf("unknown Profile edge %s", name) + return fmt.Errorf("unknown OrgMetadata edge %s", name) } -// ProfileIssueMutation represents an operation that mutates the ProfileIssue nodes in the graph. -type ProfileIssueMutation struct { +// PhysicalDiskMutation represents an operation that mutates the PhysicalDisk nodes in the graph. +type PhysicalDiskMutation struct { config - op Op - typ string - id *int - error *string - when *time.Time - clearedFields map[string]struct{} - profile *int - clearedprofile bool - agents *string - clearedagents bool - done bool - oldValue func(context.Context) (*ProfileIssue, error) - predicates []predicate.ProfileIssue + op Op + typ string + id *int + device_id *string + model *string + serial_number *string + size_in_units *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*PhysicalDisk, error) + predicates []predicate.PhysicalDisk } -var _ ent.Mutation = (*ProfileIssueMutation)(nil) +var _ ent.Mutation = (*PhysicalDiskMutation)(nil) -// profileissueOption allows management of the mutation configuration using functional options. -type profileissueOption func(*ProfileIssueMutation) +// physicaldiskOption allows management of the mutation configuration using functional options. +type physicaldiskOption func(*PhysicalDiskMutation) -// newProfileIssueMutation creates new mutation for the ProfileIssue entity. -func newProfileIssueMutation(c config, op Op, opts ...profileissueOption) *ProfileIssueMutation { - m := &ProfileIssueMutation{ +// newPhysicalDiskMutation creates new mutation for the PhysicalDisk entity. +func newPhysicalDiskMutation(c config, op Op, opts ...physicaldiskOption) *PhysicalDiskMutation { + m := &PhysicalDiskMutation{ config: c, op: op, - typ: TypeProfileIssue, + typ: TypePhysicalDisk, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -18127,20 +18188,20 @@ func newProfileIssueMutation(c config, op Op, opts ...profileissueOption) *Profi return m } -// withProfileIssueID sets the ID field of the mutation. -func withProfileIssueID(id int) profileissueOption { - return func(m *ProfileIssueMutation) { +// withPhysicalDiskID sets the ID field of the mutation. +func withPhysicalDiskID(id int) physicaldiskOption { + return func(m *PhysicalDiskMutation) { var ( err error once sync.Once - value *ProfileIssue + value *PhysicalDisk ) - m.oldValue = func(ctx context.Context) (*ProfileIssue, error) { + m.oldValue = func(ctx context.Context) (*PhysicalDisk, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().ProfileIssue.Get(ctx, id) + value, err = m.Client().PhysicalDisk.Get(ctx, id) } }) return value, err @@ -18149,10 +18210,10 @@ func withProfileIssueID(id int) profileissueOption { } } -// withProfileIssue sets the old ProfileIssue of the mutation. -func withProfileIssue(node *ProfileIssue) profileissueOption { - return func(m *ProfileIssueMutation) { - m.oldValue = func(context.Context) (*ProfileIssue, error) { +// withPhysicalDisk sets the old PhysicalDisk of the mutation. +func withPhysicalDisk(node *PhysicalDisk) physicaldiskOption { + return func(m *PhysicalDiskMutation) { + m.oldValue = func(context.Context) (*PhysicalDisk, error) { return node, nil } m.id = &node.ID @@ -18161,7 +18222,7 @@ func withProfileIssue(node *ProfileIssue) profileissueOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProfileIssueMutation) Client() *Client { +func (m PhysicalDiskMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -18169,7 +18230,7 @@ func (m ProfileIssueMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProfileIssueMutation) Tx() (*Tx, error) { +func (m PhysicalDiskMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -18180,7 +18241,7 @@ func (m ProfileIssueMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProfileIssueMutation) ID() (id int, exists bool) { +func (m *PhysicalDiskMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -18191,7 +18252,7 @@ func (m *ProfileIssueMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProfileIssueMutation) IDs(ctx context.Context) ([]int, error) { +func (m *PhysicalDiskMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -18200,197 +18261,243 @@ func (m *ProfileIssueMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().ProfileIssue.Query().Where(m.predicates...).IDs(ctx) + return m.Client().PhysicalDisk.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetError sets the "error" field. -func (m *ProfileIssueMutation) SetError(s string) { - m.error = &s +// SetDeviceID sets the "device_id" field. +func (m *PhysicalDiskMutation) SetDeviceID(s string) { + m.device_id = &s } -// Error returns the value of the "error" field in the mutation. -func (m *ProfileIssueMutation) Error() (r string, exists bool) { - v := m.error +// DeviceID returns the value of the "device_id" field in the mutation. +func (m *PhysicalDiskMutation) DeviceID() (r string, exists bool) { + v := m.device_id if v == nil { return } return *v, true } -// OldError returns the old "error" field's value of the ProfileIssue entity. -// If the ProfileIssue object wasn't provided to the builder, the object is fetched from the database. +// OldDeviceID returns the old "device_id" field's value of the PhysicalDisk entity. +// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProfileIssueMutation) OldError(ctx context.Context) (v string, err error) { +func (m *PhysicalDiskMutation) OldDeviceID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldError is only allowed on UpdateOne operations") + return v, errors.New("OldDeviceID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldError requires an ID field in the mutation") + return v, errors.New("OldDeviceID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldError: %w", err) + return v, fmt.Errorf("querying old value for OldDeviceID: %w", err) } - return oldValue.Error, nil -} - -// ClearError clears the value of the "error" field. -func (m *ProfileIssueMutation) ClearError() { - m.error = nil - m.clearedFields[profileissue.FieldError] = struct{}{} -} - -// ErrorCleared returns if the "error" field was cleared in this mutation. -func (m *ProfileIssueMutation) ErrorCleared() bool { - _, ok := m.clearedFields[profileissue.FieldError] - return ok + return oldValue.DeviceID, nil } -// ResetError resets all changes to the "error" field. -func (m *ProfileIssueMutation) ResetError() { - m.error = nil - delete(m.clearedFields, profileissue.FieldError) +// ResetDeviceID resets all changes to the "device_id" field. +func (m *PhysicalDiskMutation) ResetDeviceID() { + m.device_id = nil } -// SetWhen sets the "when" field. -func (m *ProfileIssueMutation) SetWhen(t time.Time) { - m.when = &t +// SetModel sets the "model" field. +func (m *PhysicalDiskMutation) SetModel(s string) { + m.model = &s } -// When returns the value of the "when" field in the mutation. -func (m *ProfileIssueMutation) When() (r time.Time, exists bool) { - v := m.when +// Model returns the value of the "model" field in the mutation. +func (m *PhysicalDiskMutation) Model() (r string, exists bool) { + v := m.model if v == nil { return } return *v, true } -// OldWhen returns the old "when" field's value of the ProfileIssue entity. -// If the ProfileIssue object wasn't provided to the builder, the object is fetched from the database. +// OldModel returns the old "model" field's value of the PhysicalDisk entity. +// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProfileIssueMutation) OldWhen(ctx context.Context) (v time.Time, err error) { +func (m *PhysicalDiskMutation) OldModel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWhen is only allowed on UpdateOne operations") + return v, errors.New("OldModel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWhen requires an ID field in the mutation") + return v, errors.New("OldModel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldWhen: %w", err) + return v, fmt.Errorf("querying old value for OldModel: %w", err) } - return oldValue.When, nil + return oldValue.Model, nil } -// ClearWhen clears the value of the "when" field. -func (m *ProfileIssueMutation) ClearWhen() { - m.when = nil - m.clearedFields[profileissue.FieldWhen] = struct{}{} +// ClearModel clears the value of the "model" field. +func (m *PhysicalDiskMutation) ClearModel() { + m.model = nil + m.clearedFields[physicaldisk.FieldModel] = struct{}{} } -// WhenCleared returns if the "when" field was cleared in this mutation. -func (m *ProfileIssueMutation) WhenCleared() bool { - _, ok := m.clearedFields[profileissue.FieldWhen] +// ModelCleared returns if the "model" field was cleared in this mutation. +func (m *PhysicalDiskMutation) ModelCleared() bool { + _, ok := m.clearedFields[physicaldisk.FieldModel] return ok } -// ResetWhen resets all changes to the "when" field. -func (m *ProfileIssueMutation) ResetWhen() { - m.when = nil - delete(m.clearedFields, profileissue.FieldWhen) -} - -// SetProfileID sets the "profile" edge to the Profile entity by id. -func (m *ProfileIssueMutation) SetProfileID(id int) { - m.profile = &id +// ResetModel resets all changes to the "model" field. +func (m *PhysicalDiskMutation) ResetModel() { + m.model = nil + delete(m.clearedFields, physicaldisk.FieldModel) } -// ClearProfile clears the "profile" edge to the Profile entity. -func (m *ProfileIssueMutation) ClearProfile() { - m.clearedprofile = true +// SetSerialNumber sets the "serial_number" field. +func (m *PhysicalDiskMutation) SetSerialNumber(s string) { + m.serial_number = &s } -// ProfileCleared reports if the "profile" edge to the Profile entity was cleared. -func (m *ProfileIssueMutation) ProfileCleared() bool { - return m.clearedprofile +// SerialNumber returns the value of the "serial_number" field in the mutation. +func (m *PhysicalDiskMutation) SerialNumber() (r string, exists bool) { + v := m.serial_number + if v == nil { + return + } + return *v, true } -// ProfileID returns the "profile" edge ID in the mutation. -func (m *ProfileIssueMutation) ProfileID() (id int, exists bool) { - if m.profile != nil { - return *m.profile, true +// OldSerialNumber returns the old "serial_number" field's value of the PhysicalDisk entity. +// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhysicalDiskMutation) OldSerialNumber(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSerialNumber is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSerialNumber requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSerialNumber: %w", err) + } + return oldValue.SerialNumber, nil } -// ProfileIDs returns the "profile" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ProfileID instead. It exists only for internal usage by the builders. -func (m *ProfileIssueMutation) ProfileIDs() (ids []int) { - if id := m.profile; id != nil { - ids = append(ids, *id) +// ClearSerialNumber clears the value of the "serial_number" field. +func (m *PhysicalDiskMutation) ClearSerialNumber() { + m.serial_number = nil + m.clearedFields[physicaldisk.FieldSerialNumber] = struct{}{} +} + +// SerialNumberCleared returns if the "serial_number" field was cleared in this mutation. +func (m *PhysicalDiskMutation) SerialNumberCleared() bool { + _, ok := m.clearedFields[physicaldisk.FieldSerialNumber] + return ok +} + +// ResetSerialNumber resets all changes to the "serial_number" field. +func (m *PhysicalDiskMutation) ResetSerialNumber() { + m.serial_number = nil + delete(m.clearedFields, physicaldisk.FieldSerialNumber) +} + +// SetSizeInUnits sets the "size_in_units" field. +func (m *PhysicalDiskMutation) SetSizeInUnits(s string) { + m.size_in_units = &s +} + +// SizeInUnits returns the value of the "size_in_units" field in the mutation. +func (m *PhysicalDiskMutation) SizeInUnits() (r string, exists bool) { + v := m.size_in_units + if v == nil { + return } - return + return *v, true } -// ResetProfile resets all changes to the "profile" edge. -func (m *ProfileIssueMutation) ResetProfile() { - m.profile = nil - m.clearedprofile = false +// OldSizeInUnits returns the old "size_in_units" field's value of the PhysicalDisk entity. +// If the PhysicalDisk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PhysicalDiskMutation) OldSizeInUnits(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSizeInUnits is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSizeInUnits requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSizeInUnits: %w", err) + } + return oldValue.SizeInUnits, nil } -// SetAgentsID sets the "agents" edge to the Agent entity by id. -func (m *ProfileIssueMutation) SetAgentsID(id string) { - m.agents = &id +// ClearSizeInUnits clears the value of the "size_in_units" field. +func (m *PhysicalDiskMutation) ClearSizeInUnits() { + m.size_in_units = nil + m.clearedFields[physicaldisk.FieldSizeInUnits] = struct{}{} } -// ClearAgents clears the "agents" edge to the Agent entity. -func (m *ProfileIssueMutation) ClearAgents() { - m.clearedagents = true +// SizeInUnitsCleared returns if the "size_in_units" field was cleared in this mutation. +func (m *PhysicalDiskMutation) SizeInUnitsCleared() bool { + _, ok := m.clearedFields[physicaldisk.FieldSizeInUnits] + return ok } -// AgentsCleared reports if the "agents" edge to the Agent entity was cleared. -func (m *ProfileIssueMutation) AgentsCleared() bool { - return m.clearedagents +// ResetSizeInUnits resets all changes to the "size_in_units" field. +func (m *PhysicalDiskMutation) ResetSizeInUnits() { + m.size_in_units = nil + delete(m.clearedFields, physicaldisk.FieldSizeInUnits) } -// AgentsID returns the "agents" edge ID in the mutation. -func (m *ProfileIssueMutation) AgentsID() (id string, exists bool) { - if m.agents != nil { - return *m.agents, true +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *PhysicalDiskMutation) SetOwnerID(id string) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *PhysicalDiskMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *PhysicalDiskMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *PhysicalDiskMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true } return } -// AgentsIDs returns the "agents" edge IDs in the mutation. +// OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// AgentsID instead. It exists only for internal usage by the builders. -func (m *ProfileIssueMutation) AgentsIDs() (ids []string) { - if id := m.agents; id != nil { +// OwnerID instead. It exists only for internal usage by the builders. +func (m *PhysicalDiskMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { ids = append(ids, *id) } return } -// ResetAgents resets all changes to the "agents" edge. -func (m *ProfileIssueMutation) ResetAgents() { - m.agents = nil - m.clearedagents = false +// ResetOwner resets all changes to the "owner" edge. +func (m *PhysicalDiskMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// Where appends a list predicates to the ProfileIssueMutation builder. -func (m *ProfileIssueMutation) Where(ps ...predicate.ProfileIssue) { +// Where appends a list predicates to the PhysicalDiskMutation builder. +func (m *PhysicalDiskMutation) Where(ps ...predicate.PhysicalDisk) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProfileIssueMutation builder. Using this method, +// WhereP appends storage-level predicates to the PhysicalDiskMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProfileIssueMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.ProfileIssue, len(ps)) +func (m *PhysicalDiskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PhysicalDisk, len(ps)) for i := range ps { p[i] = ps[i] } @@ -18398,30 +18505,36 @@ func (m *ProfileIssueMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProfileIssueMutation) Op() Op { +func (m *PhysicalDiskMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProfileIssueMutation) SetOp(op Op) { +func (m *PhysicalDiskMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (ProfileIssue). -func (m *ProfileIssueMutation) Type() string { +// Type returns the node type of this mutation (PhysicalDisk). +func (m *PhysicalDiskMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProfileIssueMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.error != nil { - fields = append(fields, profileissue.FieldError) +func (m *PhysicalDiskMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.device_id != nil { + fields = append(fields, physicaldisk.FieldDeviceID) } - if m.when != nil { - fields = append(fields, profileissue.FieldWhen) + if m.model != nil { + fields = append(fields, physicaldisk.FieldModel) + } + if m.serial_number != nil { + fields = append(fields, physicaldisk.FieldSerialNumber) + } + if m.size_in_units != nil { + fields = append(fields, physicaldisk.FieldSizeInUnits) } return fields } @@ -18429,12 +18542,16 @@ func (m *ProfileIssueMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProfileIssueMutation) Field(name string) (ent.Value, bool) { +func (m *PhysicalDiskMutation) Field(name string) (ent.Value, bool) { switch name { - case profileissue.FieldError: - return m.Error() - case profileissue.FieldWhen: - return m.When() + case physicaldisk.FieldDeviceID: + return m.DeviceID() + case physicaldisk.FieldModel: + return m.Model() + case physicaldisk.FieldSerialNumber: + return m.SerialNumber() + case physicaldisk.FieldSizeInUnits: + return m.SizeInUnits() } return nil, false } @@ -18442,131 +18559,154 @@ func (m *ProfileIssueMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProfileIssueMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *PhysicalDiskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case profileissue.FieldError: - return m.OldError(ctx) - case profileissue.FieldWhen: - return m.OldWhen(ctx) + case physicaldisk.FieldDeviceID: + return m.OldDeviceID(ctx) + case physicaldisk.FieldModel: + return m.OldModel(ctx) + case physicaldisk.FieldSerialNumber: + return m.OldSerialNumber(ctx) + case physicaldisk.FieldSizeInUnits: + return m.OldSizeInUnits(ctx) } - return nil, fmt.Errorf("unknown ProfileIssue field %s", name) + return nil, fmt.Errorf("unknown PhysicalDisk field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProfileIssueMutation) SetField(name string, value ent.Value) error { +func (m *PhysicalDiskMutation) SetField(name string, value ent.Value) error { switch name { - case profileissue.FieldError: + case physicaldisk.FieldDeviceID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetError(v) + m.SetDeviceID(v) return nil - case profileissue.FieldWhen: - v, ok := value.(time.Time) + case physicaldisk.FieldModel: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetWhen(v) + m.SetModel(v) + return nil + case physicaldisk.FieldSerialNumber: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSerialNumber(v) + return nil + case physicaldisk.FieldSizeInUnits: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSizeInUnits(v) return nil } - return fmt.Errorf("unknown ProfileIssue field %s", name) + return fmt.Errorf("unknown PhysicalDisk field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProfileIssueMutation) AddedFields() []string { +func (m *PhysicalDiskMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProfileIssueMutation) AddedField(name string) (ent.Value, bool) { +func (m *PhysicalDiskMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProfileIssueMutation) AddField(name string, value ent.Value) error { +func (m *PhysicalDiskMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown ProfileIssue numeric field %s", name) + return fmt.Errorf("unknown PhysicalDisk numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProfileIssueMutation) ClearedFields() []string { +func (m *PhysicalDiskMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(profileissue.FieldError) { - fields = append(fields, profileissue.FieldError) + if m.FieldCleared(physicaldisk.FieldModel) { + fields = append(fields, physicaldisk.FieldModel) } - if m.FieldCleared(profileissue.FieldWhen) { - fields = append(fields, profileissue.FieldWhen) + if m.FieldCleared(physicaldisk.FieldSerialNumber) { + fields = append(fields, physicaldisk.FieldSerialNumber) + } + if m.FieldCleared(physicaldisk.FieldSizeInUnits) { + fields = append(fields, physicaldisk.FieldSizeInUnits) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProfileIssueMutation) FieldCleared(name string) bool { +func (m *PhysicalDiskMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProfileIssueMutation) ClearField(name string) error { +func (m *PhysicalDiskMutation) ClearField(name string) error { switch name { - case profileissue.FieldError: - m.ClearError() + case physicaldisk.FieldModel: + m.ClearModel() return nil - case profileissue.FieldWhen: - m.ClearWhen() + case physicaldisk.FieldSerialNumber: + m.ClearSerialNumber() + return nil + case physicaldisk.FieldSizeInUnits: + m.ClearSizeInUnits() return nil } - return fmt.Errorf("unknown ProfileIssue nullable field %s", name) + return fmt.Errorf("unknown PhysicalDisk nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProfileIssueMutation) ResetField(name string) error { +func (m *PhysicalDiskMutation) ResetField(name string) error { switch name { - case profileissue.FieldError: - m.ResetError() + case physicaldisk.FieldDeviceID: + m.ResetDeviceID() return nil - case profileissue.FieldWhen: - m.ResetWhen() + case physicaldisk.FieldModel: + m.ResetModel() + return nil + case physicaldisk.FieldSerialNumber: + m.ResetSerialNumber() + return nil + case physicaldisk.FieldSizeInUnits: + m.ResetSizeInUnits() return nil } - return fmt.Errorf("unknown ProfileIssue field %s", name) + return fmt.Errorf("unknown PhysicalDisk field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProfileIssueMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.profile != nil { - edges = append(edges, profileissue.EdgeProfile) - } - if m.agents != nil { - edges = append(edges, profileissue.EdgeAgents) +func (m *PhysicalDiskMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.owner != nil { + edges = append(edges, physicaldisk.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProfileIssueMutation) AddedIDs(name string) []ent.Value { +func (m *PhysicalDiskMutation) AddedIDs(name string) []ent.Value { switch name { - case profileissue.EdgeProfile: - if id := m.profile; id != nil { - return []ent.Value{*id} - } - case profileissue.EdgeAgents: - if id := m.agents; id != nil { + case physicaldisk.EdgeOwner: + if id := m.owner; id != nil { return []ent.Value{*id} } } @@ -18574,96 +18714,88 @@ func (m *ProfileIssueMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProfileIssueMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *PhysicalDiskMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProfileIssueMutation) RemovedIDs(name string) []ent.Value { +func (m *PhysicalDiskMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProfileIssueMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedprofile { - edges = append(edges, profileissue.EdgeProfile) - } - if m.clearedagents { - edges = append(edges, profileissue.EdgeAgents) +func (m *PhysicalDiskMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedowner { + edges = append(edges, physicaldisk.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProfileIssueMutation) EdgeCleared(name string) bool { +func (m *PhysicalDiskMutation) EdgeCleared(name string) bool { switch name { - case profileissue.EdgeProfile: - return m.clearedprofile - case profileissue.EdgeAgents: - return m.clearedagents + case physicaldisk.EdgeOwner: + return m.clearedowner } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProfileIssueMutation) ClearEdge(name string) error { +func (m *PhysicalDiskMutation) ClearEdge(name string) error { switch name { - case profileissue.EdgeProfile: - m.ClearProfile() - return nil - case profileissue.EdgeAgents: - m.ClearAgents() + case physicaldisk.EdgeOwner: + m.ClearOwner() return nil } - return fmt.Errorf("unknown ProfileIssue unique edge %s", name) + return fmt.Errorf("unknown PhysicalDisk unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProfileIssueMutation) ResetEdge(name string) error { +func (m *PhysicalDiskMutation) ResetEdge(name string) error { switch name { - case profileissue.EdgeProfile: - m.ResetProfile() - return nil - case profileissue.EdgeAgents: - m.ResetAgents() + case physicaldisk.EdgeOwner: + m.ResetOwner() return nil } - return fmt.Errorf("unknown ProfileIssue edge %s", name) + return fmt.Errorf("unknown PhysicalDisk edge %s", name) } -// RecoveryCodeMutation represents an operation that mutates the RecoveryCode nodes in the graph. -type RecoveryCodeMutation struct { +// PrinterMutation represents an operation that mutates the Printer nodes in the graph. +type PrinterMutation struct { config op Op typ string id *int - code *string - used *bool + name *string + port *string + is_default *bool + is_network *bool + is_shared *bool clearedFields map[string]struct{} - user *string - cleareduser bool + owner *string + clearedowner bool done bool - oldValue func(context.Context) (*RecoveryCode, error) - predicates []predicate.RecoveryCode + oldValue func(context.Context) (*Printer, error) + predicates []predicate.Printer } -var _ ent.Mutation = (*RecoveryCodeMutation)(nil) +var _ ent.Mutation = (*PrinterMutation)(nil) -// recoverycodeOption allows management of the mutation configuration using functional options. -type recoverycodeOption func(*RecoveryCodeMutation) +// printerOption allows management of the mutation configuration using functional options. +type printerOption func(*PrinterMutation) -// newRecoveryCodeMutation creates new mutation for the RecoveryCode entity. -func newRecoveryCodeMutation(c config, op Op, opts ...recoverycodeOption) *RecoveryCodeMutation { - m := &RecoveryCodeMutation{ +// newPrinterMutation creates new mutation for the Printer entity. +func newPrinterMutation(c config, op Op, opts ...printerOption) *PrinterMutation { + m := &PrinterMutation{ config: c, op: op, - typ: TypeRecoveryCode, + typ: TypePrinter, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -18672,20 +18804,20 @@ func newRecoveryCodeMutation(c config, op Op, opts ...recoverycodeOption) *Recov return m } -// withRecoveryCodeID sets the ID field of the mutation. -func withRecoveryCodeID(id int) recoverycodeOption { - return func(m *RecoveryCodeMutation) { +// withPrinterID sets the ID field of the mutation. +func withPrinterID(id int) printerOption { + return func(m *PrinterMutation) { var ( err error once sync.Once - value *RecoveryCode + value *Printer ) - m.oldValue = func(ctx context.Context) (*RecoveryCode, error) { + m.oldValue = func(ctx context.Context) (*Printer, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().RecoveryCode.Get(ctx, id) + value, err = m.Client().Printer.Get(ctx, id) } }) return value, err @@ -18694,10 +18826,10 @@ func withRecoveryCodeID(id int) recoverycodeOption { } } -// withRecoveryCode sets the old RecoveryCode of the mutation. -func withRecoveryCode(node *RecoveryCode) recoverycodeOption { - return func(m *RecoveryCodeMutation) { - m.oldValue = func(context.Context) (*RecoveryCode, error) { +// withPrinter sets the old Printer of the mutation. +func withPrinter(node *Printer) printerOption { + return func(m *PrinterMutation) { + m.oldValue = func(context.Context) (*Printer, error) { return node, nil } m.id = &node.ID @@ -18706,7 +18838,7 @@ func withRecoveryCode(node *RecoveryCode) recoverycodeOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m RecoveryCodeMutation) Client() *Client { +func (m PrinterMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -18714,7 +18846,7 @@ func (m RecoveryCodeMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m RecoveryCodeMutation) Tx() (*Tx, error) { +func (m PrinterMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -18725,7 +18857,7 @@ func (m RecoveryCodeMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *RecoveryCodeMutation) ID() (id int, exists bool) { +func (m *PrinterMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -18736,7 +18868,7 @@ func (m *RecoveryCodeMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *RecoveryCodeMutation) IDs(ctx context.Context) ([]int, error) { +func (m *PrinterMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -18745,132 +18877,292 @@ func (m *RecoveryCodeMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().RecoveryCode.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Printer.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetCode sets the "code" field. -func (m *RecoveryCodeMutation) SetCode(s string) { - m.code = &s +// SetName sets the "name" field. +func (m *PrinterMutation) SetName(s string) { + m.name = &s } -// Code returns the value of the "code" field in the mutation. -func (m *RecoveryCodeMutation) Code() (r string, exists bool) { - v := m.code +// Name returns the value of the "name" field in the mutation. +func (m *PrinterMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldCode returns the old "code" field's value of the RecoveryCode entity. -// If the RecoveryCode object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Printer entity. +// If the Printer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RecoveryCodeMutation) OldCode(ctx context.Context) (v string, err error) { +func (m *PrinterMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCode is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCode requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCode: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Code, nil + return oldValue.Name, nil } -// ResetCode resets all changes to the "code" field. -func (m *RecoveryCodeMutation) ResetCode() { - m.code = nil +// ResetName resets all changes to the "name" field. +func (m *PrinterMutation) ResetName() { + m.name = nil } -// SetUsed sets the "used" field. -func (m *RecoveryCodeMutation) SetUsed(b bool) { - m.used = &b +// SetPort sets the "port" field. +func (m *PrinterMutation) SetPort(s string) { + m.port = &s } -// Used returns the value of the "used" field in the mutation. -func (m *RecoveryCodeMutation) Used() (r bool, exists bool) { - v := m.used +// Port returns the value of the "port" field in the mutation. +func (m *PrinterMutation) Port() (r string, exists bool) { + v := m.port if v == nil { return } return *v, true } -// OldUsed returns the old "used" field's value of the RecoveryCode entity. -// If the RecoveryCode object wasn't provided to the builder, the object is fetched from the database. +// OldPort returns the old "port" field's value of the Printer entity. +// If the Printer object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RecoveryCodeMutation) OldUsed(ctx context.Context) (v bool, err error) { +func (m *PrinterMutation) OldPort(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsed is only allowed on UpdateOne operations") + return v, errors.New("OldPort is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsed requires an ID field in the mutation") + return v, errors.New("OldPort requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUsed: %w", err) + return v, fmt.Errorf("querying old value for OldPort: %w", err) } - return oldValue.Used, nil + return oldValue.Port, nil } -// ResetUsed resets all changes to the "used" field. -func (m *RecoveryCodeMutation) ResetUsed() { - m.used = nil +// ClearPort clears the value of the "port" field. +func (m *PrinterMutation) ClearPort() { + m.port = nil + m.clearedFields[printer.FieldPort] = struct{}{} } -// SetUserID sets the "user" edge to the User entity by id. -func (m *RecoveryCodeMutation) SetUserID(id string) { - m.user = &id +// PortCleared returns if the "port" field was cleared in this mutation. +func (m *PrinterMutation) PortCleared() bool { + _, ok := m.clearedFields[printer.FieldPort] + return ok } -// ClearUser clears the "user" edge to the User entity. -func (m *RecoveryCodeMutation) ClearUser() { - m.cleareduser = true +// ResetPort resets all changes to the "port" field. +func (m *PrinterMutation) ResetPort() { + m.port = nil + delete(m.clearedFields, printer.FieldPort) } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *RecoveryCodeMutation) UserCleared() bool { - return m.cleareduser +// SetIsDefault sets the "is_default" field. +func (m *PrinterMutation) SetIsDefault(b bool) { + m.is_default = &b } -// UserID returns the "user" edge ID in the mutation. -func (m *RecoveryCodeMutation) UserID() (id string, exists bool) { - if m.user != nil { - return *m.user, true +// IsDefault returns the value of the "is_default" field in the mutation. +func (m *PrinterMutation) IsDefault() (r bool, exists bool) { + v := m.is_default + if v == nil { + return + } + return *v, true +} + +// OldIsDefault returns the old "is_default" field's value of the Printer entity. +// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PrinterMutation) OldIsDefault(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDefault requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) + } + return oldValue.IsDefault, nil +} + +// ClearIsDefault clears the value of the "is_default" field. +func (m *PrinterMutation) ClearIsDefault() { + m.is_default = nil + m.clearedFields[printer.FieldIsDefault] = struct{}{} +} + +// IsDefaultCleared returns if the "is_default" field was cleared in this mutation. +func (m *PrinterMutation) IsDefaultCleared() bool { + _, ok := m.clearedFields[printer.FieldIsDefault] + return ok +} + +// ResetIsDefault resets all changes to the "is_default" field. +func (m *PrinterMutation) ResetIsDefault() { + m.is_default = nil + delete(m.clearedFields, printer.FieldIsDefault) +} + +// SetIsNetwork sets the "is_network" field. +func (m *PrinterMutation) SetIsNetwork(b bool) { + m.is_network = &b +} + +// IsNetwork returns the value of the "is_network" field in the mutation. +func (m *PrinterMutation) IsNetwork() (r bool, exists bool) { + v := m.is_network + if v == nil { + return + } + return *v, true +} + +// OldIsNetwork returns the old "is_network" field's value of the Printer entity. +// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PrinterMutation) OldIsNetwork(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsNetwork is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsNetwork requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsNetwork: %w", err) + } + return oldValue.IsNetwork, nil +} + +// ClearIsNetwork clears the value of the "is_network" field. +func (m *PrinterMutation) ClearIsNetwork() { + m.is_network = nil + m.clearedFields[printer.FieldIsNetwork] = struct{}{} +} + +// IsNetworkCleared returns if the "is_network" field was cleared in this mutation. +func (m *PrinterMutation) IsNetworkCleared() bool { + _, ok := m.clearedFields[printer.FieldIsNetwork] + return ok +} + +// ResetIsNetwork resets all changes to the "is_network" field. +func (m *PrinterMutation) ResetIsNetwork() { + m.is_network = nil + delete(m.clearedFields, printer.FieldIsNetwork) +} + +// SetIsShared sets the "is_shared" field. +func (m *PrinterMutation) SetIsShared(b bool) { + m.is_shared = &b +} + +// IsShared returns the value of the "is_shared" field in the mutation. +func (m *PrinterMutation) IsShared() (r bool, exists bool) { + v := m.is_shared + if v == nil { + return + } + return *v, true +} + +// OldIsShared returns the old "is_shared" field's value of the Printer entity. +// If the Printer object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PrinterMutation) OldIsShared(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsShared is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsShared requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsShared: %w", err) + } + return oldValue.IsShared, nil +} + +// ClearIsShared clears the value of the "is_shared" field. +func (m *PrinterMutation) ClearIsShared() { + m.is_shared = nil + m.clearedFields[printer.FieldIsShared] = struct{}{} +} + +// IsSharedCleared returns if the "is_shared" field was cleared in this mutation. +func (m *PrinterMutation) IsSharedCleared() bool { + _, ok := m.clearedFields[printer.FieldIsShared] + return ok +} + +// ResetIsShared resets all changes to the "is_shared" field. +func (m *PrinterMutation) ResetIsShared() { + m.is_shared = nil + delete(m.clearedFields, printer.FieldIsShared) +} + +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *PrinterMutation) SetOwnerID(id string) { + m.owner = &id +} + +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *PrinterMutation) ClearOwner() { + m.clearedowner = true +} + +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *PrinterMutation) OwnerCleared() bool { + return m.clearedowner +} + +// OwnerID returns the "owner" edge ID in the mutation. +func (m *PrinterMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true } return } -// UserIDs returns the "user" edge IDs in the mutation. +// OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *RecoveryCodeMutation) UserIDs() (ids []string) { - if id := m.user; id != nil { +// OwnerID instead. It exists only for internal usage by the builders. +func (m *PrinterMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { ids = append(ids, *id) } return } -// ResetUser resets all changes to the "user" edge. -func (m *RecoveryCodeMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// ResetOwner resets all changes to the "owner" edge. +func (m *PrinterMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// Where appends a list predicates to the RecoveryCodeMutation builder. -func (m *RecoveryCodeMutation) Where(ps ...predicate.RecoveryCode) { +// Where appends a list predicates to the PrinterMutation builder. +func (m *PrinterMutation) Where(ps ...predicate.Printer) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the RecoveryCodeMutation builder. Using this method, +// WhereP appends storage-level predicates to the PrinterMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RecoveryCodeMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.RecoveryCode, len(ps)) +func (m *PrinterMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Printer, len(ps)) for i := range ps { p[i] = ps[i] } @@ -18878,30 +19170,39 @@ func (m *RecoveryCodeMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *RecoveryCodeMutation) Op() Op { +func (m *PrinterMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *RecoveryCodeMutation) SetOp(op Op) { +func (m *PrinterMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (RecoveryCode). -func (m *RecoveryCodeMutation) Type() string { +// Type returns the node type of this mutation (Printer). +func (m *PrinterMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *RecoveryCodeMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.code != nil { - fields = append(fields, recoverycode.FieldCode) +func (m *PrinterMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.name != nil { + fields = append(fields, printer.FieldName) } - if m.used != nil { - fields = append(fields, recoverycode.FieldUsed) + if m.port != nil { + fields = append(fields, printer.FieldPort) + } + if m.is_default != nil { + fields = append(fields, printer.FieldIsDefault) + } + if m.is_network != nil { + fields = append(fields, printer.FieldIsNetwork) + } + if m.is_shared != nil { + fields = append(fields, printer.FieldIsShared) } return fields } @@ -18909,12 +19210,18 @@ func (m *RecoveryCodeMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *RecoveryCodeMutation) Field(name string) (ent.Value, bool) { +func (m *PrinterMutation) Field(name string) (ent.Value, bool) { switch name { - case recoverycode.FieldCode: - return m.Code() - case recoverycode.FieldUsed: - return m.Used() + case printer.FieldName: + return m.Name() + case printer.FieldPort: + return m.Port() + case printer.FieldIsDefault: + return m.IsDefault() + case printer.FieldIsNetwork: + return m.IsNetwork() + case printer.FieldIsShared: + return m.IsShared() } return nil, false } @@ -18922,109 +19229,172 @@ func (m *RecoveryCodeMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *RecoveryCodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *PrinterMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case recoverycode.FieldCode: - return m.OldCode(ctx) - case recoverycode.FieldUsed: - return m.OldUsed(ctx) + case printer.FieldName: + return m.OldName(ctx) + case printer.FieldPort: + return m.OldPort(ctx) + case printer.FieldIsDefault: + return m.OldIsDefault(ctx) + case printer.FieldIsNetwork: + return m.OldIsNetwork(ctx) + case printer.FieldIsShared: + return m.OldIsShared(ctx) } - return nil, fmt.Errorf("unknown RecoveryCode field %s", name) + return nil, fmt.Errorf("unknown Printer field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RecoveryCodeMutation) SetField(name string, value ent.Value) error { +func (m *PrinterMutation) SetField(name string, value ent.Value) error { switch name { - case recoverycode.FieldCode: + case printer.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCode(v) + m.SetName(v) return nil - case recoverycode.FieldUsed: + case printer.FieldPort: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPort(v) + return nil + case printer.FieldIsDefault: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUsed(v) + m.SetIsDefault(v) + return nil + case printer.FieldIsNetwork: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsNetwork(v) + return nil + case printer.FieldIsShared: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsShared(v) return nil } - return fmt.Errorf("unknown RecoveryCode field %s", name) + return fmt.Errorf("unknown Printer field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *RecoveryCodeMutation) AddedFields() []string { +func (m *PrinterMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *RecoveryCodeMutation) AddedField(name string) (ent.Value, bool) { +func (m *PrinterMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RecoveryCodeMutation) AddField(name string, value ent.Value) error { +func (m *PrinterMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown RecoveryCode numeric field %s", name) + return fmt.Errorf("unknown Printer numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *RecoveryCodeMutation) ClearedFields() []string { - return nil +func (m *PrinterMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(printer.FieldPort) { + fields = append(fields, printer.FieldPort) + } + if m.FieldCleared(printer.FieldIsDefault) { + fields = append(fields, printer.FieldIsDefault) + } + if m.FieldCleared(printer.FieldIsNetwork) { + fields = append(fields, printer.FieldIsNetwork) + } + if m.FieldCleared(printer.FieldIsShared) { + fields = append(fields, printer.FieldIsShared) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *RecoveryCodeMutation) FieldCleared(name string) bool { +func (m *PrinterMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *RecoveryCodeMutation) ClearField(name string) error { - return fmt.Errorf("unknown RecoveryCode nullable field %s", name) +func (m *PrinterMutation) ClearField(name string) error { + switch name { + case printer.FieldPort: + m.ClearPort() + return nil + case printer.FieldIsDefault: + m.ClearIsDefault() + return nil + case printer.FieldIsNetwork: + m.ClearIsNetwork() + return nil + case printer.FieldIsShared: + m.ClearIsShared() + return nil + } + return fmt.Errorf("unknown Printer nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *RecoveryCodeMutation) ResetField(name string) error { +func (m *PrinterMutation) ResetField(name string) error { switch name { - case recoverycode.FieldCode: - m.ResetCode() + case printer.FieldName: + m.ResetName() return nil - case recoverycode.FieldUsed: - m.ResetUsed() + case printer.FieldPort: + m.ResetPort() + return nil + case printer.FieldIsDefault: + m.ResetIsDefault() + return nil + case printer.FieldIsNetwork: + m.ResetIsNetwork() + return nil + case printer.FieldIsShared: + m.ResetIsShared() return nil } - return fmt.Errorf("unknown RecoveryCode field %s", name) + return fmt.Errorf("unknown Printer field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *RecoveryCodeMutation) AddedEdges() []string { +func (m *PrinterMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.user != nil { - edges = append(edges, recoverycode.EdgeUser) + if m.owner != nil { + edges = append(edges, printer.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *RecoveryCodeMutation) AddedIDs(name string) []ent.Value { +func (m *PrinterMutation) AddedIDs(name string) []ent.Value { switch name { - case recoverycode.EdgeUser: - if id := m.user; id != nil { + case printer.EdgeOwner: + if id := m.owner; id != nil { return []ent.Value{*id} } } @@ -19032,95 +19402,96 @@ func (m *RecoveryCodeMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *RecoveryCodeMutation) RemovedEdges() []string { +func (m *PrinterMutation) RemovedEdges() []string { edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *RecoveryCodeMutation) RemovedIDs(name string) []ent.Value { +func (m *PrinterMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RecoveryCodeMutation) ClearedEdges() []string { +func (m *PrinterMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.cleareduser { - edges = append(edges, recoverycode.EdgeUser) + if m.clearedowner { + edges = append(edges, printer.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *RecoveryCodeMutation) EdgeCleared(name string) bool { +func (m *PrinterMutation) EdgeCleared(name string) bool { switch name { - case recoverycode.EdgeUser: - return m.cleareduser + case printer.EdgeOwner: + return m.clearedowner } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *RecoveryCodeMutation) ClearEdge(name string) error { +func (m *PrinterMutation) ClearEdge(name string) error { switch name { - case recoverycode.EdgeUser: - m.ClearUser() + case printer.EdgeOwner: + m.ClearOwner() return nil } - return fmt.Errorf("unknown RecoveryCode unique edge %s", name) + return fmt.Errorf("unknown Printer unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *RecoveryCodeMutation) ResetEdge(name string) error { +func (m *PrinterMutation) ResetEdge(name string) error { switch name { - case recoverycode.EdgeUser: - m.ResetUser() + case printer.EdgeOwner: + m.ResetOwner() return nil } - return fmt.Errorf("unknown RecoveryCode edge %s", name) + return fmt.Errorf("unknown Printer edge %s", name) } -// ReleaseMutation represents an operation that mutates the Release nodes in the graph. -type ReleaseMutation struct { +// ProfileMutation represents an operation that mutates the Profile nodes in the graph. +type ProfileMutation struct { config op Op typ string id *int - release_type *release.ReleaseType - version *string - channel *string - summary *string - release_notes *string - file_url *string - checksum *string - is_critical *bool - release_date *time.Time - os *string - arch *string + name *string + apply_to_all *bool + disabled *bool + _type *profile.Type clearedFields map[string]struct{} - agents map[string]struct{} - removedagents map[string]struct{} - clearedagents bool + tags map[int]struct{} + removedtags map[int]struct{} + clearedtags bool + tasks map[int]struct{} + removedtasks map[int]struct{} + clearedtasks bool + issues map[int]struct{} + removedissues map[int]struct{} + clearedissues bool + site *int + clearedsite bool done bool - oldValue func(context.Context) (*Release, error) - predicates []predicate.Release + oldValue func(context.Context) (*Profile, error) + predicates []predicate.Profile } -var _ ent.Mutation = (*ReleaseMutation)(nil) +var _ ent.Mutation = (*ProfileMutation)(nil) -// releaseOption allows management of the mutation configuration using functional options. -type releaseOption func(*ReleaseMutation) +// profileOption allows management of the mutation configuration using functional options. +type profileOption func(*ProfileMutation) -// newReleaseMutation creates new mutation for the Release entity. -func newReleaseMutation(c config, op Op, opts ...releaseOption) *ReleaseMutation { - m := &ReleaseMutation{ +// newProfileMutation creates new mutation for the Profile entity. +func newProfileMutation(c config, op Op, opts ...profileOption) *ProfileMutation { + m := &ProfileMutation{ config: c, op: op, - typ: TypeRelease, + typ: TypeProfile, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -19129,20 +19500,20 @@ func newReleaseMutation(c config, op Op, opts ...releaseOption) *ReleaseMutation return m } -// withReleaseID sets the ID field of the mutation. -func withReleaseID(id int) releaseOption { - return func(m *ReleaseMutation) { +// withProfileID sets the ID field of the mutation. +func withProfileID(id int) profileOption { + return func(m *ProfileMutation) { var ( err error once sync.Once - value *Release + value *Profile ) - m.oldValue = func(ctx context.Context) (*Release, error) { + m.oldValue = func(ctx context.Context) (*Profile, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Release.Get(ctx, id) + value, err = m.Client().Profile.Get(ctx, id) } }) return value, err @@ -19151,10 +19522,10 @@ func withReleaseID(id int) releaseOption { } } -// withRelease sets the old Release of the mutation. -func withRelease(node *Release) releaseOption { - return func(m *ReleaseMutation) { - m.oldValue = func(context.Context) (*Release, error) { +// withProfile sets the old Profile of the mutation. +func withProfile(node *Profile) profileOption { + return func(m *ProfileMutation) { + m.oldValue = func(context.Context) (*Profile, error) { return node, nil } m.id = &node.ID @@ -19163,7 +19534,7 @@ func withRelease(node *Release) releaseOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ReleaseMutation) Client() *Client { +func (m ProfileMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -19171,7 +19542,7 @@ func (m ReleaseMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ReleaseMutation) Tx() (*Tx, error) { +func (m ProfileMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -19182,7 +19553,7 @@ func (m ReleaseMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ReleaseMutation) ID() (id int, exists bool) { +func (m *ProfileMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -19193,7 +19564,7 @@ func (m *ReleaseMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ReleaseMutation) IDs(ctx context.Context) ([]int, error) { +func (m *ProfileMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -19202,672 +19573,416 @@ func (m *ReleaseMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Release.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Profile.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetReleaseType sets the "release_type" field. -func (m *ReleaseMutation) SetReleaseType(rt release.ReleaseType) { - m.release_type = &rt +// SetName sets the "name" field. +func (m *ProfileMutation) SetName(s string) { + m.name = &s } -// ReleaseType returns the value of the "release_type" field in the mutation. -func (m *ReleaseMutation) ReleaseType() (r release.ReleaseType, exists bool) { - v := m.release_type +// Name returns the value of the "name" field in the mutation. +func (m *ProfileMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldReleaseType returns the old "release_type" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Profile entity. +// If the Profile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldReleaseType(ctx context.Context) (v release.ReleaseType, err error) { +func (m *ProfileMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldReleaseType is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldReleaseType requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldReleaseType: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.ReleaseType, nil -} - -// ClearReleaseType clears the value of the "release_type" field. -func (m *ReleaseMutation) ClearReleaseType() { - m.release_type = nil - m.clearedFields[release.FieldReleaseType] = struct{}{} -} - -// ReleaseTypeCleared returns if the "release_type" field was cleared in this mutation. -func (m *ReleaseMutation) ReleaseTypeCleared() bool { - _, ok := m.clearedFields[release.FieldReleaseType] - return ok + return oldValue.Name, nil } -// ResetReleaseType resets all changes to the "release_type" field. -func (m *ReleaseMutation) ResetReleaseType() { - m.release_type = nil - delete(m.clearedFields, release.FieldReleaseType) +// ResetName resets all changes to the "name" field. +func (m *ProfileMutation) ResetName() { + m.name = nil } -// SetVersion sets the "version" field. -func (m *ReleaseMutation) SetVersion(s string) { - m.version = &s +// SetApplyToAll sets the "apply_to_all" field. +func (m *ProfileMutation) SetApplyToAll(b bool) { + m.apply_to_all = &b } -// Version returns the value of the "version" field in the mutation. -func (m *ReleaseMutation) Version() (r string, exists bool) { - v := m.version +// ApplyToAll returns the value of the "apply_to_all" field in the mutation. +func (m *ProfileMutation) ApplyToAll() (r bool, exists bool) { + v := m.apply_to_all if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. +// OldApplyToAll returns the old "apply_to_all" field's value of the Profile entity. +// If the Profile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldVersion(ctx context.Context) (v string, err error) { +func (m *ProfileMutation) OldApplyToAll(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldApplyToAll is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldApplyToAll requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) + return v, fmt.Errorf("querying old value for OldApplyToAll: %w", err) } - return oldValue.Version, nil -} - -// ClearVersion clears the value of the "version" field. -func (m *ReleaseMutation) ClearVersion() { - m.version = nil - m.clearedFields[release.FieldVersion] = struct{}{} -} - -// VersionCleared returns if the "version" field was cleared in this mutation. -func (m *ReleaseMutation) VersionCleared() bool { - _, ok := m.clearedFields[release.FieldVersion] - return ok + return oldValue.ApplyToAll, nil } -// ResetVersion resets all changes to the "version" field. -func (m *ReleaseMutation) ResetVersion() { - m.version = nil - delete(m.clearedFields, release.FieldVersion) +// ResetApplyToAll resets all changes to the "apply_to_all" field. +func (m *ProfileMutation) ResetApplyToAll() { + m.apply_to_all = nil } -// SetChannel sets the "channel" field. -func (m *ReleaseMutation) SetChannel(s string) { - m.channel = &s +// SetDisabled sets the "disabled" field. +func (m *ProfileMutation) SetDisabled(b bool) { + m.disabled = &b } -// Channel returns the value of the "channel" field in the mutation. -func (m *ReleaseMutation) Channel() (r string, exists bool) { - v := m.channel +// Disabled returns the value of the "disabled" field in the mutation. +func (m *ProfileMutation) Disabled() (r bool, exists bool) { + v := m.disabled if v == nil { return } return *v, true } -// OldChannel returns the old "channel" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. +// OldDisabled returns the old "disabled" field's value of the Profile entity. +// If the Profile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldChannel(ctx context.Context) (v string, err error) { +func (m *ProfileMutation) OldDisabled(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChannel is only allowed on UpdateOne operations") + return v, errors.New("OldDisabled is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChannel requires an ID field in the mutation") + return v, errors.New("OldDisabled requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldChannel: %w", err) + return v, fmt.Errorf("querying old value for OldDisabled: %w", err) } - return oldValue.Channel, nil -} - -// ClearChannel clears the value of the "channel" field. -func (m *ReleaseMutation) ClearChannel() { - m.channel = nil - m.clearedFields[release.FieldChannel] = struct{}{} -} - -// ChannelCleared returns if the "channel" field was cleared in this mutation. -func (m *ReleaseMutation) ChannelCleared() bool { - _, ok := m.clearedFields[release.FieldChannel] - return ok + return oldValue.Disabled, nil } -// ResetChannel resets all changes to the "channel" field. -func (m *ReleaseMutation) ResetChannel() { - m.channel = nil - delete(m.clearedFields, release.FieldChannel) +// ResetDisabled resets all changes to the "disabled" field. +func (m *ProfileMutation) ResetDisabled() { + m.disabled = nil } -// SetSummary sets the "summary" field. -func (m *ReleaseMutation) SetSummary(s string) { - m.summary = &s +// SetType sets the "type" field. +func (m *ProfileMutation) SetType(pr profile.Type) { + m._type = &pr } -// Summary returns the value of the "summary" field in the mutation. -func (m *ReleaseMutation) Summary() (r string, exists bool) { - v := m.summary +// GetType returns the value of the "type" field in the mutation. +func (m *ProfileMutation) GetType() (r profile.Type, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldSummary returns the old "summary" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. +// OldType returns the old "type" field's value of the Profile entity. +// If the Profile object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldSummary(ctx context.Context) (v string, err error) { +func (m *ProfileMutation) OldType(ctx context.Context) (v profile.Type, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSummary is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSummary requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSummary: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.Summary, nil + return oldValue.Type, nil } -// ClearSummary clears the value of the "summary" field. -func (m *ReleaseMutation) ClearSummary() { - m.summary = nil - m.clearedFields[release.FieldSummary] = struct{}{} +// ClearType clears the value of the "type" field. +func (m *ProfileMutation) ClearType() { + m._type = nil + m.clearedFields[profile.FieldType] = struct{}{} } -// SummaryCleared returns if the "summary" field was cleared in this mutation. -func (m *ReleaseMutation) SummaryCleared() bool { - _, ok := m.clearedFields[release.FieldSummary] +// TypeCleared returns if the "type" field was cleared in this mutation. +func (m *ProfileMutation) TypeCleared() bool { + _, ok := m.clearedFields[profile.FieldType] return ok } -// ResetSummary resets all changes to the "summary" field. -func (m *ReleaseMutation) ResetSummary() { - m.summary = nil - delete(m.clearedFields, release.FieldSummary) -} - -// SetReleaseNotes sets the "release_notes" field. -func (m *ReleaseMutation) SetReleaseNotes(s string) { - m.release_notes = &s -} - -// ReleaseNotes returns the value of the "release_notes" field in the mutation. -func (m *ReleaseMutation) ReleaseNotes() (r string, exists bool) { - v := m.release_notes - if v == nil { - return - } - return *v, true +// ResetType resets all changes to the "type" field. +func (m *ProfileMutation) ResetType() { + m._type = nil + delete(m.clearedFields, profile.FieldType) } -// OldReleaseNotes returns the old "release_notes" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldReleaseNotes(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldReleaseNotes is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldReleaseNotes requires an ID field in the mutation") +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *ProfileMutation) AddTagIDs(ids ...int) { + if m.tags == nil { + m.tags = make(map[int]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldReleaseNotes: %w", err) + for i := range ids { + m.tags[ids[i]] = struct{}{} } - return oldValue.ReleaseNotes, nil -} - -// ClearReleaseNotes clears the value of the "release_notes" field. -func (m *ReleaseMutation) ClearReleaseNotes() { - m.release_notes = nil - m.clearedFields[release.FieldReleaseNotes] = struct{}{} } -// ReleaseNotesCleared returns if the "release_notes" field was cleared in this mutation. -func (m *ReleaseMutation) ReleaseNotesCleared() bool { - _, ok := m.clearedFields[release.FieldReleaseNotes] - return ok +// ClearTags clears the "tags" edge to the Tag entity. +func (m *ProfileMutation) ClearTags() { + m.clearedtags = true } -// ResetReleaseNotes resets all changes to the "release_notes" field. -func (m *ReleaseMutation) ResetReleaseNotes() { - m.release_notes = nil - delete(m.clearedFields, release.FieldReleaseNotes) +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *ProfileMutation) TagsCleared() bool { + return m.clearedtags } -// SetFileURL sets the "file_url" field. -func (m *ReleaseMutation) SetFileURL(s string) { - m.file_url = &s +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *ProfileMutation) RemoveTagIDs(ids ...int) { + if m.removedtags == nil { + m.removedtags = make(map[int]struct{}) + } + for i := range ids { + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} + } } -// FileURL returns the value of the "file_url" field in the mutation. -func (m *ReleaseMutation) FileURL() (r string, exists bool) { - v := m.file_url - if v == nil { - return +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *ProfileMutation) RemovedTagsIDs() (ids []int) { + for id := range m.removedtags { + ids = append(ids, id) } - return *v, true + return } -// OldFileURL returns the old "file_url" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldFileURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldFileURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldFileURL requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFileURL: %w", err) +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *ProfileMutation) TagsIDs() (ids []int) { + for id := range m.tags { + ids = append(ids, id) } - return oldValue.FileURL, nil + return } -// ClearFileURL clears the value of the "file_url" field. -func (m *ReleaseMutation) ClearFileURL() { - m.file_url = nil - m.clearedFields[release.FieldFileURL] = struct{}{} +// ResetTags resets all changes to the "tags" edge. +func (m *ProfileMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil } -// FileURLCleared returns if the "file_url" field was cleared in this mutation. -func (m *ReleaseMutation) FileURLCleared() bool { - _, ok := m.clearedFields[release.FieldFileURL] - return ok +// AddTaskIDs adds the "tasks" edge to the Task entity by ids. +func (m *ProfileMutation) AddTaskIDs(ids ...int) { + if m.tasks == nil { + m.tasks = make(map[int]struct{}) + } + for i := range ids { + m.tasks[ids[i]] = struct{}{} + } } -// ResetFileURL resets all changes to the "file_url" field. -func (m *ReleaseMutation) ResetFileURL() { - m.file_url = nil - delete(m.clearedFields, release.FieldFileURL) +// ClearTasks clears the "tasks" edge to the Task entity. +func (m *ProfileMutation) ClearTasks() { + m.clearedtasks = true } -// SetChecksum sets the "checksum" field. -func (m *ReleaseMutation) SetChecksum(s string) { - m.checksum = &s +// TasksCleared reports if the "tasks" edge to the Task entity was cleared. +func (m *ProfileMutation) TasksCleared() bool { + return m.clearedtasks } -// Checksum returns the value of the "checksum" field in the mutation. -func (m *ReleaseMutation) Checksum() (r string, exists bool) { - v := m.checksum - if v == nil { - return +// RemoveTaskIDs removes the "tasks" edge to the Task entity by IDs. +func (m *ProfileMutation) RemoveTaskIDs(ids ...int) { + if m.removedtasks == nil { + m.removedtasks = make(map[int]struct{}) + } + for i := range ids { + delete(m.tasks, ids[i]) + m.removedtasks[ids[i]] = struct{}{} } - return *v, true } -// OldChecksum returns the old "checksum" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldChecksum(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChecksum is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChecksum requires an ID field in the mutation") +// RemovedTasks returns the removed IDs of the "tasks" edge to the Task entity. +func (m *ProfileMutation) RemovedTasksIDs() (ids []int) { + for id := range m.removedtasks { + ids = append(ids, id) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldChecksum: %w", err) + return +} + +// TasksIDs returns the "tasks" edge IDs in the mutation. +func (m *ProfileMutation) TasksIDs() (ids []int) { + for id := range m.tasks { + ids = append(ids, id) } - return oldValue.Checksum, nil + return } -// ClearChecksum clears the value of the "checksum" field. -func (m *ReleaseMutation) ClearChecksum() { - m.checksum = nil - m.clearedFields[release.FieldChecksum] = struct{}{} +// ResetTasks resets all changes to the "tasks" edge. +func (m *ProfileMutation) ResetTasks() { + m.tasks = nil + m.clearedtasks = false + m.removedtasks = nil } -// ChecksumCleared returns if the "checksum" field was cleared in this mutation. -func (m *ReleaseMutation) ChecksumCleared() bool { - _, ok := m.clearedFields[release.FieldChecksum] - return ok +// AddIssueIDs adds the "issues" edge to the ProfileIssue entity by ids. +func (m *ProfileMutation) AddIssueIDs(ids ...int) { + if m.issues == nil { + m.issues = make(map[int]struct{}) + } + for i := range ids { + m.issues[ids[i]] = struct{}{} + } } -// ResetChecksum resets all changes to the "checksum" field. -func (m *ReleaseMutation) ResetChecksum() { - m.checksum = nil - delete(m.clearedFields, release.FieldChecksum) +// ClearIssues clears the "issues" edge to the ProfileIssue entity. +func (m *ProfileMutation) ClearIssues() { + m.clearedissues = true } -// SetIsCritical sets the "is_critical" field. -func (m *ReleaseMutation) SetIsCritical(b bool) { - m.is_critical = &b +// IssuesCleared reports if the "issues" edge to the ProfileIssue entity was cleared. +func (m *ProfileMutation) IssuesCleared() bool { + return m.clearedissues } -// IsCritical returns the value of the "is_critical" field in the mutation. -func (m *ReleaseMutation) IsCritical() (r bool, exists bool) { - v := m.is_critical - if v == nil { - return +// RemoveIssueIDs removes the "issues" edge to the ProfileIssue entity by IDs. +func (m *ProfileMutation) RemoveIssueIDs(ids ...int) { + if m.removedissues == nil { + m.removedissues = make(map[int]struct{}) + } + for i := range ids { + delete(m.issues, ids[i]) + m.removedissues[ids[i]] = struct{}{} } - return *v, true } -// OldIsCritical returns the old "is_critical" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldIsCritical(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsCritical is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsCritical requires an ID field in the mutation") +// RemovedIssues returns the removed IDs of the "issues" edge to the ProfileIssue entity. +func (m *ProfileMutation) RemovedIssuesIDs() (ids []int) { + for id := range m.removedissues { + ids = append(ids, id) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIsCritical: %w", err) + return +} + +// IssuesIDs returns the "issues" edge IDs in the mutation. +func (m *ProfileMutation) IssuesIDs() (ids []int) { + for id := range m.issues { + ids = append(ids, id) } - return oldValue.IsCritical, nil + return } -// ClearIsCritical clears the value of the "is_critical" field. -func (m *ReleaseMutation) ClearIsCritical() { - m.is_critical = nil - m.clearedFields[release.FieldIsCritical] = struct{}{} +// ResetIssues resets all changes to the "issues" edge. +func (m *ProfileMutation) ResetIssues() { + m.issues = nil + m.clearedissues = false + m.removedissues = nil } -// IsCriticalCleared returns if the "is_critical" field was cleared in this mutation. -func (m *ReleaseMutation) IsCriticalCleared() bool { - _, ok := m.clearedFields[release.FieldIsCritical] - return ok +// SetSiteID sets the "site" edge to the Site entity by id. +func (m *ProfileMutation) SetSiteID(id int) { + m.site = &id } -// ResetIsCritical resets all changes to the "is_critical" field. -func (m *ReleaseMutation) ResetIsCritical() { - m.is_critical = nil - delete(m.clearedFields, release.FieldIsCritical) +// ClearSite clears the "site" edge to the Site entity. +func (m *ProfileMutation) ClearSite() { + m.clearedsite = true } -// SetReleaseDate sets the "release_date" field. -func (m *ReleaseMutation) SetReleaseDate(t time.Time) { - m.release_date = &t +// SiteCleared reports if the "site" edge to the Site entity was cleared. +func (m *ProfileMutation) SiteCleared() bool { + return m.clearedsite } -// ReleaseDate returns the value of the "release_date" field in the mutation. -func (m *ReleaseMutation) ReleaseDate() (r time.Time, exists bool) { - v := m.release_date - if v == nil { - return +// SiteID returns the "site" edge ID in the mutation. +func (m *ProfileMutation) SiteID() (id int, exists bool) { + if m.site != nil { + return *m.site, true } - return *v, true + return } -// OldReleaseDate returns the old "release_date" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldReleaseDate(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldReleaseDate is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldReleaseDate requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldReleaseDate: %w", err) +// SiteIDs returns the "site" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SiteID instead. It exists only for internal usage by the builders. +func (m *ProfileMutation) SiteIDs() (ids []int) { + if id := m.site; id != nil { + ids = append(ids, *id) } - return oldValue.ReleaseDate, nil + return } -// ClearReleaseDate clears the value of the "release_date" field. -func (m *ReleaseMutation) ClearReleaseDate() { - m.release_date = nil - m.clearedFields[release.FieldReleaseDate] = struct{}{} +// ResetSite resets all changes to the "site" edge. +func (m *ProfileMutation) ResetSite() { + m.site = nil + m.clearedsite = false } -// ReleaseDateCleared returns if the "release_date" field was cleared in this mutation. -func (m *ReleaseMutation) ReleaseDateCleared() bool { - _, ok := m.clearedFields[release.FieldReleaseDate] - return ok +// Where appends a list predicates to the ProfileMutation builder. +func (m *ProfileMutation) Where(ps ...predicate.Profile) { + m.predicates = append(m.predicates, ps...) } -// ResetReleaseDate resets all changes to the "release_date" field. -func (m *ReleaseMutation) ResetReleaseDate() { - m.release_date = nil - delete(m.clearedFields, release.FieldReleaseDate) +// WhereP appends storage-level predicates to the ProfileMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ProfileMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Profile, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// SetOs sets the "os" field. -func (m *ReleaseMutation) SetOs(s string) { - m.os = &s +// Op returns the operation name. +func (m *ProfileMutation) Op() Op { + return m.op } -// Os returns the value of the "os" field in the mutation. -func (m *ReleaseMutation) Os() (r string, exists bool) { - v := m.os - if v == nil { - return - } - return *v, true +// SetOp allows setting the mutation operation. +func (m *ProfileMutation) SetOp(op Op) { + m.op = op } -// OldOs returns the old "os" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldOs(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOs is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOs requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldOs: %w", err) - } - return oldValue.Os, nil -} - -// ClearOs clears the value of the "os" field. -func (m *ReleaseMutation) ClearOs() { - m.os = nil - m.clearedFields[release.FieldOs] = struct{}{} -} - -// OsCleared returns if the "os" field was cleared in this mutation. -func (m *ReleaseMutation) OsCleared() bool { - _, ok := m.clearedFields[release.FieldOs] - return ok -} - -// ResetOs resets all changes to the "os" field. -func (m *ReleaseMutation) ResetOs() { - m.os = nil - delete(m.clearedFields, release.FieldOs) -} - -// SetArch sets the "arch" field. -func (m *ReleaseMutation) SetArch(s string) { - m.arch = &s -} - -// Arch returns the value of the "arch" field in the mutation. -func (m *ReleaseMutation) Arch() (r string, exists bool) { - v := m.arch - if v == nil { - return - } - return *v, true -} - -// OldArch returns the old "arch" field's value of the Release entity. -// If the Release object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ReleaseMutation) OldArch(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArch is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArch requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArch: %w", err) - } - return oldValue.Arch, nil -} - -// ClearArch clears the value of the "arch" field. -func (m *ReleaseMutation) ClearArch() { - m.arch = nil - m.clearedFields[release.FieldArch] = struct{}{} -} - -// ArchCleared returns if the "arch" field was cleared in this mutation. -func (m *ReleaseMutation) ArchCleared() bool { - _, ok := m.clearedFields[release.FieldArch] - return ok -} - -// ResetArch resets all changes to the "arch" field. -func (m *ReleaseMutation) ResetArch() { - m.arch = nil - delete(m.clearedFields, release.FieldArch) -} - -// AddAgentIDs adds the "agents" edge to the Agent entity by ids. -func (m *ReleaseMutation) AddAgentIDs(ids ...string) { - if m.agents == nil { - m.agents = make(map[string]struct{}) - } - for i := range ids { - m.agents[ids[i]] = struct{}{} - } -} - -// ClearAgents clears the "agents" edge to the Agent entity. -func (m *ReleaseMutation) ClearAgents() { - m.clearedagents = true -} - -// AgentsCleared reports if the "agents" edge to the Agent entity was cleared. -func (m *ReleaseMutation) AgentsCleared() bool { - return m.clearedagents -} - -// RemoveAgentIDs removes the "agents" edge to the Agent entity by IDs. -func (m *ReleaseMutation) RemoveAgentIDs(ids ...string) { - if m.removedagents == nil { - m.removedagents = make(map[string]struct{}) - } - for i := range ids { - delete(m.agents, ids[i]) - m.removedagents[ids[i]] = struct{}{} - } -} - -// RemovedAgents returns the removed IDs of the "agents" edge to the Agent entity. -func (m *ReleaseMutation) RemovedAgentsIDs() (ids []string) { - for id := range m.removedagents { - ids = append(ids, id) - } - return -} - -// AgentsIDs returns the "agents" edge IDs in the mutation. -func (m *ReleaseMutation) AgentsIDs() (ids []string) { - for id := range m.agents { - ids = append(ids, id) - } - return -} - -// ResetAgents resets all changes to the "agents" edge. -func (m *ReleaseMutation) ResetAgents() { - m.agents = nil - m.clearedagents = false - m.removedagents = nil -} - -// Where appends a list predicates to the ReleaseMutation builder. -func (m *ReleaseMutation) Where(ps ...predicate.Release) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ReleaseMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ReleaseMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Release, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *ReleaseMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *ReleaseMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Release). -func (m *ReleaseMutation) Type() string { +// Type returns the node type of this mutation (Profile). +func (m *ProfileMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ReleaseMutation) Fields() []string { - fields := make([]string, 0, 11) - if m.release_type != nil { - fields = append(fields, release.FieldReleaseType) - } - if m.version != nil { - fields = append(fields, release.FieldVersion) - } - if m.channel != nil { - fields = append(fields, release.FieldChannel) - } - if m.summary != nil { - fields = append(fields, release.FieldSummary) - } - if m.release_notes != nil { - fields = append(fields, release.FieldReleaseNotes) - } - if m.file_url != nil { - fields = append(fields, release.FieldFileURL) - } - if m.checksum != nil { - fields = append(fields, release.FieldChecksum) - } - if m.is_critical != nil { - fields = append(fields, release.FieldIsCritical) +func (m *ProfileMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.name != nil { + fields = append(fields, profile.FieldName) } - if m.release_date != nil { - fields = append(fields, release.FieldReleaseDate) + if m.apply_to_all != nil { + fields = append(fields, profile.FieldApplyToAll) } - if m.os != nil { - fields = append(fields, release.FieldOs) + if m.disabled != nil { + fields = append(fields, profile.FieldDisabled) } - if m.arch != nil { - fields = append(fields, release.FieldArch) + if m._type != nil { + fields = append(fields, profile.FieldType) } return fields } @@ -19875,30 +19990,16 @@ func (m *ReleaseMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ReleaseMutation) Field(name string) (ent.Value, bool) { +func (m *ProfileMutation) Field(name string) (ent.Value, bool) { switch name { - case release.FieldReleaseType: - return m.ReleaseType() - case release.FieldVersion: - return m.Version() - case release.FieldChannel: - return m.Channel() - case release.FieldSummary: - return m.Summary() - case release.FieldReleaseNotes: - return m.ReleaseNotes() - case release.FieldFileURL: - return m.FileURL() - case release.FieldChecksum: - return m.Checksum() - case release.FieldIsCritical: - return m.IsCritical() - case release.FieldReleaseDate: - return m.ReleaseDate() - case release.FieldOs: - return m.Os() - case release.FieldArch: - return m.Arch() + case profile.FieldName: + return m.Name() + case profile.FieldApplyToAll: + return m.ApplyToAll() + case profile.FieldDisabled: + return m.Disabled() + case profile.FieldType: + return m.GetType() } return nil, false } @@ -19906,310 +20007,209 @@ func (m *ReleaseMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ReleaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProfileMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case release.FieldReleaseType: - return m.OldReleaseType(ctx) - case release.FieldVersion: - return m.OldVersion(ctx) - case release.FieldChannel: - return m.OldChannel(ctx) - case release.FieldSummary: - return m.OldSummary(ctx) - case release.FieldReleaseNotes: - return m.OldReleaseNotes(ctx) - case release.FieldFileURL: - return m.OldFileURL(ctx) - case release.FieldChecksum: - return m.OldChecksum(ctx) - case release.FieldIsCritical: - return m.OldIsCritical(ctx) - case release.FieldReleaseDate: - return m.OldReleaseDate(ctx) - case release.FieldOs: - return m.OldOs(ctx) - case release.FieldArch: - return m.OldArch(ctx) + case profile.FieldName: + return m.OldName(ctx) + case profile.FieldApplyToAll: + return m.OldApplyToAll(ctx) + case profile.FieldDisabled: + return m.OldDisabled(ctx) + case profile.FieldType: + return m.OldType(ctx) } - return nil, fmt.Errorf("unknown Release field %s", name) + return nil, fmt.Errorf("unknown Profile field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ReleaseMutation) SetField(name string, value ent.Value) error { +func (m *ProfileMutation) SetField(name string, value ent.Value) error { switch name { - case release.FieldReleaseType: - v, ok := value.(release.ReleaseType) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetReleaseType(v) - return nil - case release.FieldVersion: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVersion(v) - return nil - case release.FieldChannel: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChannel(v) - return nil - case release.FieldSummary: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSummary(v) - return nil - case release.FieldReleaseNotes: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetReleaseNotes(v) - return nil - case release.FieldFileURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFileURL(v) - return nil - case release.FieldChecksum: + case profile.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetChecksum(v) + m.SetName(v) return nil - case release.FieldIsCritical: + case profile.FieldApplyToAll: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsCritical(v) - return nil - case release.FieldReleaseDate: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetReleaseDate(v) + m.SetApplyToAll(v) return nil - case release.FieldOs: - v, ok := value.(string) + case profile.FieldDisabled: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOs(v) + m.SetDisabled(v) return nil - case release.FieldArch: - v, ok := value.(string) + case profile.FieldType: + v, ok := value.(profile.Type) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetArch(v) + m.SetType(v) return nil } - return fmt.Errorf("unknown Release field %s", name) + return fmt.Errorf("unknown Profile field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ReleaseMutation) AddedFields() []string { +func (m *ProfileMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ReleaseMutation) AddedField(name string) (ent.Value, bool) { +func (m *ProfileMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ReleaseMutation) AddField(name string, value ent.Value) error { +func (m *ProfileMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Release numeric field %s", name) + return fmt.Errorf("unknown Profile numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ReleaseMutation) ClearedFields() []string { +func (m *ProfileMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(release.FieldReleaseType) { - fields = append(fields, release.FieldReleaseType) - } - if m.FieldCleared(release.FieldVersion) { - fields = append(fields, release.FieldVersion) - } - if m.FieldCleared(release.FieldChannel) { - fields = append(fields, release.FieldChannel) - } - if m.FieldCleared(release.FieldSummary) { - fields = append(fields, release.FieldSummary) - } - if m.FieldCleared(release.FieldReleaseNotes) { - fields = append(fields, release.FieldReleaseNotes) - } - if m.FieldCleared(release.FieldFileURL) { - fields = append(fields, release.FieldFileURL) - } - if m.FieldCleared(release.FieldChecksum) { - fields = append(fields, release.FieldChecksum) - } - if m.FieldCleared(release.FieldIsCritical) { - fields = append(fields, release.FieldIsCritical) - } - if m.FieldCleared(release.FieldReleaseDate) { - fields = append(fields, release.FieldReleaseDate) - } - if m.FieldCleared(release.FieldOs) { - fields = append(fields, release.FieldOs) - } - if m.FieldCleared(release.FieldArch) { - fields = append(fields, release.FieldArch) + if m.FieldCleared(profile.FieldType) { + fields = append(fields, profile.FieldType) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ReleaseMutation) FieldCleared(name string) bool { +func (m *ProfileMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ReleaseMutation) ClearField(name string) error { +func (m *ProfileMutation) ClearField(name string) error { switch name { - case release.FieldReleaseType: - m.ClearReleaseType() - return nil - case release.FieldVersion: - m.ClearVersion() - return nil - case release.FieldChannel: - m.ClearChannel() - return nil - case release.FieldSummary: - m.ClearSummary() - return nil - case release.FieldReleaseNotes: - m.ClearReleaseNotes() - return nil - case release.FieldFileURL: - m.ClearFileURL() - return nil - case release.FieldChecksum: - m.ClearChecksum() - return nil - case release.FieldIsCritical: - m.ClearIsCritical() - return nil - case release.FieldReleaseDate: - m.ClearReleaseDate() - return nil - case release.FieldOs: - m.ClearOs() - return nil - case release.FieldArch: - m.ClearArch() + case profile.FieldType: + m.ClearType() return nil } - return fmt.Errorf("unknown Release nullable field %s", name) + return fmt.Errorf("unknown Profile nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ReleaseMutation) ResetField(name string) error { +func (m *ProfileMutation) ResetField(name string) error { switch name { - case release.FieldReleaseType: - m.ResetReleaseType() - return nil - case release.FieldVersion: - m.ResetVersion() - return nil - case release.FieldChannel: - m.ResetChannel() - return nil - case release.FieldSummary: - m.ResetSummary() - return nil - case release.FieldReleaseNotes: - m.ResetReleaseNotes() - return nil - case release.FieldFileURL: - m.ResetFileURL() - return nil - case release.FieldChecksum: - m.ResetChecksum() - return nil - case release.FieldIsCritical: - m.ResetIsCritical() + case profile.FieldName: + m.ResetName() return nil - case release.FieldReleaseDate: - m.ResetReleaseDate() + case profile.FieldApplyToAll: + m.ResetApplyToAll() return nil - case release.FieldOs: - m.ResetOs() + case profile.FieldDisabled: + m.ResetDisabled() return nil - case release.FieldArch: - m.ResetArch() + case profile.FieldType: + m.ResetType() return nil } - return fmt.Errorf("unknown Release field %s", name) + return fmt.Errorf("unknown Profile field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ReleaseMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.agents != nil { - edges = append(edges, release.EdgeAgents) +func (m *ProfileMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.tags != nil { + edges = append(edges, profile.EdgeTags) + } + if m.tasks != nil { + edges = append(edges, profile.EdgeTasks) + } + if m.issues != nil { + edges = append(edges, profile.EdgeIssues) + } + if m.site != nil { + edges = append(edges, profile.EdgeSite) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ReleaseMutation) AddedIDs(name string) []ent.Value { +func (m *ProfileMutation) AddedIDs(name string) []ent.Value { switch name { - case release.EdgeAgents: - ids := make([]ent.Value, 0, len(m.agents)) - for id := range m.agents { + case profile.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { + ids = append(ids, id) + } + return ids + case profile.EdgeTasks: + ids := make([]ent.Value, 0, len(m.tasks)) + for id := range m.tasks { ids = append(ids, id) } return ids + case profile.EdgeIssues: + ids := make([]ent.Value, 0, len(m.issues)) + for id := range m.issues { + ids = append(ids, id) + } + return ids + case profile.EdgeSite: + if id := m.site; id != nil { + return []ent.Value{*id} + } } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ReleaseMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - if m.removedagents != nil { - edges = append(edges, release.EdgeAgents) - } - return edges +func (m *ProfileMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedtags != nil { + edges = append(edges, profile.EdgeTags) + } + if m.removedtasks != nil { + edges = append(edges, profile.EdgeTasks) + } + if m.removedissues != nil { + edges = append(edges, profile.EdgeIssues) + } + return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ReleaseMutation) RemovedIDs(name string) []ent.Value { +func (m *ProfileMutation) RemovedIDs(name string) []ent.Value { switch name { - case release.EdgeAgents: - ids := make([]ent.Value, 0, len(m.removedagents)) - for id := range m.removedagents { + case profile.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { + ids = append(ids, id) + } + return ids + case profile.EdgeTasks: + ids := make([]ent.Value, 0, len(m.removedtasks)) + for id := range m.removedtasks { + ids = append(ids, id) + } + return ids + case profile.EdgeIssues: + ids := make([]ent.Value, 0, len(m.removedissues)) + for id := range m.removedissues { ids = append(ids, id) } return ids @@ -20218,71 +20218,99 @@ func (m *ReleaseMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ReleaseMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedagents { - edges = append(edges, release.EdgeAgents) +func (m *ProfileMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedtags { + edges = append(edges, profile.EdgeTags) + } + if m.clearedtasks { + edges = append(edges, profile.EdgeTasks) + } + if m.clearedissues { + edges = append(edges, profile.EdgeIssues) + } + if m.clearedsite { + edges = append(edges, profile.EdgeSite) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ReleaseMutation) EdgeCleared(name string) bool { +func (m *ProfileMutation) EdgeCleared(name string) bool { switch name { - case release.EdgeAgents: - return m.clearedagents + case profile.EdgeTags: + return m.clearedtags + case profile.EdgeTasks: + return m.clearedtasks + case profile.EdgeIssues: + return m.clearedissues + case profile.EdgeSite: + return m.clearedsite } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ReleaseMutation) ClearEdge(name string) error { +func (m *ProfileMutation) ClearEdge(name string) error { switch name { + case profile.EdgeSite: + m.ClearSite() + return nil } - return fmt.Errorf("unknown Release unique edge %s", name) + return fmt.Errorf("unknown Profile unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ReleaseMutation) ResetEdge(name string) error { +func (m *ProfileMutation) ResetEdge(name string) error { switch name { - case release.EdgeAgents: - m.ResetAgents() + case profile.EdgeTags: + m.ResetTags() + return nil + case profile.EdgeTasks: + m.ResetTasks() + return nil + case profile.EdgeIssues: + m.ResetIssues() + return nil + case profile.EdgeSite: + m.ResetSite() return nil } - return fmt.Errorf("unknown Release edge %s", name) + return fmt.Errorf("unknown Profile edge %s", name) } -// RevocationMutation represents an operation that mutates the Revocation nodes in the graph. -type RevocationMutation struct { +// ProfileIssueMutation represents an operation that mutates the ProfileIssue nodes in the graph. +type ProfileIssueMutation struct { config - op Op - typ string - id *int64 - reason *int - addreason *int - info *string - expiry *time.Time - revoked *time.Time - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*Revocation, error) - predicates []predicate.Revocation + op Op + typ string + id *int + error *string + when *time.Time + clearedFields map[string]struct{} + profile *int + clearedprofile bool + agents *string + clearedagents bool + done bool + oldValue func(context.Context) (*ProfileIssue, error) + predicates []predicate.ProfileIssue } -var _ ent.Mutation = (*RevocationMutation)(nil) +var _ ent.Mutation = (*ProfileIssueMutation)(nil) -// revocationOption allows management of the mutation configuration using functional options. -type revocationOption func(*RevocationMutation) +// profileissueOption allows management of the mutation configuration using functional options. +type profileissueOption func(*ProfileIssueMutation) -// newRevocationMutation creates new mutation for the Revocation entity. -func newRevocationMutation(c config, op Op, opts ...revocationOption) *RevocationMutation { - m := &RevocationMutation{ +// newProfileIssueMutation creates new mutation for the ProfileIssue entity. +func newProfileIssueMutation(c config, op Op, opts ...profileissueOption) *ProfileIssueMutation { + m := &ProfileIssueMutation{ config: c, op: op, - typ: TypeRevocation, + typ: TypeProfileIssue, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -20291,20 +20319,20 @@ func newRevocationMutation(c config, op Op, opts ...revocationOption) *Revocatio return m } -// withRevocationID sets the ID field of the mutation. -func withRevocationID(id int64) revocationOption { - return func(m *RevocationMutation) { +// withProfileIssueID sets the ID field of the mutation. +func withProfileIssueID(id int) profileissueOption { + return func(m *ProfileIssueMutation) { var ( err error once sync.Once - value *Revocation + value *ProfileIssue ) - m.oldValue = func(ctx context.Context) (*Revocation, error) { + m.oldValue = func(ctx context.Context) (*ProfileIssue, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Revocation.Get(ctx, id) + value, err = m.Client().ProfileIssue.Get(ctx, id) } }) return value, err @@ -20313,10 +20341,10 @@ func withRevocationID(id int64) revocationOption { } } -// withRevocation sets the old Revocation of the mutation. -func withRevocation(node *Revocation) revocationOption { - return func(m *RevocationMutation) { - m.oldValue = func(context.Context) (*Revocation, error) { +// withProfileIssue sets the old ProfileIssue of the mutation. +func withProfileIssue(node *ProfileIssue) profileissueOption { + return func(m *ProfileIssueMutation) { + m.oldValue = func(context.Context) (*ProfileIssue, error) { return node, nil } m.id = &node.ID @@ -20325,7 +20353,7 @@ func withRevocation(node *Revocation) revocationOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m RevocationMutation) Client() *Client { +func (m ProfileIssueMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -20333,7 +20361,7 @@ func (m RevocationMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m RevocationMutation) Tx() (*Tx, error) { +func (m ProfileIssueMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -20342,15 +20370,9 @@ func (m RevocationMutation) Tx() (*Tx, error) { return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Revocation entities. -func (m *RevocationMutation) SetID(id int64) { - m.id = &id -} - // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *RevocationMutation) ID() (id int64, exists bool) { +func (m *ProfileIssueMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -20361,234 +20383,206 @@ func (m *RevocationMutation) ID() (id int64, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *RevocationMutation) IDs(ctx context.Context) ([]int64, error) { +func (m *ProfileIssueMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int64{id}, nil + return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Revocation.Query().Where(m.predicates...).IDs(ctx) + return m.Client().ProfileIssue.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetReason sets the "reason" field. -func (m *RevocationMutation) SetReason(i int) { - m.reason = &i - m.addreason = nil +// SetError sets the "error" field. +func (m *ProfileIssueMutation) SetError(s string) { + m.error = &s } -// Reason returns the value of the "reason" field in the mutation. -func (m *RevocationMutation) Reason() (r int, exists bool) { - v := m.reason +// Error returns the value of the "error" field in the mutation. +func (m *ProfileIssueMutation) Error() (r string, exists bool) { + v := m.error if v == nil { return } return *v, true } -// OldReason returns the old "reason" field's value of the Revocation entity. -// If the Revocation object wasn't provided to the builder, the object is fetched from the database. +// OldError returns the old "error" field's value of the ProfileIssue entity. +// If the ProfileIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RevocationMutation) OldReason(ctx context.Context) (v int, err error) { +func (m *ProfileIssueMutation) OldError(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldReason is only allowed on UpdateOne operations") + return v, errors.New("OldError is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldReason requires an ID field in the mutation") + return v, errors.New("OldError requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldReason: %w", err) - } - return oldValue.Reason, nil -} - -// AddReason adds i to the "reason" field. -func (m *RevocationMutation) AddReason(i int) { - if m.addreason != nil { - *m.addreason += i - } else { - m.addreason = &i - } -} - -// AddedReason returns the value that was added to the "reason" field in this mutation. -func (m *RevocationMutation) AddedReason() (r int, exists bool) { - v := m.addreason - if v == nil { - return + return v, fmt.Errorf("querying old value for OldError: %w", err) } - return *v, true + return oldValue.Error, nil } -// ClearReason clears the value of the "reason" field. -func (m *RevocationMutation) ClearReason() { - m.reason = nil - m.addreason = nil - m.clearedFields[revocation.FieldReason] = struct{}{} +// ClearError clears the value of the "error" field. +func (m *ProfileIssueMutation) ClearError() { + m.error = nil + m.clearedFields[profileissue.FieldError] = struct{}{} } -// ReasonCleared returns if the "reason" field was cleared in this mutation. -func (m *RevocationMutation) ReasonCleared() bool { - _, ok := m.clearedFields[revocation.FieldReason] +// ErrorCleared returns if the "error" field was cleared in this mutation. +func (m *ProfileIssueMutation) ErrorCleared() bool { + _, ok := m.clearedFields[profileissue.FieldError] return ok } -// ResetReason resets all changes to the "reason" field. -func (m *RevocationMutation) ResetReason() { - m.reason = nil - m.addreason = nil - delete(m.clearedFields, revocation.FieldReason) +// ResetError resets all changes to the "error" field. +func (m *ProfileIssueMutation) ResetError() { + m.error = nil + delete(m.clearedFields, profileissue.FieldError) } -// SetInfo sets the "info" field. -func (m *RevocationMutation) SetInfo(s string) { - m.info = &s +// SetWhen sets the "when" field. +func (m *ProfileIssueMutation) SetWhen(t time.Time) { + m.when = &t } -// Info returns the value of the "info" field in the mutation. -func (m *RevocationMutation) Info() (r string, exists bool) { - v := m.info +// When returns the value of the "when" field in the mutation. +func (m *ProfileIssueMutation) When() (r time.Time, exists bool) { + v := m.when if v == nil { return } return *v, true } -// OldInfo returns the old "info" field's value of the Revocation entity. -// If the Revocation object wasn't provided to the builder, the object is fetched from the database. +// OldWhen returns the old "when" field's value of the ProfileIssue entity. +// If the ProfileIssue object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RevocationMutation) OldInfo(ctx context.Context) (v string, err error) { +func (m *ProfileIssueMutation) OldWhen(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInfo is only allowed on UpdateOne operations") + return v, errors.New("OldWhen is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInfo requires an ID field in the mutation") + return v, errors.New("OldWhen requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInfo: %w", err) + return v, fmt.Errorf("querying old value for OldWhen: %w", err) } - return oldValue.Info, nil + return oldValue.When, nil } -// ClearInfo clears the value of the "info" field. -func (m *RevocationMutation) ClearInfo() { - m.info = nil - m.clearedFields[revocation.FieldInfo] = struct{}{} +// ClearWhen clears the value of the "when" field. +func (m *ProfileIssueMutation) ClearWhen() { + m.when = nil + m.clearedFields[profileissue.FieldWhen] = struct{}{} } -// InfoCleared returns if the "info" field was cleared in this mutation. -func (m *RevocationMutation) InfoCleared() bool { - _, ok := m.clearedFields[revocation.FieldInfo] +// WhenCleared returns if the "when" field was cleared in this mutation. +func (m *ProfileIssueMutation) WhenCleared() bool { + _, ok := m.clearedFields[profileissue.FieldWhen] return ok } -// ResetInfo resets all changes to the "info" field. -func (m *RevocationMutation) ResetInfo() { - m.info = nil - delete(m.clearedFields, revocation.FieldInfo) +// ResetWhen resets all changes to the "when" field. +func (m *ProfileIssueMutation) ResetWhen() { + m.when = nil + delete(m.clearedFields, profileissue.FieldWhen) } -// SetExpiry sets the "expiry" field. -func (m *RevocationMutation) SetExpiry(t time.Time) { - m.expiry = &t +// SetProfileID sets the "profile" edge to the Profile entity by id. +func (m *ProfileIssueMutation) SetProfileID(id int) { + m.profile = &id } -// Expiry returns the value of the "expiry" field in the mutation. -func (m *RevocationMutation) Expiry() (r time.Time, exists bool) { - v := m.expiry - if v == nil { - return - } - return *v, true +// ClearProfile clears the "profile" edge to the Profile entity. +func (m *ProfileIssueMutation) ClearProfile() { + m.clearedprofile = true } -// OldExpiry returns the old "expiry" field's value of the Revocation entity. -// If the Revocation object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RevocationMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExpiry is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExpiry requires an ID field in the mutation") +// ProfileCleared reports if the "profile" edge to the Profile entity was cleared. +func (m *ProfileIssueMutation) ProfileCleared() bool { + return m.clearedprofile +} + +// ProfileID returns the "profile" edge ID in the mutation. +func (m *ProfileIssueMutation) ProfileID() (id int, exists bool) { + if m.profile != nil { + return *m.profile, true } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldExpiry: %w", err) + return +} + +// ProfileIDs returns the "profile" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ProfileID instead. It exists only for internal usage by the builders. +func (m *ProfileIssueMutation) ProfileIDs() (ids []int) { + if id := m.profile; id != nil { + ids = append(ids, *id) } - return oldValue.Expiry, nil + return } -// ClearExpiry clears the value of the "expiry" field. -func (m *RevocationMutation) ClearExpiry() { - m.expiry = nil - m.clearedFields[revocation.FieldExpiry] = struct{}{} +// ResetProfile resets all changes to the "profile" edge. +func (m *ProfileIssueMutation) ResetProfile() { + m.profile = nil + m.clearedprofile = false } -// ExpiryCleared returns if the "expiry" field was cleared in this mutation. -func (m *RevocationMutation) ExpiryCleared() bool { - _, ok := m.clearedFields[revocation.FieldExpiry] - return ok +// SetAgentsID sets the "agents" edge to the Agent entity by id. +func (m *ProfileIssueMutation) SetAgentsID(id string) { + m.agents = &id } -// ResetExpiry resets all changes to the "expiry" field. -func (m *RevocationMutation) ResetExpiry() { - m.expiry = nil - delete(m.clearedFields, revocation.FieldExpiry) +// ClearAgents clears the "agents" edge to the Agent entity. +func (m *ProfileIssueMutation) ClearAgents() { + m.clearedagents = true } -// SetRevoked sets the "revoked" field. -func (m *RevocationMutation) SetRevoked(t time.Time) { - m.revoked = &t +// AgentsCleared reports if the "agents" edge to the Agent entity was cleared. +func (m *ProfileIssueMutation) AgentsCleared() bool { + return m.clearedagents } -// Revoked returns the value of the "revoked" field in the mutation. -func (m *RevocationMutation) Revoked() (r time.Time, exists bool) { - v := m.revoked - if v == nil { - return +// AgentsID returns the "agents" edge ID in the mutation. +func (m *ProfileIssueMutation) AgentsID() (id string, exists bool) { + if m.agents != nil { + return *m.agents, true } - return *v, true + return } -// OldRevoked returns the old "revoked" field's value of the Revocation entity. -// If the Revocation object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RevocationMutation) OldRevoked(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRevoked is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRevoked requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRevoked: %w", err) +// AgentsIDs returns the "agents" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// AgentsID instead. It exists only for internal usage by the builders. +func (m *ProfileIssueMutation) AgentsIDs() (ids []string) { + if id := m.agents; id != nil { + ids = append(ids, *id) } - return oldValue.Revoked, nil + return } -// ResetRevoked resets all changes to the "revoked" field. -func (m *RevocationMutation) ResetRevoked() { - m.revoked = nil +// ResetAgents resets all changes to the "agents" edge. +func (m *ProfileIssueMutation) ResetAgents() { + m.agents = nil + m.clearedagents = false } -// Where appends a list predicates to the RevocationMutation builder. -func (m *RevocationMutation) Where(ps ...predicate.Revocation) { +// Where appends a list predicates to the ProfileIssueMutation builder. +func (m *ProfileIssueMutation) Where(ps ...predicate.ProfileIssue) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the RevocationMutation builder. Using this method, +// WhereP appends storage-level predicates to the ProfileIssueMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RevocationMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Revocation, len(ps)) +func (m *ProfileIssueMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProfileIssue, len(ps)) for i := range ps { p[i] = ps[i] } @@ -20596,36 +20590,30 @@ func (m *RevocationMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *RevocationMutation) Op() Op { +func (m *ProfileIssueMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *RevocationMutation) SetOp(op Op) { +func (m *ProfileIssueMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Revocation). -func (m *RevocationMutation) Type() string { +// Type returns the node type of this mutation (ProfileIssue). +func (m *ProfileIssueMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *RevocationMutation) Fields() []string { - fields := make([]string, 0, 4) - if m.reason != nil { - fields = append(fields, revocation.FieldReason) - } - if m.info != nil { - fields = append(fields, revocation.FieldInfo) - } - if m.expiry != nil { - fields = append(fields, revocation.FieldExpiry) +func (m *ProfileIssueMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.error != nil { + fields = append(fields, profileissue.FieldError) } - if m.revoked != nil { - fields = append(fields, revocation.FieldRevoked) + if m.when != nil { + fields = append(fields, profileissue.FieldWhen) } return fields } @@ -20633,16 +20621,12 @@ func (m *RevocationMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *RevocationMutation) Field(name string) (ent.Value, bool) { +func (m *ProfileIssueMutation) Field(name string) (ent.Value, bool) { switch name { - case revocation.FieldReason: - return m.Reason() - case revocation.FieldInfo: - return m.Info() - case revocation.FieldExpiry: - return m.Expiry() - case revocation.FieldRevoked: - return m.Revoked() + case profileissue.FieldError: + return m.Error() + case profileissue.FieldWhen: + return m.When() } return nil, false } @@ -20650,238 +20634,228 @@ func (m *RevocationMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *RevocationMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ProfileIssueMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case revocation.FieldReason: - return m.OldReason(ctx) - case revocation.FieldInfo: - return m.OldInfo(ctx) - case revocation.FieldExpiry: - return m.OldExpiry(ctx) - case revocation.FieldRevoked: - return m.OldRevoked(ctx) + case profileissue.FieldError: + return m.OldError(ctx) + case profileissue.FieldWhen: + return m.OldWhen(ctx) } - return nil, fmt.Errorf("unknown Revocation field %s", name) + return nil, fmt.Errorf("unknown ProfileIssue field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RevocationMutation) SetField(name string, value ent.Value) error { +func (m *ProfileIssueMutation) SetField(name string, value ent.Value) error { switch name { - case revocation.FieldReason: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetReason(v) - return nil - case revocation.FieldInfo: + case profileissue.FieldError: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetInfo(v) - return nil - case revocation.FieldExpiry: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetExpiry(v) + m.SetError(v) return nil - case revocation.FieldRevoked: + case profileissue.FieldWhen: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRevoked(v) + m.SetWhen(v) return nil } - return fmt.Errorf("unknown Revocation field %s", name) + return fmt.Errorf("unknown ProfileIssue field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *RevocationMutation) AddedFields() []string { - var fields []string - if m.addreason != nil { - fields = append(fields, revocation.FieldReason) - } - return fields +func (m *ProfileIssueMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *RevocationMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case revocation.FieldReason: - return m.AddedReason() - } +func (m *ProfileIssueMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RevocationMutation) AddField(name string, value ent.Value) error { +func (m *ProfileIssueMutation) AddField(name string, value ent.Value) error { switch name { - case revocation.FieldReason: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddReason(v) - return nil } - return fmt.Errorf("unknown Revocation numeric field %s", name) + return fmt.Errorf("unknown ProfileIssue numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *RevocationMutation) ClearedFields() []string { +func (m *ProfileIssueMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(revocation.FieldReason) { - fields = append(fields, revocation.FieldReason) - } - if m.FieldCleared(revocation.FieldInfo) { - fields = append(fields, revocation.FieldInfo) + if m.FieldCleared(profileissue.FieldError) { + fields = append(fields, profileissue.FieldError) } - if m.FieldCleared(revocation.FieldExpiry) { - fields = append(fields, revocation.FieldExpiry) + if m.FieldCleared(profileissue.FieldWhen) { + fields = append(fields, profileissue.FieldWhen) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *RevocationMutation) FieldCleared(name string) bool { +func (m *ProfileIssueMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *RevocationMutation) ClearField(name string) error { +func (m *ProfileIssueMutation) ClearField(name string) error { switch name { - case revocation.FieldReason: - m.ClearReason() - return nil - case revocation.FieldInfo: - m.ClearInfo() + case profileissue.FieldError: + m.ClearError() return nil - case revocation.FieldExpiry: - m.ClearExpiry() + case profileissue.FieldWhen: + m.ClearWhen() return nil } - return fmt.Errorf("unknown Revocation nullable field %s", name) + return fmt.Errorf("unknown ProfileIssue nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *RevocationMutation) ResetField(name string) error { +func (m *ProfileIssueMutation) ResetField(name string) error { switch name { - case revocation.FieldReason: - m.ResetReason() - return nil - case revocation.FieldInfo: - m.ResetInfo() - return nil - case revocation.FieldExpiry: - m.ResetExpiry() + case profileissue.FieldError: + m.ResetError() return nil - case revocation.FieldRevoked: - m.ResetRevoked() + case profileissue.FieldWhen: + m.ResetWhen() return nil } - return fmt.Errorf("unknown Revocation field %s", name) + return fmt.Errorf("unknown ProfileIssue field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *RevocationMutation) AddedEdges() []string { - edges := make([]string, 0, 0) +func (m *ProfileIssueMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.profile != nil { + edges = append(edges, profileissue.EdgeProfile) + } + if m.agents != nil { + edges = append(edges, profileissue.EdgeAgents) + } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *RevocationMutation) AddedIDs(name string) []ent.Value { +func (m *ProfileIssueMutation) AddedIDs(name string) []ent.Value { + switch name { + case profileissue.EdgeProfile: + if id := m.profile; id != nil { + return []ent.Value{*id} + } + case profileissue.EdgeAgents: + if id := m.agents; id != nil { + return []ent.Value{*id} + } + } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *RevocationMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) +func (m *ProfileIssueMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *RevocationMutation) RemovedIDs(name string) []ent.Value { +func (m *ProfileIssueMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RevocationMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) +func (m *ProfileIssueMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedprofile { + edges = append(edges, profileissue.EdgeProfile) + } + if m.clearedagents { + edges = append(edges, profileissue.EdgeAgents) + } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *RevocationMutation) EdgeCleared(name string) bool { +func (m *ProfileIssueMutation) EdgeCleared(name string) bool { + switch name { + case profileissue.EdgeProfile: + return m.clearedprofile + case profileissue.EdgeAgents: + return m.clearedagents + } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *RevocationMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown Revocation unique edge %s", name) +func (m *ProfileIssueMutation) ClearEdge(name string) error { + switch name { + case profileissue.EdgeProfile: + m.ClearProfile() + return nil + case profileissue.EdgeAgents: + m.ClearAgents() + return nil + } + return fmt.Errorf("unknown ProfileIssue unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *RevocationMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown Revocation edge %s", name) +func (m *ProfileIssueMutation) ResetEdge(name string) error { + switch name { + case profileissue.EdgeProfile: + m.ResetProfile() + return nil + case profileissue.EdgeAgents: + m.ResetAgents() + return nil + } + return fmt.Errorf("unknown ProfileIssue edge %s", name) } -// RustdeskMutation represents an operation that mutates the Rustdesk nodes in the graph. -type RustdeskMutation struct { +// RecoveryCodeMutation represents an operation that mutates the RecoveryCode nodes in the graph. +type RecoveryCodeMutation struct { config - op Op - typ string - id *int - custom_rendezvous_server *string - relay_server *string - api_server *string - key *string - use_permanent_password *bool - whitelist *string - direct_ip_access *bool - verification_method *rustdesk.VerificationMethod - temporary_password_length *int - addtemporary_password_length *int - clearedFields map[string]struct{} - tenant map[int]struct{} - removedtenant map[int]struct{} - clearedtenant bool - done bool - oldValue func(context.Context) (*Rustdesk, error) - predicates []predicate.Rustdesk + op Op + typ string + id *int + code *string + used *bool + clearedFields map[string]struct{} + user *string + cleareduser bool + done bool + oldValue func(context.Context) (*RecoveryCode, error) + predicates []predicate.RecoveryCode } -var _ ent.Mutation = (*RustdeskMutation)(nil) +var _ ent.Mutation = (*RecoveryCodeMutation)(nil) -// rustdeskOption allows management of the mutation configuration using functional options. -type rustdeskOption func(*RustdeskMutation) +// recoverycodeOption allows management of the mutation configuration using functional options. +type recoverycodeOption func(*RecoveryCodeMutation) -// newRustdeskMutation creates new mutation for the Rustdesk entity. -func newRustdeskMutation(c config, op Op, opts ...rustdeskOption) *RustdeskMutation { - m := &RustdeskMutation{ +// newRecoveryCodeMutation creates new mutation for the RecoveryCode entity. +func newRecoveryCodeMutation(c config, op Op, opts ...recoverycodeOption) *RecoveryCodeMutation { + m := &RecoveryCodeMutation{ config: c, op: op, - typ: TypeRustdesk, + typ: TypeRecoveryCode, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -20890,20 +20864,20 @@ func newRustdeskMutation(c config, op Op, opts ...rustdeskOption) *RustdeskMutat return m } -// withRustdeskID sets the ID field of the mutation. -func withRustdeskID(id int) rustdeskOption { - return func(m *RustdeskMutation) { +// withRecoveryCodeID sets the ID field of the mutation. +func withRecoveryCodeID(id int) recoverycodeOption { + return func(m *RecoveryCodeMutation) { var ( err error once sync.Once - value *Rustdesk + value *RecoveryCode ) - m.oldValue = func(ctx context.Context) (*Rustdesk, error) { + m.oldValue = func(ctx context.Context) (*RecoveryCode, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Rustdesk.Get(ctx, id) + value, err = m.Client().RecoveryCode.Get(ctx, id) } }) return value, err @@ -20912,10 +20886,10 @@ func withRustdeskID(id int) rustdeskOption { } } -// withRustdesk sets the old Rustdesk of the mutation. -func withRustdesk(node *Rustdesk) rustdeskOption { - return func(m *RustdeskMutation) { - m.oldValue = func(context.Context) (*Rustdesk, error) { +// withRecoveryCode sets the old RecoveryCode of the mutation. +func withRecoveryCode(node *RecoveryCode) recoverycodeOption { + return func(m *RecoveryCodeMutation) { + m.oldValue = func(context.Context) (*RecoveryCode, error) { return node, nil } m.id = &node.ID @@ -20924,7 +20898,7 @@ func withRustdesk(node *Rustdesk) rustdeskOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m RustdeskMutation) Client() *Client { +func (m RecoveryCodeMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -20932,7 +20906,7 @@ func (m RustdeskMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m RustdeskMutation) Tx() (*Tx, error) { +func (m RecoveryCodeMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -20943,7 +20917,7 @@ func (m RustdeskMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *RustdeskMutation) ID() (id int, exists bool) { +func (m *RecoveryCodeMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -20954,7 +20928,7 @@ func (m *RustdeskMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *RustdeskMutation) IDs(ctx context.Context) ([]int, error) { +func (m *RecoveryCodeMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -20963,537 +20937,1071 @@ func (m *RustdeskMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Rustdesk.Query().Where(m.predicates...).IDs(ctx) + return m.Client().RecoveryCode.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetCustomRendezvousServer sets the "custom_rendezvous_server" field. -func (m *RustdeskMutation) SetCustomRendezvousServer(s string) { - m.custom_rendezvous_server = &s +// SetCode sets the "code" field. +func (m *RecoveryCodeMutation) SetCode(s string) { + m.code = &s } -// CustomRendezvousServer returns the value of the "custom_rendezvous_server" field in the mutation. -func (m *RustdeskMutation) CustomRendezvousServer() (r string, exists bool) { - v := m.custom_rendezvous_server +// Code returns the value of the "code" field in the mutation. +func (m *RecoveryCodeMutation) Code() (r string, exists bool) { + v := m.code if v == nil { return } return *v, true } -// OldCustomRendezvousServer returns the old "custom_rendezvous_server" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// OldCode returns the old "code" field's value of the RecoveryCode entity. +// If the RecoveryCode object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldCustomRendezvousServer(ctx context.Context) (v string, err error) { +func (m *RecoveryCodeMutation) OldCode(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCustomRendezvousServer is only allowed on UpdateOne operations") + return v, errors.New("OldCode is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCustomRendezvousServer requires an ID field in the mutation") + return v, errors.New("OldCode requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCustomRendezvousServer: %w", err) + return v, fmt.Errorf("querying old value for OldCode: %w", err) } - return oldValue.CustomRendezvousServer, nil -} - -// ClearCustomRendezvousServer clears the value of the "custom_rendezvous_server" field. -func (m *RustdeskMutation) ClearCustomRendezvousServer() { - m.custom_rendezvous_server = nil - m.clearedFields[rustdesk.FieldCustomRendezvousServer] = struct{}{} -} - -// CustomRendezvousServerCleared returns if the "custom_rendezvous_server" field was cleared in this mutation. -func (m *RustdeskMutation) CustomRendezvousServerCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldCustomRendezvousServer] - return ok + return oldValue.Code, nil } -// ResetCustomRendezvousServer resets all changes to the "custom_rendezvous_server" field. -func (m *RustdeskMutation) ResetCustomRendezvousServer() { - m.custom_rendezvous_server = nil - delete(m.clearedFields, rustdesk.FieldCustomRendezvousServer) +// ResetCode resets all changes to the "code" field. +func (m *RecoveryCodeMutation) ResetCode() { + m.code = nil } -// SetRelayServer sets the "relay_server" field. -func (m *RustdeskMutation) SetRelayServer(s string) { - m.relay_server = &s +// SetUsed sets the "used" field. +func (m *RecoveryCodeMutation) SetUsed(b bool) { + m.used = &b } -// RelayServer returns the value of the "relay_server" field in the mutation. -func (m *RustdeskMutation) RelayServer() (r string, exists bool) { - v := m.relay_server +// Used returns the value of the "used" field in the mutation. +func (m *RecoveryCodeMutation) Used() (r bool, exists bool) { + v := m.used if v == nil { return } return *v, true } -// OldRelayServer returns the old "relay_server" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// OldUsed returns the old "used" field's value of the RecoveryCode entity. +// If the RecoveryCode object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldRelayServer(ctx context.Context) (v string, err error) { +func (m *RecoveryCodeMutation) OldUsed(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRelayServer is only allowed on UpdateOne operations") + return v, errors.New("OldUsed is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRelayServer requires an ID field in the mutation") + return v, errors.New("OldUsed requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRelayServer: %w", err) + return v, fmt.Errorf("querying old value for OldUsed: %w", err) } - return oldValue.RelayServer, nil + return oldValue.Used, nil } -// ClearRelayServer clears the value of the "relay_server" field. -func (m *RustdeskMutation) ClearRelayServer() { - m.relay_server = nil - m.clearedFields[rustdesk.FieldRelayServer] = struct{}{} +// ResetUsed resets all changes to the "used" field. +func (m *RecoveryCodeMutation) ResetUsed() { + m.used = nil } -// RelayServerCleared returns if the "relay_server" field was cleared in this mutation. -func (m *RustdeskMutation) RelayServerCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldRelayServer] - return ok +// SetUserID sets the "user" edge to the User entity by id. +func (m *RecoveryCodeMutation) SetUserID(id string) { + m.user = &id } -// ResetRelayServer resets all changes to the "relay_server" field. -func (m *RustdeskMutation) ResetRelayServer() { - m.relay_server = nil - delete(m.clearedFields, rustdesk.FieldRelayServer) +// ClearUser clears the "user" edge to the User entity. +func (m *RecoveryCodeMutation) ClearUser() { + m.cleareduser = true } -// SetAPIServer sets the "api_server" field. -func (m *RustdeskMutation) SetAPIServer(s string) { - m.api_server = &s +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *RecoveryCodeMutation) UserCleared() bool { + return m.cleareduser } -// APIServer returns the value of the "api_server" field in the mutation. -func (m *RustdeskMutation) APIServer() (r string, exists bool) { - v := m.api_server - if v == nil { - return +// UserID returns the "user" edge ID in the mutation. +func (m *RecoveryCodeMutation) UserID() (id string, exists bool) { + if m.user != nil { + return *m.user, true } - return *v, true + return } -// OldAPIServer returns the old "api_server" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldAPIServer(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAPIServer is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAPIServer requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAPIServer: %w", err) +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *RecoveryCodeMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) } - return oldValue.APIServer, nil + return } -// ClearAPIServer clears the value of the "api_server" field. -func (m *RustdeskMutation) ClearAPIServer() { - m.api_server = nil - m.clearedFields[rustdesk.FieldAPIServer] = struct{}{} +// ResetUser resets all changes to the "user" edge. +func (m *RecoveryCodeMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// APIServerCleared returns if the "api_server" field was cleared in this mutation. -func (m *RustdeskMutation) APIServerCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldAPIServer] - return ok +// Where appends a list predicates to the RecoveryCodeMutation builder. +func (m *RecoveryCodeMutation) Where(ps ...predicate.RecoveryCode) { + m.predicates = append(m.predicates, ps...) } -// ResetAPIServer resets all changes to the "api_server" field. -func (m *RustdeskMutation) ResetAPIServer() { - m.api_server = nil - delete(m.clearedFields, rustdesk.FieldAPIServer) +// WhereP appends storage-level predicates to the RecoveryCodeMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RecoveryCodeMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.RecoveryCode, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// SetKey sets the "key" field. -func (m *RustdeskMutation) SetKey(s string) { - m.key = &s +// Op returns the operation name. +func (m *RecoveryCodeMutation) Op() Op { + return m.op } -// Key returns the value of the "key" field in the mutation. -func (m *RustdeskMutation) Key() (r string, exists bool) { - v := m.key - if v == nil { - return - } - return *v, true +// SetOp allows setting the mutation operation. +func (m *RecoveryCodeMutation) SetOp(op Op) { + m.op = op } -// OldKey returns the old "key" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldKey(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKey requires an ID field in the mutation") +// Type returns the node type of this mutation (RecoveryCode). +func (m *RecoveryCodeMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *RecoveryCodeMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.code != nil { + fields = append(fields, recoverycode.FieldCode) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKey: %w", err) + if m.used != nil { + fields = append(fields, recoverycode.FieldUsed) } - return oldValue.Key, nil + return fields } -// ClearKey clears the value of the "key" field. -func (m *RustdeskMutation) ClearKey() { - m.key = nil - m.clearedFields[rustdesk.FieldKey] = struct{}{} +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *RecoveryCodeMutation) Field(name string) (ent.Value, bool) { + switch name { + case recoverycode.FieldCode: + return m.Code() + case recoverycode.FieldUsed: + return m.Used() + } + return nil, false } -// KeyCleared returns if the "key" field was cleared in this mutation. -func (m *RustdeskMutation) KeyCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldKey] - return ok +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *RecoveryCodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case recoverycode.FieldCode: + return m.OldCode(ctx) + case recoverycode.FieldUsed: + return m.OldUsed(ctx) + } + return nil, fmt.Errorf("unknown RecoveryCode field %s", name) } -// ResetKey resets all changes to the "key" field. -func (m *RustdeskMutation) ResetKey() { - m.key = nil - delete(m.clearedFields, rustdesk.FieldKey) +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RecoveryCodeMutation) SetField(name string, value ent.Value) error { + switch name { + case recoverycode.FieldCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCode(v) + return nil + case recoverycode.FieldUsed: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsed(v) + return nil + } + return fmt.Errorf("unknown RecoveryCode field %s", name) } -// SetUsePermanentPassword sets the "use_permanent_password" field. -func (m *RustdeskMutation) SetUsePermanentPassword(b bool) { - m.use_permanent_password = &b +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *RecoveryCodeMutation) AddedFields() []string { + return nil } -// UsePermanentPassword returns the value of the "use_permanent_password" field in the mutation. -func (m *RustdeskMutation) UsePermanentPassword() (r bool, exists bool) { - v := m.use_permanent_password - if v == nil { - return - } - return *v, true +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *RecoveryCodeMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// OldUsePermanentPassword returns the old "use_permanent_password" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldUsePermanentPassword(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsePermanentPassword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsePermanentPassword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUsePermanentPassword: %w", err) +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RecoveryCodeMutation) AddField(name string, value ent.Value) error { + switch name { } - return oldValue.UsePermanentPassword, nil + return fmt.Errorf("unknown RecoveryCode numeric field %s", name) } -// ClearUsePermanentPassword clears the value of the "use_permanent_password" field. -func (m *RustdeskMutation) ClearUsePermanentPassword() { - m.use_permanent_password = nil - m.clearedFields[rustdesk.FieldUsePermanentPassword] = struct{}{} +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *RecoveryCodeMutation) ClearedFields() []string { + return nil } -// UsePermanentPasswordCleared returns if the "use_permanent_password" field was cleared in this mutation. -func (m *RustdeskMutation) UsePermanentPasswordCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldUsePermanentPassword] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *RecoveryCodeMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetUsePermanentPassword resets all changes to the "use_permanent_password" field. -func (m *RustdeskMutation) ResetUsePermanentPassword() { - m.use_permanent_password = nil - delete(m.clearedFields, rustdesk.FieldUsePermanentPassword) +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *RecoveryCodeMutation) ClearField(name string) error { + return fmt.Errorf("unknown RecoveryCode nullable field %s", name) } -// SetWhitelist sets the "whitelist" field. -func (m *RustdeskMutation) SetWhitelist(s string) { - m.whitelist = &s +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *RecoveryCodeMutation) ResetField(name string) error { + switch name { + case recoverycode.FieldCode: + m.ResetCode() + return nil + case recoverycode.FieldUsed: + m.ResetUsed() + return nil + } + return fmt.Errorf("unknown RecoveryCode field %s", name) } -// Whitelist returns the value of the "whitelist" field in the mutation. -func (m *RustdeskMutation) Whitelist() (r string, exists bool) { - v := m.whitelist +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *RecoveryCodeMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.user != nil { + edges = append(edges, recoverycode.EdgeUser) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *RecoveryCodeMutation) AddedIDs(name string) []ent.Value { + switch name { + case recoverycode.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *RecoveryCodeMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *RecoveryCodeMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RecoveryCodeMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.cleareduser { + edges = append(edges, recoverycode.EdgeUser) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *RecoveryCodeMutation) EdgeCleared(name string) bool { + switch name { + case recoverycode.EdgeUser: + return m.cleareduser + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *RecoveryCodeMutation) ClearEdge(name string) error { + switch name { + case recoverycode.EdgeUser: + m.ClearUser() + return nil + } + return fmt.Errorf("unknown RecoveryCode unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *RecoveryCodeMutation) ResetEdge(name string) error { + switch name { + case recoverycode.EdgeUser: + m.ResetUser() + return nil + } + return fmt.Errorf("unknown RecoveryCode edge %s", name) +} + +// ReleaseMutation represents an operation that mutates the Release nodes in the graph. +type ReleaseMutation struct { + config + op Op + typ string + id *int + release_type *release.ReleaseType + version *string + channel *string + summary *string + release_notes *string + file_url *string + checksum *string + is_critical *bool + release_date *time.Time + os *string + arch *string + clearedFields map[string]struct{} + agents map[string]struct{} + removedagents map[string]struct{} + clearedagents bool + done bool + oldValue func(context.Context) (*Release, error) + predicates []predicate.Release +} + +var _ ent.Mutation = (*ReleaseMutation)(nil) + +// releaseOption allows management of the mutation configuration using functional options. +type releaseOption func(*ReleaseMutation) + +// newReleaseMutation creates new mutation for the Release entity. +func newReleaseMutation(c config, op Op, opts ...releaseOption) *ReleaseMutation { + m := &ReleaseMutation{ + config: c, + op: op, + typ: TypeRelease, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withReleaseID sets the ID field of the mutation. +func withReleaseID(id int) releaseOption { + return func(m *ReleaseMutation) { + var ( + err error + once sync.Once + value *Release + ) + m.oldValue = func(ctx context.Context) (*Release, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Release.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withRelease sets the old Release of the mutation. +func withRelease(node *Release) releaseOption { + return func(m *ReleaseMutation) { + m.oldValue = func(context.Context) (*Release, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ReleaseMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ReleaseMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ReleaseMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ReleaseMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Release.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetReleaseType sets the "release_type" field. +func (m *ReleaseMutation) SetReleaseType(rt release.ReleaseType) { + m.release_type = &rt +} + +// ReleaseType returns the value of the "release_type" field in the mutation. +func (m *ReleaseMutation) ReleaseType() (r release.ReleaseType, exists bool) { + v := m.release_type if v == nil { return } return *v, true } -// OldWhitelist returns the old "whitelist" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// OldReleaseType returns the old "release_type" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldWhitelist(ctx context.Context) (v string, err error) { +func (m *ReleaseMutation) OldReleaseType(ctx context.Context) (v release.ReleaseType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWhitelist is only allowed on UpdateOne operations") + return v, errors.New("OldReleaseType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWhitelist requires an ID field in the mutation") + return v, errors.New("OldReleaseType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldWhitelist: %w", err) + return v, fmt.Errorf("querying old value for OldReleaseType: %w", err) } - return oldValue.Whitelist, nil + return oldValue.ReleaseType, nil } -// ClearWhitelist clears the value of the "whitelist" field. -func (m *RustdeskMutation) ClearWhitelist() { - m.whitelist = nil - m.clearedFields[rustdesk.FieldWhitelist] = struct{}{} +// ClearReleaseType clears the value of the "release_type" field. +func (m *ReleaseMutation) ClearReleaseType() { + m.release_type = nil + m.clearedFields[release.FieldReleaseType] = struct{}{} } -// WhitelistCleared returns if the "whitelist" field was cleared in this mutation. -func (m *RustdeskMutation) WhitelistCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldWhitelist] +// ReleaseTypeCleared returns if the "release_type" field was cleared in this mutation. +func (m *ReleaseMutation) ReleaseTypeCleared() bool { + _, ok := m.clearedFields[release.FieldReleaseType] return ok } -// ResetWhitelist resets all changes to the "whitelist" field. -func (m *RustdeskMutation) ResetWhitelist() { - m.whitelist = nil - delete(m.clearedFields, rustdesk.FieldWhitelist) +// ResetReleaseType resets all changes to the "release_type" field. +func (m *ReleaseMutation) ResetReleaseType() { + m.release_type = nil + delete(m.clearedFields, release.FieldReleaseType) } -// SetDirectIPAccess sets the "direct_ip_access" field. -func (m *RustdeskMutation) SetDirectIPAccess(b bool) { - m.direct_ip_access = &b +// SetVersion sets the "version" field. +func (m *ReleaseMutation) SetVersion(s string) { + m.version = &s } -// DirectIPAccess returns the value of the "direct_ip_access" field in the mutation. -func (m *RustdeskMutation) DirectIPAccess() (r bool, exists bool) { - v := m.direct_ip_access +// Version returns the value of the "version" field in the mutation. +func (m *ReleaseMutation) Version() (r string, exists bool) { + v := m.version if v == nil { return } return *v, true } -// OldDirectIPAccess returns the old "direct_ip_access" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// OldVersion returns the old "version" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldDirectIPAccess(ctx context.Context) (v bool, err error) { +func (m *ReleaseMutation) OldVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDirectIPAccess is only allowed on UpdateOne operations") + return v, errors.New("OldVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDirectIPAccess requires an ID field in the mutation") + return v, errors.New("OldVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDirectIPAccess: %w", err) + return v, fmt.Errorf("querying old value for OldVersion: %w", err) } - return oldValue.DirectIPAccess, nil + return oldValue.Version, nil } -// ClearDirectIPAccess clears the value of the "direct_ip_access" field. -func (m *RustdeskMutation) ClearDirectIPAccess() { - m.direct_ip_access = nil - m.clearedFields[rustdesk.FieldDirectIPAccess] = struct{}{} +// ClearVersion clears the value of the "version" field. +func (m *ReleaseMutation) ClearVersion() { + m.version = nil + m.clearedFields[release.FieldVersion] = struct{}{} } -// DirectIPAccessCleared returns if the "direct_ip_access" field was cleared in this mutation. -func (m *RustdeskMutation) DirectIPAccessCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldDirectIPAccess] +// VersionCleared returns if the "version" field was cleared in this mutation. +func (m *ReleaseMutation) VersionCleared() bool { + _, ok := m.clearedFields[release.FieldVersion] return ok } -// ResetDirectIPAccess resets all changes to the "direct_ip_access" field. -func (m *RustdeskMutation) ResetDirectIPAccess() { - m.direct_ip_access = nil - delete(m.clearedFields, rustdesk.FieldDirectIPAccess) +// ResetVersion resets all changes to the "version" field. +func (m *ReleaseMutation) ResetVersion() { + m.version = nil + delete(m.clearedFields, release.FieldVersion) } -// SetVerificationMethod sets the "verification_method" field. -func (m *RustdeskMutation) SetVerificationMethod(rm rustdesk.VerificationMethod) { - m.verification_method = &rm +// SetChannel sets the "channel" field. +func (m *ReleaseMutation) SetChannel(s string) { + m.channel = &s } -// VerificationMethod returns the value of the "verification_method" field in the mutation. -func (m *RustdeskMutation) VerificationMethod() (r rustdesk.VerificationMethod, exists bool) { - v := m.verification_method +// Channel returns the value of the "channel" field in the mutation. +func (m *ReleaseMutation) Channel() (r string, exists bool) { + v := m.channel if v == nil { return } return *v, true } -// OldVerificationMethod returns the old "verification_method" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// OldChannel returns the old "channel" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldVerificationMethod(ctx context.Context) (v rustdesk.VerificationMethod, err error) { +func (m *ReleaseMutation) OldChannel(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVerificationMethod is only allowed on UpdateOne operations") + return v, errors.New("OldChannel is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVerificationMethod requires an ID field in the mutation") + return v, errors.New("OldChannel requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVerificationMethod: %w", err) + return v, fmt.Errorf("querying old value for OldChannel: %w", err) } - return oldValue.VerificationMethod, nil + return oldValue.Channel, nil } -// ClearVerificationMethod clears the value of the "verification_method" field. -func (m *RustdeskMutation) ClearVerificationMethod() { - m.verification_method = nil - m.clearedFields[rustdesk.FieldVerificationMethod] = struct{}{} +// ClearChannel clears the value of the "channel" field. +func (m *ReleaseMutation) ClearChannel() { + m.channel = nil + m.clearedFields[release.FieldChannel] = struct{}{} } -// VerificationMethodCleared returns if the "verification_method" field was cleared in this mutation. -func (m *RustdeskMutation) VerificationMethodCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldVerificationMethod] +// ChannelCleared returns if the "channel" field was cleared in this mutation. +func (m *ReleaseMutation) ChannelCleared() bool { + _, ok := m.clearedFields[release.FieldChannel] return ok } -// ResetVerificationMethod resets all changes to the "verification_method" field. -func (m *RustdeskMutation) ResetVerificationMethod() { - m.verification_method = nil - delete(m.clearedFields, rustdesk.FieldVerificationMethod) +// ResetChannel resets all changes to the "channel" field. +func (m *ReleaseMutation) ResetChannel() { + m.channel = nil + delete(m.clearedFields, release.FieldChannel) } -// SetTemporaryPasswordLength sets the "temporary_password_length" field. -func (m *RustdeskMutation) SetTemporaryPasswordLength(i int) { - m.temporary_password_length = &i - m.addtemporary_password_length = nil +// SetSummary sets the "summary" field. +func (m *ReleaseMutation) SetSummary(s string) { + m.summary = &s } -// TemporaryPasswordLength returns the value of the "temporary_password_length" field in the mutation. -func (m *RustdeskMutation) TemporaryPasswordLength() (r int, exists bool) { - v := m.temporary_password_length +// Summary returns the value of the "summary" field in the mutation. +func (m *ReleaseMutation) Summary() (r string, exists bool) { + v := m.summary if v == nil { return } return *v, true } -// OldTemporaryPasswordLength returns the old "temporary_password_length" field's value of the Rustdesk entity. -// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// OldSummary returns the old "summary" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RustdeskMutation) OldTemporaryPasswordLength(ctx context.Context) (v int, err error) { +func (m *ReleaseMutation) OldSummary(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTemporaryPasswordLength is only allowed on UpdateOne operations") + return v, errors.New("OldSummary is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTemporaryPasswordLength requires an ID field in the mutation") + return v, errors.New("OldSummary requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTemporaryPasswordLength: %w", err) + return v, fmt.Errorf("querying old value for OldSummary: %w", err) } - return oldValue.TemporaryPasswordLength, nil + return oldValue.Summary, nil } -// AddTemporaryPasswordLength adds i to the "temporary_password_length" field. -func (m *RustdeskMutation) AddTemporaryPasswordLength(i int) { - if m.addtemporary_password_length != nil { - *m.addtemporary_password_length += i - } else { - m.addtemporary_password_length = &i - } +// ClearSummary clears the value of the "summary" field. +func (m *ReleaseMutation) ClearSummary() { + m.summary = nil + m.clearedFields[release.FieldSummary] = struct{}{} } -// AddedTemporaryPasswordLength returns the value that was added to the "temporary_password_length" field in this mutation. -func (m *RustdeskMutation) AddedTemporaryPasswordLength() (r int, exists bool) { - v := m.addtemporary_password_length - if v == nil { - return - } - return *v, true +// SummaryCleared returns if the "summary" field was cleared in this mutation. +func (m *ReleaseMutation) SummaryCleared() bool { + _, ok := m.clearedFields[release.FieldSummary] + return ok } -// ClearTemporaryPasswordLength clears the value of the "temporary_password_length" field. -func (m *RustdeskMutation) ClearTemporaryPasswordLength() { - m.temporary_password_length = nil - m.addtemporary_password_length = nil - m.clearedFields[rustdesk.FieldTemporaryPasswordLength] = struct{}{} +// ResetSummary resets all changes to the "summary" field. +func (m *ReleaseMutation) ResetSummary() { + m.summary = nil + delete(m.clearedFields, release.FieldSummary) } -// TemporaryPasswordLengthCleared returns if the "temporary_password_length" field was cleared in this mutation. -func (m *RustdeskMutation) TemporaryPasswordLengthCleared() bool { - _, ok := m.clearedFields[rustdesk.FieldTemporaryPasswordLength] - return ok +// SetReleaseNotes sets the "release_notes" field. +func (m *ReleaseMutation) SetReleaseNotes(s string) { + m.release_notes = &s } -// ResetTemporaryPasswordLength resets all changes to the "temporary_password_length" field. -func (m *RustdeskMutation) ResetTemporaryPasswordLength() { - m.temporary_password_length = nil - m.addtemporary_password_length = nil - delete(m.clearedFields, rustdesk.FieldTemporaryPasswordLength) +// ReleaseNotes returns the value of the "release_notes" field in the mutation. +func (m *ReleaseMutation) ReleaseNotes() (r string, exists bool) { + v := m.release_notes + if v == nil { + return + } + return *v, true } -// AddTenantIDs adds the "tenant" edge to the Tenant entity by ids. -func (m *RustdeskMutation) AddTenantIDs(ids ...int) { - if m.tenant == nil { - m.tenant = make(map[int]struct{}) +// OldReleaseNotes returns the old "release_notes" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldReleaseNotes(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReleaseNotes is only allowed on UpdateOne operations") } - for i := range ids { - m.tenant[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReleaseNotes requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReleaseNotes: %w", err) } + return oldValue.ReleaseNotes, nil } -// ClearTenant clears the "tenant" edge to the Tenant entity. -func (m *RustdeskMutation) ClearTenant() { - m.clearedtenant = true +// ClearReleaseNotes clears the value of the "release_notes" field. +func (m *ReleaseMutation) ClearReleaseNotes() { + m.release_notes = nil + m.clearedFields[release.FieldReleaseNotes] = struct{}{} } -// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. -func (m *RustdeskMutation) TenantCleared() bool { - return m.clearedtenant +// ReleaseNotesCleared returns if the "release_notes" field was cleared in this mutation. +func (m *ReleaseMutation) ReleaseNotesCleared() bool { + _, ok := m.clearedFields[release.FieldReleaseNotes] + return ok } -// RemoveTenantIDs removes the "tenant" edge to the Tenant entity by IDs. -func (m *RustdeskMutation) RemoveTenantIDs(ids ...int) { - if m.removedtenant == nil { - m.removedtenant = make(map[int]struct{}) - } - for i := range ids { - delete(m.tenant, ids[i]) - m.removedtenant[ids[i]] = struct{}{} - } +// ResetReleaseNotes resets all changes to the "release_notes" field. +func (m *ReleaseMutation) ResetReleaseNotes() { + m.release_notes = nil + delete(m.clearedFields, release.FieldReleaseNotes) } -// RemovedTenant returns the removed IDs of the "tenant" edge to the Tenant entity. -func (m *RustdeskMutation) RemovedTenantIDs() (ids []int) { - for id := range m.removedtenant { - ids = append(ids, id) - } - return +// SetFileURL sets the "file_url" field. +func (m *ReleaseMutation) SetFileURL(s string) { + m.file_url = &s } -// TenantIDs returns the "tenant" edge IDs in the mutation. -func (m *RustdeskMutation) TenantIDs() (ids []int) { - for id := range m.tenant { - ids = append(ids, id) +// FileURL returns the value of the "file_url" field in the mutation. +func (m *ReleaseMutation) FileURL() (r string, exists bool) { + v := m.file_url + if v == nil { + return } - return -} - -// ResetTenant resets all changes to the "tenant" edge. -func (m *RustdeskMutation) ResetTenant() { - m.tenant = nil - m.clearedtenant = false - m.removedtenant = nil + return *v, true } -// Where appends a list predicates to the RustdeskMutation builder. -func (m *RustdeskMutation) Where(ps ...predicate.Rustdesk) { +// OldFileURL returns the old "file_url" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldFileURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFileURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFileURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFileURL: %w", err) + } + return oldValue.FileURL, nil +} + +// ClearFileURL clears the value of the "file_url" field. +func (m *ReleaseMutation) ClearFileURL() { + m.file_url = nil + m.clearedFields[release.FieldFileURL] = struct{}{} +} + +// FileURLCleared returns if the "file_url" field was cleared in this mutation. +func (m *ReleaseMutation) FileURLCleared() bool { + _, ok := m.clearedFields[release.FieldFileURL] + return ok +} + +// ResetFileURL resets all changes to the "file_url" field. +func (m *ReleaseMutation) ResetFileURL() { + m.file_url = nil + delete(m.clearedFields, release.FieldFileURL) +} + +// SetChecksum sets the "checksum" field. +func (m *ReleaseMutation) SetChecksum(s string) { + m.checksum = &s +} + +// Checksum returns the value of the "checksum" field in the mutation. +func (m *ReleaseMutation) Checksum() (r string, exists bool) { + v := m.checksum + if v == nil { + return + } + return *v, true +} + +// OldChecksum returns the old "checksum" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldChecksum(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChecksum is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChecksum requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChecksum: %w", err) + } + return oldValue.Checksum, nil +} + +// ClearChecksum clears the value of the "checksum" field. +func (m *ReleaseMutation) ClearChecksum() { + m.checksum = nil + m.clearedFields[release.FieldChecksum] = struct{}{} +} + +// ChecksumCleared returns if the "checksum" field was cleared in this mutation. +func (m *ReleaseMutation) ChecksumCleared() bool { + _, ok := m.clearedFields[release.FieldChecksum] + return ok +} + +// ResetChecksum resets all changes to the "checksum" field. +func (m *ReleaseMutation) ResetChecksum() { + m.checksum = nil + delete(m.clearedFields, release.FieldChecksum) +} + +// SetIsCritical sets the "is_critical" field. +func (m *ReleaseMutation) SetIsCritical(b bool) { + m.is_critical = &b +} + +// IsCritical returns the value of the "is_critical" field in the mutation. +func (m *ReleaseMutation) IsCritical() (r bool, exists bool) { + v := m.is_critical + if v == nil { + return + } + return *v, true +} + +// OldIsCritical returns the old "is_critical" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldIsCritical(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsCritical is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsCritical requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsCritical: %w", err) + } + return oldValue.IsCritical, nil +} + +// ClearIsCritical clears the value of the "is_critical" field. +func (m *ReleaseMutation) ClearIsCritical() { + m.is_critical = nil + m.clearedFields[release.FieldIsCritical] = struct{}{} +} + +// IsCriticalCleared returns if the "is_critical" field was cleared in this mutation. +func (m *ReleaseMutation) IsCriticalCleared() bool { + _, ok := m.clearedFields[release.FieldIsCritical] + return ok +} + +// ResetIsCritical resets all changes to the "is_critical" field. +func (m *ReleaseMutation) ResetIsCritical() { + m.is_critical = nil + delete(m.clearedFields, release.FieldIsCritical) +} + +// SetReleaseDate sets the "release_date" field. +func (m *ReleaseMutation) SetReleaseDate(t time.Time) { + m.release_date = &t +} + +// ReleaseDate returns the value of the "release_date" field in the mutation. +func (m *ReleaseMutation) ReleaseDate() (r time.Time, exists bool) { + v := m.release_date + if v == nil { + return + } + return *v, true +} + +// OldReleaseDate returns the old "release_date" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldReleaseDate(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReleaseDate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReleaseDate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReleaseDate: %w", err) + } + return oldValue.ReleaseDate, nil +} + +// ClearReleaseDate clears the value of the "release_date" field. +func (m *ReleaseMutation) ClearReleaseDate() { + m.release_date = nil + m.clearedFields[release.FieldReleaseDate] = struct{}{} +} + +// ReleaseDateCleared returns if the "release_date" field was cleared in this mutation. +func (m *ReleaseMutation) ReleaseDateCleared() bool { + _, ok := m.clearedFields[release.FieldReleaseDate] + return ok +} + +// ResetReleaseDate resets all changes to the "release_date" field. +func (m *ReleaseMutation) ResetReleaseDate() { + m.release_date = nil + delete(m.clearedFields, release.FieldReleaseDate) +} + +// SetOs sets the "os" field. +func (m *ReleaseMutation) SetOs(s string) { + m.os = &s +} + +// Os returns the value of the "os" field in the mutation. +func (m *ReleaseMutation) Os() (r string, exists bool) { + v := m.os + if v == nil { + return + } + return *v, true +} + +// OldOs returns the old "os" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldOs(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOs is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOs requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOs: %w", err) + } + return oldValue.Os, nil +} + +// ClearOs clears the value of the "os" field. +func (m *ReleaseMutation) ClearOs() { + m.os = nil + m.clearedFields[release.FieldOs] = struct{}{} +} + +// OsCleared returns if the "os" field was cleared in this mutation. +func (m *ReleaseMutation) OsCleared() bool { + _, ok := m.clearedFields[release.FieldOs] + return ok +} + +// ResetOs resets all changes to the "os" field. +func (m *ReleaseMutation) ResetOs() { + m.os = nil + delete(m.clearedFields, release.FieldOs) +} + +// SetArch sets the "arch" field. +func (m *ReleaseMutation) SetArch(s string) { + m.arch = &s +} + +// Arch returns the value of the "arch" field in the mutation. +func (m *ReleaseMutation) Arch() (r string, exists bool) { + v := m.arch + if v == nil { + return + } + return *v, true +} + +// OldArch returns the old "arch" field's value of the Release entity. +// If the Release object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ReleaseMutation) OldArch(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldArch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldArch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldArch: %w", err) + } + return oldValue.Arch, nil +} + +// ClearArch clears the value of the "arch" field. +func (m *ReleaseMutation) ClearArch() { + m.arch = nil + m.clearedFields[release.FieldArch] = struct{}{} +} + +// ArchCleared returns if the "arch" field was cleared in this mutation. +func (m *ReleaseMutation) ArchCleared() bool { + _, ok := m.clearedFields[release.FieldArch] + return ok +} + +// ResetArch resets all changes to the "arch" field. +func (m *ReleaseMutation) ResetArch() { + m.arch = nil + delete(m.clearedFields, release.FieldArch) +} + +// AddAgentIDs adds the "agents" edge to the Agent entity by ids. +func (m *ReleaseMutation) AddAgentIDs(ids ...string) { + if m.agents == nil { + m.agents = make(map[string]struct{}) + } + for i := range ids { + m.agents[ids[i]] = struct{}{} + } +} + +// ClearAgents clears the "agents" edge to the Agent entity. +func (m *ReleaseMutation) ClearAgents() { + m.clearedagents = true +} + +// AgentsCleared reports if the "agents" edge to the Agent entity was cleared. +func (m *ReleaseMutation) AgentsCleared() bool { + return m.clearedagents +} + +// RemoveAgentIDs removes the "agents" edge to the Agent entity by IDs. +func (m *ReleaseMutation) RemoveAgentIDs(ids ...string) { + if m.removedagents == nil { + m.removedagents = make(map[string]struct{}) + } + for i := range ids { + delete(m.agents, ids[i]) + m.removedagents[ids[i]] = struct{}{} + } +} + +// RemovedAgents returns the removed IDs of the "agents" edge to the Agent entity. +func (m *ReleaseMutation) RemovedAgentsIDs() (ids []string) { + for id := range m.removedagents { + ids = append(ids, id) + } + return +} + +// AgentsIDs returns the "agents" edge IDs in the mutation. +func (m *ReleaseMutation) AgentsIDs() (ids []string) { + for id := range m.agents { + ids = append(ids, id) + } + return +} + +// ResetAgents resets all changes to the "agents" edge. +func (m *ReleaseMutation) ResetAgents() { + m.agents = nil + m.clearedagents = false + m.removedagents = nil +} + +// Where appends a list predicates to the ReleaseMutation builder. +func (m *ReleaseMutation) Where(ps ...predicate.Release) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the RustdeskMutation builder. Using this method, +// WhereP appends storage-level predicates to the ReleaseMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RustdeskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Rustdesk, len(ps)) +func (m *ReleaseMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Release, len(ps)) for i := range ps { p[i] = ps[i] } @@ -21501,51 +22009,57 @@ func (m *RustdeskMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *RustdeskMutation) Op() Op { +func (m *ReleaseMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *RustdeskMutation) SetOp(op Op) { +func (m *ReleaseMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Rustdesk). -func (m *RustdeskMutation) Type() string { +// Type returns the node type of this mutation (Release). +func (m *ReleaseMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *RustdeskMutation) Fields() []string { - fields := make([]string, 0, 9) - if m.custom_rendezvous_server != nil { - fields = append(fields, rustdesk.FieldCustomRendezvousServer) +func (m *ReleaseMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.release_type != nil { + fields = append(fields, release.FieldReleaseType) } - if m.relay_server != nil { - fields = append(fields, rustdesk.FieldRelayServer) + if m.version != nil { + fields = append(fields, release.FieldVersion) } - if m.api_server != nil { - fields = append(fields, rustdesk.FieldAPIServer) + if m.channel != nil { + fields = append(fields, release.FieldChannel) } - if m.key != nil { - fields = append(fields, rustdesk.FieldKey) + if m.summary != nil { + fields = append(fields, release.FieldSummary) } - if m.use_permanent_password != nil { - fields = append(fields, rustdesk.FieldUsePermanentPassword) + if m.release_notes != nil { + fields = append(fields, release.FieldReleaseNotes) } - if m.whitelist != nil { - fields = append(fields, rustdesk.FieldWhitelist) + if m.file_url != nil { + fields = append(fields, release.FieldFileURL) } - if m.direct_ip_access != nil { - fields = append(fields, rustdesk.FieldDirectIPAccess) + if m.checksum != nil { + fields = append(fields, release.FieldChecksum) } - if m.verification_method != nil { - fields = append(fields, rustdesk.FieldVerificationMethod) + if m.is_critical != nil { + fields = append(fields, release.FieldIsCritical) } - if m.temporary_password_length != nil { - fields = append(fields, rustdesk.FieldTemporaryPasswordLength) + if m.release_date != nil { + fields = append(fields, release.FieldReleaseDate) + } + if m.os != nil { + fields = append(fields, release.FieldOs) + } + if m.arch != nil { + fields = append(fields, release.FieldArch) } return fields } @@ -21553,26 +22067,30 @@ func (m *RustdeskMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *RustdeskMutation) Field(name string) (ent.Value, bool) { +func (m *ReleaseMutation) Field(name string) (ent.Value, bool) { switch name { - case rustdesk.FieldCustomRendezvousServer: - return m.CustomRendezvousServer() - case rustdesk.FieldRelayServer: - return m.RelayServer() - case rustdesk.FieldAPIServer: - return m.APIServer() - case rustdesk.FieldKey: - return m.Key() - case rustdesk.FieldUsePermanentPassword: - return m.UsePermanentPassword() - case rustdesk.FieldWhitelist: - return m.Whitelist() - case rustdesk.FieldDirectIPAccess: - return m.DirectIPAccess() - case rustdesk.FieldVerificationMethod: - return m.VerificationMethod() - case rustdesk.FieldTemporaryPasswordLength: - return m.TemporaryPasswordLength() + case release.FieldReleaseType: + return m.ReleaseType() + case release.FieldVersion: + return m.Version() + case release.FieldChannel: + return m.Channel() + case release.FieldSummary: + return m.Summary() + case release.FieldReleaseNotes: + return m.ReleaseNotes() + case release.FieldFileURL: + return m.FileURL() + case release.FieldChecksum: + return m.Checksum() + case release.FieldIsCritical: + return m.IsCritical() + case release.FieldReleaseDate: + return m.ReleaseDate() + case release.FieldOs: + return m.Os() + case release.FieldArch: + return m.Arch() } return nil, false } @@ -21580,266 +22098,287 @@ func (m *RustdeskMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *RustdeskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ReleaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case rustdesk.FieldCustomRendezvousServer: - return m.OldCustomRendezvousServer(ctx) - case rustdesk.FieldRelayServer: - return m.OldRelayServer(ctx) - case rustdesk.FieldAPIServer: - return m.OldAPIServer(ctx) - case rustdesk.FieldKey: - return m.OldKey(ctx) - case rustdesk.FieldUsePermanentPassword: - return m.OldUsePermanentPassword(ctx) - case rustdesk.FieldWhitelist: - return m.OldWhitelist(ctx) - case rustdesk.FieldDirectIPAccess: - return m.OldDirectIPAccess(ctx) - case rustdesk.FieldVerificationMethod: - return m.OldVerificationMethod(ctx) - case rustdesk.FieldTemporaryPasswordLength: - return m.OldTemporaryPasswordLength(ctx) + case release.FieldReleaseType: + return m.OldReleaseType(ctx) + case release.FieldVersion: + return m.OldVersion(ctx) + case release.FieldChannel: + return m.OldChannel(ctx) + case release.FieldSummary: + return m.OldSummary(ctx) + case release.FieldReleaseNotes: + return m.OldReleaseNotes(ctx) + case release.FieldFileURL: + return m.OldFileURL(ctx) + case release.FieldChecksum: + return m.OldChecksum(ctx) + case release.FieldIsCritical: + return m.OldIsCritical(ctx) + case release.FieldReleaseDate: + return m.OldReleaseDate(ctx) + case release.FieldOs: + return m.OldOs(ctx) + case release.FieldArch: + return m.OldArch(ctx) } - return nil, fmt.Errorf("unknown Rustdesk field %s", name) + return nil, fmt.Errorf("unknown Release field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RustdeskMutation) SetField(name string, value ent.Value) error { +func (m *ReleaseMutation) SetField(name string, value ent.Value) error { switch name { - case rustdesk.FieldCustomRendezvousServer: - v, ok := value.(string) + case release.FieldReleaseType: + v, ok := value.(release.ReleaseType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCustomRendezvousServer(v) + m.SetReleaseType(v) return nil - case rustdesk.FieldRelayServer: + case release.FieldVersion: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRelayServer(v) + m.SetVersion(v) return nil - case rustdesk.FieldAPIServer: + case release.FieldChannel: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAPIServer(v) + m.SetChannel(v) return nil - case rustdesk.FieldKey: + case release.FieldSummary: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetKey(v) + m.SetSummary(v) return nil - case rustdesk.FieldUsePermanentPassword: - v, ok := value.(bool) + case release.FieldReleaseNotes: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUsePermanentPassword(v) + m.SetReleaseNotes(v) return nil - case rustdesk.FieldWhitelist: + case release.FieldFileURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetWhitelist(v) + m.SetFileURL(v) return nil - case rustdesk.FieldDirectIPAccess: + case release.FieldChecksum: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChecksum(v) + return nil + case release.FieldIsCritical: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDirectIPAccess(v) + m.SetIsCritical(v) return nil - case rustdesk.FieldVerificationMethod: - v, ok := value.(rustdesk.VerificationMethod) + case release.FieldReleaseDate: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVerificationMethod(v) + m.SetReleaseDate(v) return nil - case rustdesk.FieldTemporaryPasswordLength: - v, ok := value.(int) + case release.FieldOs: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTemporaryPasswordLength(v) + m.SetOs(v) + return nil + case release.FieldArch: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArch(v) return nil } - return fmt.Errorf("unknown Rustdesk field %s", name) + return fmt.Errorf("unknown Release field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *RustdeskMutation) AddedFields() []string { - var fields []string - if m.addtemporary_password_length != nil { - fields = append(fields, rustdesk.FieldTemporaryPasswordLength) - } - return fields +func (m *ReleaseMutation) AddedFields() []string { + return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *RustdeskMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case rustdesk.FieldTemporaryPasswordLength: - return m.AddedTemporaryPasswordLength() - } +func (m *ReleaseMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RustdeskMutation) AddField(name string, value ent.Value) error { +func (m *ReleaseMutation) AddField(name string, value ent.Value) error { switch name { - case rustdesk.FieldTemporaryPasswordLength: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddTemporaryPasswordLength(v) - return nil } - return fmt.Errorf("unknown Rustdesk numeric field %s", name) + return fmt.Errorf("unknown Release numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *RustdeskMutation) ClearedFields() []string { +func (m *ReleaseMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(rustdesk.FieldCustomRendezvousServer) { - fields = append(fields, rustdesk.FieldCustomRendezvousServer) + if m.FieldCleared(release.FieldReleaseType) { + fields = append(fields, release.FieldReleaseType) } - if m.FieldCleared(rustdesk.FieldRelayServer) { - fields = append(fields, rustdesk.FieldRelayServer) + if m.FieldCleared(release.FieldVersion) { + fields = append(fields, release.FieldVersion) } - if m.FieldCleared(rustdesk.FieldAPIServer) { - fields = append(fields, rustdesk.FieldAPIServer) + if m.FieldCleared(release.FieldChannel) { + fields = append(fields, release.FieldChannel) } - if m.FieldCleared(rustdesk.FieldKey) { - fields = append(fields, rustdesk.FieldKey) + if m.FieldCleared(release.FieldSummary) { + fields = append(fields, release.FieldSummary) } - if m.FieldCleared(rustdesk.FieldUsePermanentPassword) { - fields = append(fields, rustdesk.FieldUsePermanentPassword) + if m.FieldCleared(release.FieldReleaseNotes) { + fields = append(fields, release.FieldReleaseNotes) } - if m.FieldCleared(rustdesk.FieldWhitelist) { - fields = append(fields, rustdesk.FieldWhitelist) + if m.FieldCleared(release.FieldFileURL) { + fields = append(fields, release.FieldFileURL) } - if m.FieldCleared(rustdesk.FieldDirectIPAccess) { - fields = append(fields, rustdesk.FieldDirectIPAccess) + if m.FieldCleared(release.FieldChecksum) { + fields = append(fields, release.FieldChecksum) } - if m.FieldCleared(rustdesk.FieldVerificationMethod) { - fields = append(fields, rustdesk.FieldVerificationMethod) + if m.FieldCleared(release.FieldIsCritical) { + fields = append(fields, release.FieldIsCritical) } - if m.FieldCleared(rustdesk.FieldTemporaryPasswordLength) { - fields = append(fields, rustdesk.FieldTemporaryPasswordLength) + if m.FieldCleared(release.FieldReleaseDate) { + fields = append(fields, release.FieldReleaseDate) + } + if m.FieldCleared(release.FieldOs) { + fields = append(fields, release.FieldOs) + } + if m.FieldCleared(release.FieldArch) { + fields = append(fields, release.FieldArch) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *RustdeskMutation) FieldCleared(name string) bool { +func (m *ReleaseMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *RustdeskMutation) ClearField(name string) error { +func (m *ReleaseMutation) ClearField(name string) error { switch name { - case rustdesk.FieldCustomRendezvousServer: - m.ClearCustomRendezvousServer() + case release.FieldReleaseType: + m.ClearReleaseType() return nil - case rustdesk.FieldRelayServer: - m.ClearRelayServer() + case release.FieldVersion: + m.ClearVersion() return nil - case rustdesk.FieldAPIServer: - m.ClearAPIServer() + case release.FieldChannel: + m.ClearChannel() return nil - case rustdesk.FieldKey: - m.ClearKey() + case release.FieldSummary: + m.ClearSummary() return nil - case rustdesk.FieldUsePermanentPassword: - m.ClearUsePermanentPassword() + case release.FieldReleaseNotes: + m.ClearReleaseNotes() return nil - case rustdesk.FieldWhitelist: - m.ClearWhitelist() + case release.FieldFileURL: + m.ClearFileURL() return nil - case rustdesk.FieldDirectIPAccess: - m.ClearDirectIPAccess() + case release.FieldChecksum: + m.ClearChecksum() return nil - case rustdesk.FieldVerificationMethod: - m.ClearVerificationMethod() + case release.FieldIsCritical: + m.ClearIsCritical() return nil - case rustdesk.FieldTemporaryPasswordLength: - m.ClearTemporaryPasswordLength() + case release.FieldReleaseDate: + m.ClearReleaseDate() + return nil + case release.FieldOs: + m.ClearOs() + return nil + case release.FieldArch: + m.ClearArch() return nil } - return fmt.Errorf("unknown Rustdesk nullable field %s", name) + return fmt.Errorf("unknown Release nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *RustdeskMutation) ResetField(name string) error { +func (m *ReleaseMutation) ResetField(name string) error { switch name { - case rustdesk.FieldCustomRendezvousServer: - m.ResetCustomRendezvousServer() + case release.FieldReleaseType: + m.ResetReleaseType() return nil - case rustdesk.FieldRelayServer: - m.ResetRelayServer() + case release.FieldVersion: + m.ResetVersion() return nil - case rustdesk.FieldAPIServer: - m.ResetAPIServer() + case release.FieldChannel: + m.ResetChannel() return nil - case rustdesk.FieldKey: - m.ResetKey() + case release.FieldSummary: + m.ResetSummary() return nil - case rustdesk.FieldUsePermanentPassword: - m.ResetUsePermanentPassword() + case release.FieldReleaseNotes: + m.ResetReleaseNotes() return nil - case rustdesk.FieldWhitelist: - m.ResetWhitelist() + case release.FieldFileURL: + m.ResetFileURL() return nil - case rustdesk.FieldDirectIPAccess: - m.ResetDirectIPAccess() + case release.FieldChecksum: + m.ResetChecksum() return nil - case rustdesk.FieldVerificationMethod: - m.ResetVerificationMethod() + case release.FieldIsCritical: + m.ResetIsCritical() return nil - case rustdesk.FieldTemporaryPasswordLength: - m.ResetTemporaryPasswordLength() + case release.FieldReleaseDate: + m.ResetReleaseDate() + return nil + case release.FieldOs: + m.ResetOs() + return nil + case release.FieldArch: + m.ResetArch() return nil } - return fmt.Errorf("unknown Rustdesk field %s", name) + return fmt.Errorf("unknown Release field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *RustdeskMutation) AddedEdges() []string { +func (m *ReleaseMutation) AddedEdges() []string { edges := make([]string, 0, 1) - if m.tenant != nil { - edges = append(edges, rustdesk.EdgeTenant) + if m.agents != nil { + edges = append(edges, release.EdgeAgents) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *RustdeskMutation) AddedIDs(name string) []ent.Value { +func (m *ReleaseMutation) AddedIDs(name string) []ent.Value { switch name { - case rustdesk.EdgeTenant: - ids := make([]ent.Value, 0, len(m.tenant)) - for id := range m.tenant { + case release.EdgeAgents: + ids := make([]ent.Value, 0, len(m.agents)) + for id := range m.agents { ids = append(ids, id) } return ids @@ -21848,21 +22387,21 @@ func (m *RustdeskMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *RustdeskMutation) RemovedEdges() []string { +func (m *ReleaseMutation) RemovedEdges() []string { edges := make([]string, 0, 1) - if m.removedtenant != nil { - edges = append(edges, rustdesk.EdgeTenant) + if m.removedagents != nil { + edges = append(edges, release.EdgeAgents) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *RustdeskMutation) RemovedIDs(name string) []ent.Value { +func (m *ReleaseMutation) RemovedIDs(name string) []ent.Value { switch name { - case rustdesk.EdgeTenant: - ids := make([]ent.Value, 0, len(m.removedtenant)) - for id := range m.removedtenant { + case release.EdgeAgents: + ids := make([]ent.Value, 0, len(m.removedagents)) + for id := range m.removedagents { ids = append(ids, id) } return ids @@ -21871,80 +22410,71 @@ func (m *RustdeskMutation) RemovedIDs(name string) []ent.Value { } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RustdeskMutation) ClearedEdges() []string { +func (m *ReleaseMutation) ClearedEdges() []string { edges := make([]string, 0, 1) - if m.clearedtenant { - edges = append(edges, rustdesk.EdgeTenant) + if m.clearedagents { + edges = append(edges, release.EdgeAgents) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *RustdeskMutation) EdgeCleared(name string) bool { +func (m *ReleaseMutation) EdgeCleared(name string) bool { switch name { - case rustdesk.EdgeTenant: - return m.clearedtenant + case release.EdgeAgents: + return m.clearedagents } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *RustdeskMutation) ClearEdge(name string) error { +func (m *ReleaseMutation) ClearEdge(name string) error { switch name { } - return fmt.Errorf("unknown Rustdesk unique edge %s", name) + return fmt.Errorf("unknown Release unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *RustdeskMutation) ResetEdge(name string) error { +func (m *ReleaseMutation) ResetEdge(name string) error { switch name { - case rustdesk.EdgeTenant: - m.ResetTenant() + case release.EdgeAgents: + m.ResetAgents() return nil } - return fmt.Errorf("unknown Rustdesk edge %s", name) + return fmt.Errorf("unknown Release edge %s", name) } -// ServerMutation represents an operation that mutates the Server nodes in the graph. -type ServerMutation struct { +// RevocationMutation represents an operation that mutates the Revocation nodes in the graph. +type RevocationMutation struct { config - op Op - typ string - id *int - hostname *string - arch *string - os *string - version *string - channel *server.Channel - update_status *server.UpdateStatus - update_message *string - update_when *time.Time - nats_component *bool - ocsp_component *bool - console_component *bool - agent_worker_component *bool - notification_worker_component *bool - cert_manager_worker_component *bool - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*Server, error) - predicates []predicate.Server + op Op + typ string + id *int64 + reason *int + addreason *int + info *string + expiry *time.Time + revoked *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Revocation, error) + predicates []predicate.Revocation } -var _ ent.Mutation = (*ServerMutation)(nil) +var _ ent.Mutation = (*RevocationMutation)(nil) -// serverOption allows management of the mutation configuration using functional options. -type serverOption func(*ServerMutation) +// revocationOption allows management of the mutation configuration using functional options. +type revocationOption func(*RevocationMutation) -// newServerMutation creates new mutation for the Server entity. -func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation { - m := &ServerMutation{ +// newRevocationMutation creates new mutation for the Revocation entity. +func newRevocationMutation(c config, op Op, opts ...revocationOption) *RevocationMutation { + m := &RevocationMutation{ config: c, op: op, - typ: TypeServer, + typ: TypeRevocation, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -21953,20 +22483,20 @@ func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation { return m } -// withServerID sets the ID field of the mutation. -func withServerID(id int) serverOption { - return func(m *ServerMutation) { +// withRevocationID sets the ID field of the mutation. +func withRevocationID(id int64) revocationOption { + return func(m *RevocationMutation) { var ( err error once sync.Once - value *Server + value *Revocation ) - m.oldValue = func(ctx context.Context) (*Server, error) { + m.oldValue = func(ctx context.Context) (*Revocation, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Server.Get(ctx, id) + value, err = m.Client().Revocation.Get(ctx, id) } }) return value, err @@ -21975,10 +22505,10 @@ func withServerID(id int) serverOption { } } -// withServer sets the old Server of the mutation. -func withServer(node *Server) serverOption { - return func(m *ServerMutation) { - m.oldValue = func(context.Context) (*Server, error) { +// withRevocation sets the old Revocation of the mutation. +func withRevocation(node *Revocation) revocationOption { + return func(m *RevocationMutation) { + m.oldValue = func(context.Context) (*Revocation, error) { return node, nil } m.id = &node.ID @@ -21987,7 +22517,7 @@ func withServer(node *Server) serverOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ServerMutation) Client() *Client { +func (m RevocationMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -21995,7 +22525,7 @@ func (m ServerMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ServerMutation) Tx() (*Tx, error) { +func (m RevocationMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -22004,9 +22534,15 @@ func (m ServerMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Revocation entities. +func (m *RevocationMutation) SetID(id int64) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ServerMutation) ID() (id int, exists bool) { +func (m *RevocationMutation) ID() (id int64, exists bool) { if m.id == nil { return } @@ -22017,1126 +22553,1590 @@ func (m *ServerMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ServerMutation) IDs(ctx context.Context) ([]int, error) { +func (m *RevocationMutation) IDs(ctx context.Context) ([]int64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []int64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Server.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Revocation.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetHostname sets the "hostname" field. -func (m *ServerMutation) SetHostname(s string) { - m.hostname = &s +// SetReason sets the "reason" field. +func (m *RevocationMutation) SetReason(i int) { + m.reason = &i + m.addreason = nil } -// Hostname returns the value of the "hostname" field in the mutation. -func (m *ServerMutation) Hostname() (r string, exists bool) { - v := m.hostname +// Reason returns the value of the "reason" field in the mutation. +func (m *RevocationMutation) Reason() (r int, exists bool) { + v := m.reason if v == nil { return } return *v, true } -// OldHostname returns the old "hostname" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// OldReason returns the old "reason" field's value of the Revocation entity. +// If the Revocation object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldHostname(ctx context.Context) (v string, err error) { +func (m *RevocationMutation) OldReason(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHostname is only allowed on UpdateOne operations") + return v, errors.New("OldReason is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHostname requires an ID field in the mutation") + return v, errors.New("OldReason requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHostname: %w", err) + return v, fmt.Errorf("querying old value for OldReason: %w", err) } - return oldValue.Hostname, nil -} - -// ResetHostname resets all changes to the "hostname" field. -func (m *ServerMutation) ResetHostname() { - m.hostname = nil + return oldValue.Reason, nil } -// SetArch sets the "arch" field. -func (m *ServerMutation) SetArch(s string) { - m.arch = &s +// AddReason adds i to the "reason" field. +func (m *RevocationMutation) AddReason(i int) { + if m.addreason != nil { + *m.addreason += i + } else { + m.addreason = &i + } } -// Arch returns the value of the "arch" field in the mutation. -func (m *ServerMutation) Arch() (r string, exists bool) { - v := m.arch +// AddedReason returns the value that was added to the "reason" field in this mutation. +func (m *RevocationMutation) AddedReason() (r int, exists bool) { + v := m.addreason if v == nil { return } return *v, true } -// OldArch returns the old "arch" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldArch(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldArch is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldArch requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldArch: %w", err) - } - return oldValue.Arch, nil +// ClearReason clears the value of the "reason" field. +func (m *RevocationMutation) ClearReason() { + m.reason = nil + m.addreason = nil + m.clearedFields[revocation.FieldReason] = struct{}{} } -// ResetArch resets all changes to the "arch" field. -func (m *ServerMutation) ResetArch() { - m.arch = nil +// ReasonCleared returns if the "reason" field was cleared in this mutation. +func (m *RevocationMutation) ReasonCleared() bool { + _, ok := m.clearedFields[revocation.FieldReason] + return ok } -// SetOs sets the "os" field. -func (m *ServerMutation) SetOs(s string) { - m.os = &s +// ResetReason resets all changes to the "reason" field. +func (m *RevocationMutation) ResetReason() { + m.reason = nil + m.addreason = nil + delete(m.clearedFields, revocation.FieldReason) } -// Os returns the value of the "os" field in the mutation. -func (m *ServerMutation) Os() (r string, exists bool) { - v := m.os +// SetInfo sets the "info" field. +func (m *RevocationMutation) SetInfo(s string) { + m.info = &s +} + +// Info returns the value of the "info" field in the mutation. +func (m *RevocationMutation) Info() (r string, exists bool) { + v := m.info if v == nil { return } return *v, true } -// OldOs returns the old "os" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// OldInfo returns the old "info" field's value of the Revocation entity. +// If the Revocation object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldOs(ctx context.Context) (v string, err error) { +func (m *RevocationMutation) OldInfo(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOs is only allowed on UpdateOne operations") + return v, errors.New("OldInfo is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOs requires an ID field in the mutation") + return v, errors.New("OldInfo requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOs: %w", err) + return v, fmt.Errorf("querying old value for OldInfo: %w", err) } - return oldValue.Os, nil + return oldValue.Info, nil } -// ResetOs resets all changes to the "os" field. -func (m *ServerMutation) ResetOs() { - m.os = nil +// ClearInfo clears the value of the "info" field. +func (m *RevocationMutation) ClearInfo() { + m.info = nil + m.clearedFields[revocation.FieldInfo] = struct{}{} } -// SetVersion sets the "version" field. -func (m *ServerMutation) SetVersion(s string) { - m.version = &s +// InfoCleared returns if the "info" field was cleared in this mutation. +func (m *RevocationMutation) InfoCleared() bool { + _, ok := m.clearedFields[revocation.FieldInfo] + return ok } -// Version returns the value of the "version" field in the mutation. -func (m *ServerMutation) Version() (r string, exists bool) { - v := m.version +// ResetInfo resets all changes to the "info" field. +func (m *RevocationMutation) ResetInfo() { + m.info = nil + delete(m.clearedFields, revocation.FieldInfo) +} + +// SetExpiry sets the "expiry" field. +func (m *RevocationMutation) SetExpiry(t time.Time) { + m.expiry = &t +} + +// Expiry returns the value of the "expiry" field in the mutation. +func (m *RevocationMutation) Expiry() (r time.Time, exists bool) { + v := m.expiry if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// OldExpiry returns the old "expiry" field's value of the Revocation entity. +// If the Revocation object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldVersion(ctx context.Context) (v string, err error) { +func (m *RevocationMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldExpiry is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldExpiry requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) + return v, fmt.Errorf("querying old value for OldExpiry: %w", err) } - return oldValue.Version, nil + return oldValue.Expiry, nil } -// ResetVersion resets all changes to the "version" field. -func (m *ServerMutation) ResetVersion() { - m.version = nil +// ClearExpiry clears the value of the "expiry" field. +func (m *RevocationMutation) ClearExpiry() { + m.expiry = nil + m.clearedFields[revocation.FieldExpiry] = struct{}{} } -// SetChannel sets the "channel" field. -func (m *ServerMutation) SetChannel(s server.Channel) { - m.channel = &s +// ExpiryCleared returns if the "expiry" field was cleared in this mutation. +func (m *RevocationMutation) ExpiryCleared() bool { + _, ok := m.clearedFields[revocation.FieldExpiry] + return ok } -// Channel returns the value of the "channel" field in the mutation. -func (m *ServerMutation) Channel() (r server.Channel, exists bool) { - v := m.channel - if v == nil { - return - } - return *v, true -} - -// OldChannel returns the old "channel" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldChannel(ctx context.Context) (v server.Channel, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChannel is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChannel requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldChannel: %w", err) - } - return oldValue.Channel, nil -} - -// ResetChannel resets all changes to the "channel" field. -func (m *ServerMutation) ResetChannel() { - m.channel = nil +// ResetExpiry resets all changes to the "expiry" field. +func (m *RevocationMutation) ResetExpiry() { + m.expiry = nil + delete(m.clearedFields, revocation.FieldExpiry) } -// SetUpdateStatus sets the "update_status" field. -func (m *ServerMutation) SetUpdateStatus(ss server.UpdateStatus) { - m.update_status = &ss +// SetRevoked sets the "revoked" field. +func (m *RevocationMutation) SetRevoked(t time.Time) { + m.revoked = &t } -// UpdateStatus returns the value of the "update_status" field in the mutation. -func (m *ServerMutation) UpdateStatus() (r server.UpdateStatus, exists bool) { - v := m.update_status +// Revoked returns the value of the "revoked" field in the mutation. +func (m *RevocationMutation) Revoked() (r time.Time, exists bool) { + v := m.revoked if v == nil { return } return *v, true } -// OldUpdateStatus returns the old "update_status" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// OldRevoked returns the old "revoked" field's value of the Revocation entity. +// If the Revocation object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldUpdateStatus(ctx context.Context) (v server.UpdateStatus, err error) { +func (m *RevocationMutation) OldRevoked(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateStatus is only allowed on UpdateOne operations") + return v, errors.New("OldRevoked is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateStatus requires an ID field in the mutation") + return v, errors.New("OldRevoked requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateStatus: %w", err) + return v, fmt.Errorf("querying old value for OldRevoked: %w", err) } - return oldValue.UpdateStatus, nil -} - -// ClearUpdateStatus clears the value of the "update_status" field. -func (m *ServerMutation) ClearUpdateStatus() { - m.update_status = nil - m.clearedFields[server.FieldUpdateStatus] = struct{}{} -} - -// UpdateStatusCleared returns if the "update_status" field was cleared in this mutation. -func (m *ServerMutation) UpdateStatusCleared() bool { - _, ok := m.clearedFields[server.FieldUpdateStatus] - return ok -} - -// ResetUpdateStatus resets all changes to the "update_status" field. -func (m *ServerMutation) ResetUpdateStatus() { - m.update_status = nil - delete(m.clearedFields, server.FieldUpdateStatus) + return oldValue.Revoked, nil } -// SetUpdateMessage sets the "update_message" field. -func (m *ServerMutation) SetUpdateMessage(s string) { - m.update_message = &s +// ResetRevoked resets all changes to the "revoked" field. +func (m *RevocationMutation) ResetRevoked() { + m.revoked = nil } -// UpdateMessage returns the value of the "update_message" field in the mutation. -func (m *ServerMutation) UpdateMessage() (r string, exists bool) { - v := m.update_message - if v == nil { - return - } - return *v, true +// Where appends a list predicates to the RevocationMutation builder. +func (m *RevocationMutation) Where(ps ...predicate.Revocation) { + m.predicates = append(m.predicates, ps...) } -// OldUpdateMessage returns the old "update_message" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldUpdateMessage(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateMessage is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateMessage requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateMessage: %w", err) +// WhereP appends storage-level predicates to the RevocationMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RevocationMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Revocation, len(ps)) + for i := range ps { + p[i] = ps[i] } - return oldValue.UpdateMessage, nil -} - -// ClearUpdateMessage clears the value of the "update_message" field. -func (m *ServerMutation) ClearUpdateMessage() { - m.update_message = nil - m.clearedFields[server.FieldUpdateMessage] = struct{}{} + m.Where(p...) } -// UpdateMessageCleared returns if the "update_message" field was cleared in this mutation. -func (m *ServerMutation) UpdateMessageCleared() bool { - _, ok := m.clearedFields[server.FieldUpdateMessage] - return ok +// Op returns the operation name. +func (m *RevocationMutation) Op() Op { + return m.op } -// ResetUpdateMessage resets all changes to the "update_message" field. -func (m *ServerMutation) ResetUpdateMessage() { - m.update_message = nil - delete(m.clearedFields, server.FieldUpdateMessage) +// SetOp allows setting the mutation operation. +func (m *RevocationMutation) SetOp(op Op) { + m.op = op } -// SetUpdateWhen sets the "update_when" field. -func (m *ServerMutation) SetUpdateWhen(t time.Time) { - m.update_when = &t +// Type returns the node type of this mutation (Revocation). +func (m *RevocationMutation) Type() string { + return m.typ } -// UpdateWhen returns the value of the "update_when" field in the mutation. -func (m *ServerMutation) UpdateWhen() (r time.Time, exists bool) { - v := m.update_when - if v == nil { - return +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *RevocationMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.reason != nil { + fields = append(fields, revocation.FieldReason) } - return *v, true -} - -// OldUpdateWhen returns the old "update_when" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldUpdateWhen(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateWhen is only allowed on UpdateOne operations") + if m.info != nil { + fields = append(fields, revocation.FieldInfo) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateWhen requires an ID field in the mutation") + if m.expiry != nil { + fields = append(fields, revocation.FieldExpiry) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateWhen: %w", err) + if m.revoked != nil { + fields = append(fields, revocation.FieldRevoked) } - return oldValue.UpdateWhen, nil + return fields } -// ClearUpdateWhen clears the value of the "update_when" field. -func (m *ServerMutation) ClearUpdateWhen() { - m.update_when = nil - m.clearedFields[server.FieldUpdateWhen] = struct{}{} +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *RevocationMutation) Field(name string) (ent.Value, bool) { + switch name { + case revocation.FieldReason: + return m.Reason() + case revocation.FieldInfo: + return m.Info() + case revocation.FieldExpiry: + return m.Expiry() + case revocation.FieldRevoked: + return m.Revoked() + } + return nil, false } -// UpdateWhenCleared returns if the "update_when" field was cleared in this mutation. -func (m *ServerMutation) UpdateWhenCleared() bool { - _, ok := m.clearedFields[server.FieldUpdateWhen] - return ok +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *RevocationMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case revocation.FieldReason: + return m.OldReason(ctx) + case revocation.FieldInfo: + return m.OldInfo(ctx) + case revocation.FieldExpiry: + return m.OldExpiry(ctx) + case revocation.FieldRevoked: + return m.OldRevoked(ctx) + } + return nil, fmt.Errorf("unknown Revocation field %s", name) } -// ResetUpdateWhen resets all changes to the "update_when" field. -func (m *ServerMutation) ResetUpdateWhen() { - m.update_when = nil - delete(m.clearedFields, server.FieldUpdateWhen) +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RevocationMutation) SetField(name string, value ent.Value) error { + switch name { + case revocation.FieldReason: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetReason(v) + return nil + case revocation.FieldInfo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetInfo(v) + return nil + case revocation.FieldExpiry: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExpiry(v) + return nil + case revocation.FieldRevoked: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRevoked(v) + return nil + } + return fmt.Errorf("unknown Revocation field %s", name) } -// SetNatsComponent sets the "nats_component" field. -func (m *ServerMutation) SetNatsComponent(b bool) { - m.nats_component = &b +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *RevocationMutation) AddedFields() []string { + var fields []string + if m.addreason != nil { + fields = append(fields, revocation.FieldReason) + } + return fields } -// NatsComponent returns the value of the "nats_component" field in the mutation. -func (m *ServerMutation) NatsComponent() (r bool, exists bool) { - v := m.nats_component - if v == nil { - return +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *RevocationMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case revocation.FieldReason: + return m.AddedReason() } - return *v, true + return nil, false } -// OldNatsComponent returns the old "nats_component" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldNatsComponent(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNatsComponent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNatsComponent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldNatsComponent: %w", err) +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RevocationMutation) AddField(name string, value ent.Value) error { + switch name { + case revocation.FieldReason: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddReason(v) + return nil } - return oldValue.NatsComponent, nil + return fmt.Errorf("unknown Revocation numeric field %s", name) } -// ClearNatsComponent clears the value of the "nats_component" field. -func (m *ServerMutation) ClearNatsComponent() { - m.nats_component = nil - m.clearedFields[server.FieldNatsComponent] = struct{}{} +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *RevocationMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(revocation.FieldReason) { + fields = append(fields, revocation.FieldReason) + } + if m.FieldCleared(revocation.FieldInfo) { + fields = append(fields, revocation.FieldInfo) + } + if m.FieldCleared(revocation.FieldExpiry) { + fields = append(fields, revocation.FieldExpiry) + } + return fields } -// NatsComponentCleared returns if the "nats_component" field was cleared in this mutation. -func (m *ServerMutation) NatsComponentCleared() bool { - _, ok := m.clearedFields[server.FieldNatsComponent] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *RevocationMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetNatsComponent resets all changes to the "nats_component" field. -func (m *ServerMutation) ResetNatsComponent() { - m.nats_component = nil - delete(m.clearedFields, server.FieldNatsComponent) -} - -// SetOcspComponent sets the "ocsp_component" field. -func (m *ServerMutation) SetOcspComponent(b bool) { - m.ocsp_component = &b -} - -// OcspComponent returns the value of the "ocsp_component" field in the mutation. -func (m *ServerMutation) OcspComponent() (r bool, exists bool) { - v := m.ocsp_component - if v == nil { - return +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *RevocationMutation) ClearField(name string) error { + switch name { + case revocation.FieldReason: + m.ClearReason() + return nil + case revocation.FieldInfo: + m.ClearInfo() + return nil + case revocation.FieldExpiry: + m.ClearExpiry() + return nil } - return *v, true + return fmt.Errorf("unknown Revocation nullable field %s", name) } -// OldOcspComponent returns the old "ocsp_component" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldOcspComponent(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOcspComponent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOcspComponent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldOcspComponent: %w", err) +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *RevocationMutation) ResetField(name string) error { + switch name { + case revocation.FieldReason: + m.ResetReason() + return nil + case revocation.FieldInfo: + m.ResetInfo() + return nil + case revocation.FieldExpiry: + m.ResetExpiry() + return nil + case revocation.FieldRevoked: + m.ResetRevoked() + return nil } - return oldValue.OcspComponent, nil + return fmt.Errorf("unknown Revocation field %s", name) } -// ClearOcspComponent clears the value of the "ocsp_component" field. -func (m *ServerMutation) ClearOcspComponent() { - m.ocsp_component = nil - m.clearedFields[server.FieldOcspComponent] = struct{}{} +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *RevocationMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges } -// OcspComponentCleared returns if the "ocsp_component" field was cleared in this mutation. -func (m *ServerMutation) OcspComponentCleared() bool { - _, ok := m.clearedFields[server.FieldOcspComponent] - return ok +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *RevocationMutation) AddedIDs(name string) []ent.Value { + return nil } -// ResetOcspComponent resets all changes to the "ocsp_component" field. -func (m *ServerMutation) ResetOcspComponent() { - m.ocsp_component = nil - delete(m.clearedFields, server.FieldOcspComponent) +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *RevocationMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges } -// SetConsoleComponent sets the "console_component" field. -func (m *ServerMutation) SetConsoleComponent(b bool) { - m.console_component = &b +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *RevocationMutation) RemovedIDs(name string) []ent.Value { + return nil } -// ConsoleComponent returns the value of the "console_component" field in the mutation. -func (m *ServerMutation) ConsoleComponent() (r bool, exists bool) { - v := m.console_component - if v == nil { - return - } - return *v, true +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RevocationMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges } -// OldConsoleComponent returns the old "console_component" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldConsoleComponent(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldConsoleComponent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldConsoleComponent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldConsoleComponent: %w", err) - } - return oldValue.ConsoleComponent, nil +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *RevocationMutation) EdgeCleared(name string) bool { + return false } -// ClearConsoleComponent clears the value of the "console_component" field. -func (m *ServerMutation) ClearConsoleComponent() { - m.console_component = nil - m.clearedFields[server.FieldConsoleComponent] = struct{}{} +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *RevocationMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Revocation unique edge %s", name) } -// ConsoleComponentCleared returns if the "console_component" field was cleared in this mutation. -func (m *ServerMutation) ConsoleComponentCleared() bool { - _, ok := m.clearedFields[server.FieldConsoleComponent] - return ok +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *RevocationMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Revocation edge %s", name) } -// ResetConsoleComponent resets all changes to the "console_component" field. -func (m *ServerMutation) ResetConsoleComponent() { - m.console_component = nil - delete(m.clearedFields, server.FieldConsoleComponent) +// RustdeskMutation represents an operation that mutates the Rustdesk nodes in the graph. +type RustdeskMutation struct { + config + op Op + typ string + id *int + custom_rendezvous_server *string + relay_server *string + api_server *string + key *string + use_permanent_password *bool + whitelist *string + direct_ip_access *bool + verification_method *rustdesk.VerificationMethod + temporary_password_length *int + addtemporary_password_length *int + clearedFields map[string]struct{} + tenant map[int]struct{} + removedtenant map[int]struct{} + clearedtenant bool + done bool + oldValue func(context.Context) (*Rustdesk, error) + predicates []predicate.Rustdesk } -// SetAgentWorkerComponent sets the "agent_worker_component" field. -func (m *ServerMutation) SetAgentWorkerComponent(b bool) { - m.agent_worker_component = &b -} +var _ ent.Mutation = (*RustdeskMutation)(nil) -// AgentWorkerComponent returns the value of the "agent_worker_component" field in the mutation. -func (m *ServerMutation) AgentWorkerComponent() (r bool, exists bool) { - v := m.agent_worker_component - if v == nil { - return +// rustdeskOption allows management of the mutation configuration using functional options. +type rustdeskOption func(*RustdeskMutation) + +// newRustdeskMutation creates new mutation for the Rustdesk entity. +func newRustdeskMutation(c config, op Op, opts ...rustdeskOption) *RustdeskMutation { + m := &RustdeskMutation{ + config: c, + op: op, + typ: TypeRustdesk, + clearedFields: make(map[string]struct{}), } - return *v, true + for _, opt := range opts { + opt(m) + } + return m } -// OldAgentWorkerComponent returns the old "agent_worker_component" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// withRustdeskID sets the ID field of the mutation. +func withRustdeskID(id int) rustdeskOption { + return func(m *RustdeskMutation) { + var ( + err error + once sync.Once + value *Rustdesk + ) + m.oldValue = func(ctx context.Context) (*Rustdesk, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Rustdesk.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withRustdesk sets the old Rustdesk of the mutation. +func withRustdesk(node *Rustdesk) rustdeskOption { + return func(m *RustdeskMutation) { + m.oldValue = func(context.Context) (*Rustdesk, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m RustdeskMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m RustdeskMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *RustdeskMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *RustdeskMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Rustdesk.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCustomRendezvousServer sets the "custom_rendezvous_server" field. +func (m *RustdeskMutation) SetCustomRendezvousServer(s string) { + m.custom_rendezvous_server = &s +} + +// CustomRendezvousServer returns the value of the "custom_rendezvous_server" field in the mutation. +func (m *RustdeskMutation) CustomRendezvousServer() (r string, exists bool) { + v := m.custom_rendezvous_server + if v == nil { + return + } + return *v, true +} + +// OldCustomRendezvousServer returns the old "custom_rendezvous_server" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldAgentWorkerComponent(ctx context.Context) (v bool, err error) { +func (m *RustdeskMutation) OldCustomRendezvousServer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAgentWorkerComponent is only allowed on UpdateOne operations") + return v, errors.New("OldCustomRendezvousServer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAgentWorkerComponent requires an ID field in the mutation") + return v, errors.New("OldCustomRendezvousServer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAgentWorkerComponent: %w", err) + return v, fmt.Errorf("querying old value for OldCustomRendezvousServer: %w", err) } - return oldValue.AgentWorkerComponent, nil + return oldValue.CustomRendezvousServer, nil } -// ClearAgentWorkerComponent clears the value of the "agent_worker_component" field. -func (m *ServerMutation) ClearAgentWorkerComponent() { - m.agent_worker_component = nil - m.clearedFields[server.FieldAgentWorkerComponent] = struct{}{} +// ClearCustomRendezvousServer clears the value of the "custom_rendezvous_server" field. +func (m *RustdeskMutation) ClearCustomRendezvousServer() { + m.custom_rendezvous_server = nil + m.clearedFields[rustdesk.FieldCustomRendezvousServer] = struct{}{} } -// AgentWorkerComponentCleared returns if the "agent_worker_component" field was cleared in this mutation. -func (m *ServerMutation) AgentWorkerComponentCleared() bool { - _, ok := m.clearedFields[server.FieldAgentWorkerComponent] +// CustomRendezvousServerCleared returns if the "custom_rendezvous_server" field was cleared in this mutation. +func (m *RustdeskMutation) CustomRendezvousServerCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldCustomRendezvousServer] return ok } -// ResetAgentWorkerComponent resets all changes to the "agent_worker_component" field. -func (m *ServerMutation) ResetAgentWorkerComponent() { - m.agent_worker_component = nil - delete(m.clearedFields, server.FieldAgentWorkerComponent) +// ResetCustomRendezvousServer resets all changes to the "custom_rendezvous_server" field. +func (m *RustdeskMutation) ResetCustomRendezvousServer() { + m.custom_rendezvous_server = nil + delete(m.clearedFields, rustdesk.FieldCustomRendezvousServer) } -// SetNotificationWorkerComponent sets the "notification_worker_component" field. -func (m *ServerMutation) SetNotificationWorkerComponent(b bool) { - m.notification_worker_component = &b +// SetRelayServer sets the "relay_server" field. +func (m *RustdeskMutation) SetRelayServer(s string) { + m.relay_server = &s } -// NotificationWorkerComponent returns the value of the "notification_worker_component" field in the mutation. -func (m *ServerMutation) NotificationWorkerComponent() (r bool, exists bool) { - v := m.notification_worker_component +// RelayServer returns the value of the "relay_server" field in the mutation. +func (m *RustdeskMutation) RelayServer() (r string, exists bool) { + v := m.relay_server if v == nil { return } return *v, true } -// OldNotificationWorkerComponent returns the old "notification_worker_component" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// OldRelayServer returns the old "relay_server" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldNotificationWorkerComponent(ctx context.Context) (v bool, err error) { +func (m *RustdeskMutation) OldRelayServer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNotificationWorkerComponent is only allowed on UpdateOne operations") + return v, errors.New("OldRelayServer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNotificationWorkerComponent requires an ID field in the mutation") + return v, errors.New("OldRelayServer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNotificationWorkerComponent: %w", err) + return v, fmt.Errorf("querying old value for OldRelayServer: %w", err) } - return oldValue.NotificationWorkerComponent, nil + return oldValue.RelayServer, nil } -// ClearNotificationWorkerComponent clears the value of the "notification_worker_component" field. -func (m *ServerMutation) ClearNotificationWorkerComponent() { - m.notification_worker_component = nil - m.clearedFields[server.FieldNotificationWorkerComponent] = struct{}{} +// ClearRelayServer clears the value of the "relay_server" field. +func (m *RustdeskMutation) ClearRelayServer() { + m.relay_server = nil + m.clearedFields[rustdesk.FieldRelayServer] = struct{}{} } -// NotificationWorkerComponentCleared returns if the "notification_worker_component" field was cleared in this mutation. -func (m *ServerMutation) NotificationWorkerComponentCleared() bool { - _, ok := m.clearedFields[server.FieldNotificationWorkerComponent] +// RelayServerCleared returns if the "relay_server" field was cleared in this mutation. +func (m *RustdeskMutation) RelayServerCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldRelayServer] return ok } -// ResetNotificationWorkerComponent resets all changes to the "notification_worker_component" field. -func (m *ServerMutation) ResetNotificationWorkerComponent() { - m.notification_worker_component = nil - delete(m.clearedFields, server.FieldNotificationWorkerComponent) +// ResetRelayServer resets all changes to the "relay_server" field. +func (m *RustdeskMutation) ResetRelayServer() { + m.relay_server = nil + delete(m.clearedFields, rustdesk.FieldRelayServer) } -// SetCertManagerWorkerComponent sets the "cert_manager_worker_component" field. -func (m *ServerMutation) SetCertManagerWorkerComponent(b bool) { - m.cert_manager_worker_component = &b +// SetAPIServer sets the "api_server" field. +func (m *RustdeskMutation) SetAPIServer(s string) { + m.api_server = &s } -// CertManagerWorkerComponent returns the value of the "cert_manager_worker_component" field in the mutation. -func (m *ServerMutation) CertManagerWorkerComponent() (r bool, exists bool) { - v := m.cert_manager_worker_component +// APIServer returns the value of the "api_server" field in the mutation. +func (m *RustdeskMutation) APIServer() (r string, exists bool) { + v := m.api_server if v == nil { return } return *v, true } -// OldCertManagerWorkerComponent returns the old "cert_manager_worker_component" field's value of the Server entity. -// If the Server object wasn't provided to the builder, the object is fetched from the database. +// OldAPIServer returns the old "api_server" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ServerMutation) OldCertManagerWorkerComponent(ctx context.Context) (v bool, err error) { +func (m *RustdeskMutation) OldAPIServer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCertManagerWorkerComponent is only allowed on UpdateOne operations") + return v, errors.New("OldAPIServer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCertManagerWorkerComponent requires an ID field in the mutation") + return v, errors.New("OldAPIServer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCertManagerWorkerComponent: %w", err) + return v, fmt.Errorf("querying old value for OldAPIServer: %w", err) } - return oldValue.CertManagerWorkerComponent, nil + return oldValue.APIServer, nil } -// ClearCertManagerWorkerComponent clears the value of the "cert_manager_worker_component" field. -func (m *ServerMutation) ClearCertManagerWorkerComponent() { - m.cert_manager_worker_component = nil - m.clearedFields[server.FieldCertManagerWorkerComponent] = struct{}{} +// ClearAPIServer clears the value of the "api_server" field. +func (m *RustdeskMutation) ClearAPIServer() { + m.api_server = nil + m.clearedFields[rustdesk.FieldAPIServer] = struct{}{} } -// CertManagerWorkerComponentCleared returns if the "cert_manager_worker_component" field was cleared in this mutation. -func (m *ServerMutation) CertManagerWorkerComponentCleared() bool { - _, ok := m.clearedFields[server.FieldCertManagerWorkerComponent] +// APIServerCleared returns if the "api_server" field was cleared in this mutation. +func (m *RustdeskMutation) APIServerCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldAPIServer] return ok } -// ResetCertManagerWorkerComponent resets all changes to the "cert_manager_worker_component" field. -func (m *ServerMutation) ResetCertManagerWorkerComponent() { - m.cert_manager_worker_component = nil - delete(m.clearedFields, server.FieldCertManagerWorkerComponent) +// ResetAPIServer resets all changes to the "api_server" field. +func (m *RustdeskMutation) ResetAPIServer() { + m.api_server = nil + delete(m.clearedFields, rustdesk.FieldAPIServer) } -// Where appends a list predicates to the ServerMutation builder. -func (m *ServerMutation) Where(ps ...predicate.Server) { - m.predicates = append(m.predicates, ps...) +// SetKey sets the "key" field. +func (m *RustdeskMutation) SetKey(s string) { + m.key = &s } -// WhereP appends storage-level predicates to the ServerMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Server, len(ps)) - for i := range ps { - p[i] = ps[i] +// Key returns the value of the "key" field in the mutation. +func (m *RustdeskMutation) Key() (r string, exists bool) { + v := m.key + if v == nil { + return } - m.Where(p...) + return *v, true } -// Op returns the operation name. -func (m *ServerMutation) Op() Op { - return m.op +// OldKey returns the old "key" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RustdeskMutation) OldKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKey: %w", err) + } + return oldValue.Key, nil } -// SetOp allows setting the mutation operation. -func (m *ServerMutation) SetOp(op Op) { - m.op = op +// ClearKey clears the value of the "key" field. +func (m *RustdeskMutation) ClearKey() { + m.key = nil + m.clearedFields[rustdesk.FieldKey] = struct{}{} } -// Type returns the node type of this mutation (Server). -func (m *ServerMutation) Type() string { - return m.typ +// KeyCleared returns if the "key" field was cleared in this mutation. +func (m *RustdeskMutation) KeyCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldKey] + return ok } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *ServerMutation) Fields() []string { - fields := make([]string, 0, 14) - if m.hostname != nil { - fields = append(fields, server.FieldHostname) - } - if m.arch != nil { - fields = append(fields, server.FieldArch) - } - if m.os != nil { - fields = append(fields, server.FieldOs) +// ResetKey resets all changes to the "key" field. +func (m *RustdeskMutation) ResetKey() { + m.key = nil + delete(m.clearedFields, rustdesk.FieldKey) +} + +// SetUsePermanentPassword sets the "use_permanent_password" field. +func (m *RustdeskMutation) SetUsePermanentPassword(b bool) { + m.use_permanent_password = &b +} + +// UsePermanentPassword returns the value of the "use_permanent_password" field in the mutation. +func (m *RustdeskMutation) UsePermanentPassword() (r bool, exists bool) { + v := m.use_permanent_password + if v == nil { + return } - if m.version != nil { - fields = append(fields, server.FieldVersion) + return *v, true +} + +// OldUsePermanentPassword returns the old "use_permanent_password" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RustdeskMutation) OldUsePermanentPassword(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsePermanentPassword is only allowed on UpdateOne operations") } - if m.channel != nil { - fields = append(fields, server.FieldChannel) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsePermanentPassword requires an ID field in the mutation") } - if m.update_status != nil { - fields = append(fields, server.FieldUpdateStatus) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsePermanentPassword: %w", err) } - if m.update_message != nil { - fields = append(fields, server.FieldUpdateMessage) + return oldValue.UsePermanentPassword, nil +} + +// ClearUsePermanentPassword clears the value of the "use_permanent_password" field. +func (m *RustdeskMutation) ClearUsePermanentPassword() { + m.use_permanent_password = nil + m.clearedFields[rustdesk.FieldUsePermanentPassword] = struct{}{} +} + +// UsePermanentPasswordCleared returns if the "use_permanent_password" field was cleared in this mutation. +func (m *RustdeskMutation) UsePermanentPasswordCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldUsePermanentPassword] + return ok +} + +// ResetUsePermanentPassword resets all changes to the "use_permanent_password" field. +func (m *RustdeskMutation) ResetUsePermanentPassword() { + m.use_permanent_password = nil + delete(m.clearedFields, rustdesk.FieldUsePermanentPassword) +} + +// SetWhitelist sets the "whitelist" field. +func (m *RustdeskMutation) SetWhitelist(s string) { + m.whitelist = &s +} + +// Whitelist returns the value of the "whitelist" field in the mutation. +func (m *RustdeskMutation) Whitelist() (r string, exists bool) { + v := m.whitelist + if v == nil { + return } - if m.update_when != nil { - fields = append(fields, server.FieldUpdateWhen) + return *v, true +} + +// OldWhitelist returns the old "whitelist" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RustdeskMutation) OldWhitelist(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWhitelist is only allowed on UpdateOne operations") } - if m.nats_component != nil { - fields = append(fields, server.FieldNatsComponent) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWhitelist requires an ID field in the mutation") } - if m.ocsp_component != nil { - fields = append(fields, server.FieldOcspComponent) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWhitelist: %w", err) } - if m.console_component != nil { - fields = append(fields, server.FieldConsoleComponent) + return oldValue.Whitelist, nil +} + +// ClearWhitelist clears the value of the "whitelist" field. +func (m *RustdeskMutation) ClearWhitelist() { + m.whitelist = nil + m.clearedFields[rustdesk.FieldWhitelist] = struct{}{} +} + +// WhitelistCleared returns if the "whitelist" field was cleared in this mutation. +func (m *RustdeskMutation) WhitelistCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldWhitelist] + return ok +} + +// ResetWhitelist resets all changes to the "whitelist" field. +func (m *RustdeskMutation) ResetWhitelist() { + m.whitelist = nil + delete(m.clearedFields, rustdesk.FieldWhitelist) +} + +// SetDirectIPAccess sets the "direct_ip_access" field. +func (m *RustdeskMutation) SetDirectIPAccess(b bool) { + m.direct_ip_access = &b +} + +// DirectIPAccess returns the value of the "direct_ip_access" field in the mutation. +func (m *RustdeskMutation) DirectIPAccess() (r bool, exists bool) { + v := m.direct_ip_access + if v == nil { + return } - if m.agent_worker_component != nil { - fields = append(fields, server.FieldAgentWorkerComponent) + return *v, true +} + +// OldDirectIPAccess returns the old "direct_ip_access" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RustdeskMutation) OldDirectIPAccess(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDirectIPAccess is only allowed on UpdateOne operations") } - if m.notification_worker_component != nil { - fields = append(fields, server.FieldNotificationWorkerComponent) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDirectIPAccess requires an ID field in the mutation") } - if m.cert_manager_worker_component != nil { - fields = append(fields, server.FieldCertManagerWorkerComponent) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDirectIPAccess: %w", err) } - return fields + return oldValue.DirectIPAccess, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *ServerMutation) Field(name string) (ent.Value, bool) { - switch name { - case server.FieldHostname: - return m.Hostname() - case server.FieldArch: - return m.Arch() - case server.FieldOs: - return m.Os() - case server.FieldVersion: - return m.Version() - case server.FieldChannel: - return m.Channel() - case server.FieldUpdateStatus: - return m.UpdateStatus() - case server.FieldUpdateMessage: - return m.UpdateMessage() - case server.FieldUpdateWhen: - return m.UpdateWhen() - case server.FieldNatsComponent: - return m.NatsComponent() - case server.FieldOcspComponent: - return m.OcspComponent() - case server.FieldConsoleComponent: - return m.ConsoleComponent() - case server.FieldAgentWorkerComponent: - return m.AgentWorkerComponent() - case server.FieldNotificationWorkerComponent: - return m.NotificationWorkerComponent() - case server.FieldCertManagerWorkerComponent: - return m.CertManagerWorkerComponent() - } - return nil, false +// ClearDirectIPAccess clears the value of the "direct_ip_access" field. +func (m *RustdeskMutation) ClearDirectIPAccess() { + m.direct_ip_access = nil + m.clearedFields[rustdesk.FieldDirectIPAccess] = struct{}{} } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case server.FieldHostname: - return m.OldHostname(ctx) - case server.FieldArch: - return m.OldArch(ctx) - case server.FieldOs: - return m.OldOs(ctx) - case server.FieldVersion: - return m.OldVersion(ctx) - case server.FieldChannel: - return m.OldChannel(ctx) - case server.FieldUpdateStatus: - return m.OldUpdateStatus(ctx) - case server.FieldUpdateMessage: - return m.OldUpdateMessage(ctx) - case server.FieldUpdateWhen: - return m.OldUpdateWhen(ctx) - case server.FieldNatsComponent: - return m.OldNatsComponent(ctx) - case server.FieldOcspComponent: - return m.OldOcspComponent(ctx) - case server.FieldConsoleComponent: - return m.OldConsoleComponent(ctx) - case server.FieldAgentWorkerComponent: - return m.OldAgentWorkerComponent(ctx) - case server.FieldNotificationWorkerComponent: - return m.OldNotificationWorkerComponent(ctx) - case server.FieldCertManagerWorkerComponent: - return m.OldCertManagerWorkerComponent(ctx) - } - return nil, fmt.Errorf("unknown Server field %s", name) +// DirectIPAccessCleared returns if the "direct_ip_access" field was cleared in this mutation. +func (m *RustdeskMutation) DirectIPAccessCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldDirectIPAccess] + return ok } -// SetField sets the value of a field with the given name. It returns an error if +// ResetDirectIPAccess resets all changes to the "direct_ip_access" field. +func (m *RustdeskMutation) ResetDirectIPAccess() { + m.direct_ip_access = nil + delete(m.clearedFields, rustdesk.FieldDirectIPAccess) +} + +// SetVerificationMethod sets the "verification_method" field. +func (m *RustdeskMutation) SetVerificationMethod(rm rustdesk.VerificationMethod) { + m.verification_method = &rm +} + +// VerificationMethod returns the value of the "verification_method" field in the mutation. +func (m *RustdeskMutation) VerificationMethod() (r rustdesk.VerificationMethod, exists bool) { + v := m.verification_method + if v == nil { + return + } + return *v, true +} + +// OldVerificationMethod returns the old "verification_method" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RustdeskMutation) OldVerificationMethod(ctx context.Context) (v rustdesk.VerificationMethod, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVerificationMethod is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVerificationMethod requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVerificationMethod: %w", err) + } + return oldValue.VerificationMethod, nil +} + +// ClearVerificationMethod clears the value of the "verification_method" field. +func (m *RustdeskMutation) ClearVerificationMethod() { + m.verification_method = nil + m.clearedFields[rustdesk.FieldVerificationMethod] = struct{}{} +} + +// VerificationMethodCleared returns if the "verification_method" field was cleared in this mutation. +func (m *RustdeskMutation) VerificationMethodCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldVerificationMethod] + return ok +} + +// ResetVerificationMethod resets all changes to the "verification_method" field. +func (m *RustdeskMutation) ResetVerificationMethod() { + m.verification_method = nil + delete(m.clearedFields, rustdesk.FieldVerificationMethod) +} + +// SetTemporaryPasswordLength sets the "temporary_password_length" field. +func (m *RustdeskMutation) SetTemporaryPasswordLength(i int) { + m.temporary_password_length = &i + m.addtemporary_password_length = nil +} + +// TemporaryPasswordLength returns the value of the "temporary_password_length" field in the mutation. +func (m *RustdeskMutation) TemporaryPasswordLength() (r int, exists bool) { + v := m.temporary_password_length + if v == nil { + return + } + return *v, true +} + +// OldTemporaryPasswordLength returns the old "temporary_password_length" field's value of the Rustdesk entity. +// If the Rustdesk object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RustdeskMutation) OldTemporaryPasswordLength(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTemporaryPasswordLength is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTemporaryPasswordLength requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTemporaryPasswordLength: %w", err) + } + return oldValue.TemporaryPasswordLength, nil +} + +// AddTemporaryPasswordLength adds i to the "temporary_password_length" field. +func (m *RustdeskMutation) AddTemporaryPasswordLength(i int) { + if m.addtemporary_password_length != nil { + *m.addtemporary_password_length += i + } else { + m.addtemporary_password_length = &i + } +} + +// AddedTemporaryPasswordLength returns the value that was added to the "temporary_password_length" field in this mutation. +func (m *RustdeskMutation) AddedTemporaryPasswordLength() (r int, exists bool) { + v := m.addtemporary_password_length + if v == nil { + return + } + return *v, true +} + +// ClearTemporaryPasswordLength clears the value of the "temporary_password_length" field. +func (m *RustdeskMutation) ClearTemporaryPasswordLength() { + m.temporary_password_length = nil + m.addtemporary_password_length = nil + m.clearedFields[rustdesk.FieldTemporaryPasswordLength] = struct{}{} +} + +// TemporaryPasswordLengthCleared returns if the "temporary_password_length" field was cleared in this mutation. +func (m *RustdeskMutation) TemporaryPasswordLengthCleared() bool { + _, ok := m.clearedFields[rustdesk.FieldTemporaryPasswordLength] + return ok +} + +// ResetTemporaryPasswordLength resets all changes to the "temporary_password_length" field. +func (m *RustdeskMutation) ResetTemporaryPasswordLength() { + m.temporary_password_length = nil + m.addtemporary_password_length = nil + delete(m.clearedFields, rustdesk.FieldTemporaryPasswordLength) +} + +// AddTenantIDs adds the "tenant" edge to the Tenant entity by ids. +func (m *RustdeskMutation) AddTenantIDs(ids ...int) { + if m.tenant == nil { + m.tenant = make(map[int]struct{}) + } + for i := range ids { + m.tenant[ids[i]] = struct{}{} + } +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *RustdeskMutation) ClearTenant() { + m.clearedtenant = true +} + +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *RustdeskMutation) TenantCleared() bool { + return m.clearedtenant +} + +// RemoveTenantIDs removes the "tenant" edge to the Tenant entity by IDs. +func (m *RustdeskMutation) RemoveTenantIDs(ids ...int) { + if m.removedtenant == nil { + m.removedtenant = make(map[int]struct{}) + } + for i := range ids { + delete(m.tenant, ids[i]) + m.removedtenant[ids[i]] = struct{}{} + } +} + +// RemovedTenant returns the removed IDs of the "tenant" edge to the Tenant entity. +func (m *RustdeskMutation) RemovedTenantIDs() (ids []int) { + for id := range m.removedtenant { + ids = append(ids, id) + } + return +} + +// TenantIDs returns the "tenant" edge IDs in the mutation. +func (m *RustdeskMutation) TenantIDs() (ids []int) { + for id := range m.tenant { + ids = append(ids, id) + } + return +} + +// ResetTenant resets all changes to the "tenant" edge. +func (m *RustdeskMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false + m.removedtenant = nil +} + +// Where appends a list predicates to the RustdeskMutation builder. +func (m *RustdeskMutation) Where(ps ...predicate.Rustdesk) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the RustdeskMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RustdeskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Rustdesk, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *RustdeskMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *RustdeskMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Rustdesk). +func (m *RustdeskMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *RustdeskMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.custom_rendezvous_server != nil { + fields = append(fields, rustdesk.FieldCustomRendezvousServer) + } + if m.relay_server != nil { + fields = append(fields, rustdesk.FieldRelayServer) + } + if m.api_server != nil { + fields = append(fields, rustdesk.FieldAPIServer) + } + if m.key != nil { + fields = append(fields, rustdesk.FieldKey) + } + if m.use_permanent_password != nil { + fields = append(fields, rustdesk.FieldUsePermanentPassword) + } + if m.whitelist != nil { + fields = append(fields, rustdesk.FieldWhitelist) + } + if m.direct_ip_access != nil { + fields = append(fields, rustdesk.FieldDirectIPAccess) + } + if m.verification_method != nil { + fields = append(fields, rustdesk.FieldVerificationMethod) + } + if m.temporary_password_length != nil { + fields = append(fields, rustdesk.FieldTemporaryPasswordLength) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *RustdeskMutation) Field(name string) (ent.Value, bool) { + switch name { + case rustdesk.FieldCustomRendezvousServer: + return m.CustomRendezvousServer() + case rustdesk.FieldRelayServer: + return m.RelayServer() + case rustdesk.FieldAPIServer: + return m.APIServer() + case rustdesk.FieldKey: + return m.Key() + case rustdesk.FieldUsePermanentPassword: + return m.UsePermanentPassword() + case rustdesk.FieldWhitelist: + return m.Whitelist() + case rustdesk.FieldDirectIPAccess: + return m.DirectIPAccess() + case rustdesk.FieldVerificationMethod: + return m.VerificationMethod() + case rustdesk.FieldTemporaryPasswordLength: + return m.TemporaryPasswordLength() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *RustdeskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case rustdesk.FieldCustomRendezvousServer: + return m.OldCustomRendezvousServer(ctx) + case rustdesk.FieldRelayServer: + return m.OldRelayServer(ctx) + case rustdesk.FieldAPIServer: + return m.OldAPIServer(ctx) + case rustdesk.FieldKey: + return m.OldKey(ctx) + case rustdesk.FieldUsePermanentPassword: + return m.OldUsePermanentPassword(ctx) + case rustdesk.FieldWhitelist: + return m.OldWhitelist(ctx) + case rustdesk.FieldDirectIPAccess: + return m.OldDirectIPAccess(ctx) + case rustdesk.FieldVerificationMethod: + return m.OldVerificationMethod(ctx) + case rustdesk.FieldTemporaryPasswordLength: + return m.OldTemporaryPasswordLength(ctx) + } + return nil, fmt.Errorf("unknown Rustdesk field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ServerMutation) SetField(name string, value ent.Value) error { +func (m *RustdeskMutation) SetField(name string, value ent.Value) error { switch name { - case server.FieldHostname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHostname(v) - return nil - case server.FieldArch: + case rustdesk.FieldCustomRendezvousServer: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetArch(v) + m.SetCustomRendezvousServer(v) return nil - case server.FieldOs: + case rustdesk.FieldRelayServer: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOs(v) + m.SetRelayServer(v) return nil - case server.FieldVersion: + case rustdesk.FieldAPIServer: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetVersion(v) - return nil - case server.FieldChannel: - v, ok := value.(server.Channel) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChannel(v) - return nil - case server.FieldUpdateStatus: - v, ok := value.(server.UpdateStatus) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateStatus(v) + m.SetAPIServer(v) return nil - case server.FieldUpdateMessage: + case rustdesk.FieldKey: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUpdateMessage(v) - return nil - case server.FieldUpdateWhen: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateWhen(v) - return nil - case server.FieldNatsComponent: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNatsComponent(v) + m.SetKey(v) return nil - case server.FieldOcspComponent: + case rustdesk.FieldUsePermanentPassword: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOcspComponent(v) + m.SetUsePermanentPassword(v) return nil - case server.FieldConsoleComponent: - v, ok := value.(bool) + case rustdesk.FieldWhitelist: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetConsoleComponent(v) + m.SetWhitelist(v) return nil - case server.FieldAgentWorkerComponent: + case rustdesk.FieldDirectIPAccess: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetAgentWorkerComponent(v) + m.SetDirectIPAccess(v) return nil - case server.FieldNotificationWorkerComponent: - v, ok := value.(bool) + case rustdesk.FieldVerificationMethod: + v, ok := value.(rustdesk.VerificationMethod) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetNotificationWorkerComponent(v) + m.SetVerificationMethod(v) return nil - case server.FieldCertManagerWorkerComponent: - v, ok := value.(bool) + case rustdesk.FieldTemporaryPasswordLength: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCertManagerWorkerComponent(v) + m.SetTemporaryPasswordLength(v) return nil } - return fmt.Errorf("unknown Server field %s", name) + return fmt.Errorf("unknown Rustdesk field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ServerMutation) AddedFields() []string { - return nil +func (m *RustdeskMutation) AddedFields() []string { + var fields []string + if m.addtemporary_password_length != nil { + fields = append(fields, rustdesk.FieldTemporaryPasswordLength) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ServerMutation) AddedField(name string) (ent.Value, bool) { +func (m *RustdeskMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case rustdesk.FieldTemporaryPasswordLength: + return m.AddedTemporaryPasswordLength() + } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ServerMutation) AddField(name string, value ent.Value) error { +func (m *RustdeskMutation) AddField(name string, value ent.Value) error { switch name { + case rustdesk.FieldTemporaryPasswordLength: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTemporaryPasswordLength(v) + return nil } - return fmt.Errorf("unknown Server numeric field %s", name) + return fmt.Errorf("unknown Rustdesk numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ServerMutation) ClearedFields() []string { +func (m *RustdeskMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(server.FieldUpdateStatus) { - fields = append(fields, server.FieldUpdateStatus) + if m.FieldCleared(rustdesk.FieldCustomRendezvousServer) { + fields = append(fields, rustdesk.FieldCustomRendezvousServer) } - if m.FieldCleared(server.FieldUpdateMessage) { - fields = append(fields, server.FieldUpdateMessage) + if m.FieldCleared(rustdesk.FieldRelayServer) { + fields = append(fields, rustdesk.FieldRelayServer) } - if m.FieldCleared(server.FieldUpdateWhen) { - fields = append(fields, server.FieldUpdateWhen) + if m.FieldCleared(rustdesk.FieldAPIServer) { + fields = append(fields, rustdesk.FieldAPIServer) } - if m.FieldCleared(server.FieldNatsComponent) { - fields = append(fields, server.FieldNatsComponent) + if m.FieldCleared(rustdesk.FieldKey) { + fields = append(fields, rustdesk.FieldKey) } - if m.FieldCleared(server.FieldOcspComponent) { - fields = append(fields, server.FieldOcspComponent) + if m.FieldCleared(rustdesk.FieldUsePermanentPassword) { + fields = append(fields, rustdesk.FieldUsePermanentPassword) } - if m.FieldCleared(server.FieldConsoleComponent) { - fields = append(fields, server.FieldConsoleComponent) + if m.FieldCleared(rustdesk.FieldWhitelist) { + fields = append(fields, rustdesk.FieldWhitelist) } - if m.FieldCleared(server.FieldAgentWorkerComponent) { - fields = append(fields, server.FieldAgentWorkerComponent) + if m.FieldCleared(rustdesk.FieldDirectIPAccess) { + fields = append(fields, rustdesk.FieldDirectIPAccess) } - if m.FieldCleared(server.FieldNotificationWorkerComponent) { - fields = append(fields, server.FieldNotificationWorkerComponent) + if m.FieldCleared(rustdesk.FieldVerificationMethod) { + fields = append(fields, rustdesk.FieldVerificationMethod) } - if m.FieldCleared(server.FieldCertManagerWorkerComponent) { - fields = append(fields, server.FieldCertManagerWorkerComponent) + if m.FieldCleared(rustdesk.FieldTemporaryPasswordLength) { + fields = append(fields, rustdesk.FieldTemporaryPasswordLength) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ServerMutation) FieldCleared(name string) bool { +func (m *RustdeskMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ServerMutation) ClearField(name string) error { +func (m *RustdeskMutation) ClearField(name string) error { switch name { - case server.FieldUpdateStatus: - m.ClearUpdateStatus() + case rustdesk.FieldCustomRendezvousServer: + m.ClearCustomRendezvousServer() return nil - case server.FieldUpdateMessage: - m.ClearUpdateMessage() + case rustdesk.FieldRelayServer: + m.ClearRelayServer() return nil - case server.FieldUpdateWhen: - m.ClearUpdateWhen() + case rustdesk.FieldAPIServer: + m.ClearAPIServer() return nil - case server.FieldNatsComponent: - m.ClearNatsComponent() + case rustdesk.FieldKey: + m.ClearKey() return nil - case server.FieldOcspComponent: - m.ClearOcspComponent() + case rustdesk.FieldUsePermanentPassword: + m.ClearUsePermanentPassword() return nil - case server.FieldConsoleComponent: - m.ClearConsoleComponent() + case rustdesk.FieldWhitelist: + m.ClearWhitelist() return nil - case server.FieldAgentWorkerComponent: - m.ClearAgentWorkerComponent() + case rustdesk.FieldDirectIPAccess: + m.ClearDirectIPAccess() return nil - case server.FieldNotificationWorkerComponent: - m.ClearNotificationWorkerComponent() + case rustdesk.FieldVerificationMethod: + m.ClearVerificationMethod() return nil - case server.FieldCertManagerWorkerComponent: - m.ClearCertManagerWorkerComponent() + case rustdesk.FieldTemporaryPasswordLength: + m.ClearTemporaryPasswordLength() return nil } - return fmt.Errorf("unknown Server nullable field %s", name) + return fmt.Errorf("unknown Rustdesk nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ServerMutation) ResetField(name string) error { +func (m *RustdeskMutation) ResetField(name string) error { switch name { - case server.FieldHostname: - m.ResetHostname() + case rustdesk.FieldCustomRendezvousServer: + m.ResetCustomRendezvousServer() return nil - case server.FieldArch: - m.ResetArch() + case rustdesk.FieldRelayServer: + m.ResetRelayServer() return nil - case server.FieldOs: - m.ResetOs() + case rustdesk.FieldAPIServer: + m.ResetAPIServer() return nil - case server.FieldVersion: - m.ResetVersion() + case rustdesk.FieldKey: + m.ResetKey() return nil - case server.FieldChannel: - m.ResetChannel() + case rustdesk.FieldUsePermanentPassword: + m.ResetUsePermanentPassword() return nil - case server.FieldUpdateStatus: - m.ResetUpdateStatus() + case rustdesk.FieldWhitelist: + m.ResetWhitelist() return nil - case server.FieldUpdateMessage: - m.ResetUpdateMessage() - return nil - case server.FieldUpdateWhen: - m.ResetUpdateWhen() - return nil - case server.FieldNatsComponent: - m.ResetNatsComponent() - return nil - case server.FieldOcspComponent: - m.ResetOcspComponent() - return nil - case server.FieldConsoleComponent: - m.ResetConsoleComponent() - return nil - case server.FieldAgentWorkerComponent: - m.ResetAgentWorkerComponent() + case rustdesk.FieldDirectIPAccess: + m.ResetDirectIPAccess() return nil - case server.FieldNotificationWorkerComponent: - m.ResetNotificationWorkerComponent() + case rustdesk.FieldVerificationMethod: + m.ResetVerificationMethod() return nil - case server.FieldCertManagerWorkerComponent: - m.ResetCertManagerWorkerComponent() + case rustdesk.FieldTemporaryPasswordLength: + m.ResetTemporaryPasswordLength() return nil } - return fmt.Errorf("unknown Server field %s", name) + return fmt.Errorf("unknown Rustdesk field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ServerMutation) AddedEdges() []string { - edges := make([]string, 0, 0) +func (m *RustdeskMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.tenant != nil { + edges = append(edges, rustdesk.EdgeTenant) + } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ServerMutation) AddedIDs(name string) []ent.Value { +func (m *RustdeskMutation) AddedIDs(name string) []ent.Value { + switch name { + case rustdesk.EdgeTenant: + ids := make([]ent.Value, 0, len(m.tenant)) + for id := range m.tenant { + ids = append(ids, id) + } + return ids + } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ServerMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) +func (m *RustdeskMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + if m.removedtenant != nil { + edges = append(edges, rustdesk.EdgeTenant) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ServerMutation) RemovedIDs(name string) []ent.Value { +func (m *RustdeskMutation) RemovedIDs(name string) []ent.Value { + switch name { + case rustdesk.EdgeTenant: + ids := make([]ent.Value, 0, len(m.removedtenant)) + for id := range m.removedtenant { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ServerMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) +func (m *RustdeskMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedtenant { + edges = append(edges, rustdesk.EdgeTenant) + } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ServerMutation) EdgeCleared(name string) bool { +func (m *RustdeskMutation) EdgeCleared(name string) bool { + switch name { + case rustdesk.EdgeTenant: + return m.clearedtenant + } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ServerMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown Server unique edge %s", name) +func (m *RustdeskMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Rustdesk unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ServerMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown Server edge %s", name) +func (m *RustdeskMutation) ResetEdge(name string) error { + switch name { + case rustdesk.EdgeTenant: + m.ResetTenant() + return nil + } + return fmt.Errorf("unknown Rustdesk edge %s", name) } -// SessionsMutation represents an operation that mutates the Sessions nodes in the graph. -type SessionsMutation struct { +// ServerMutation represents an operation that mutates the Server nodes in the graph. +type ServerMutation struct { config - op Op - typ string - id *string - data *[]byte - expiry *time.Time - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Sessions, error) - predicates []predicate.Sessions + op Op + typ string + id *int + hostname *string + arch *string + os *string + version *string + channel *server.Channel + update_status *server.UpdateStatus + update_message *string + update_when *time.Time + nats_component *bool + ocsp_component *bool + console_component *bool + agent_worker_component *bool + notification_worker_component *bool + cert_manager_worker_component *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Server, error) + predicates []predicate.Server } -var _ ent.Mutation = (*SessionsMutation)(nil) +var _ ent.Mutation = (*ServerMutation)(nil) -// sessionsOption allows management of the mutation configuration using functional options. -type sessionsOption func(*SessionsMutation) +// serverOption allows management of the mutation configuration using functional options. +type serverOption func(*ServerMutation) -// newSessionsMutation creates new mutation for the Sessions entity. -func newSessionsMutation(c config, op Op, opts ...sessionsOption) *SessionsMutation { - m := &SessionsMutation{ +// newServerMutation creates new mutation for the Server entity. +func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation { + m := &ServerMutation{ config: c, op: op, - typ: TypeSessions, + typ: TypeServer, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -23145,20 +24145,20 @@ func newSessionsMutation(c config, op Op, opts ...sessionsOption) *SessionsMutat return m } -// withSessionsID sets the ID field of the mutation. -func withSessionsID(id string) sessionsOption { - return func(m *SessionsMutation) { +// withServerID sets the ID field of the mutation. +func withServerID(id int) serverOption { + return func(m *ServerMutation) { var ( err error once sync.Once - value *Sessions + value *Server ) - m.oldValue = func(ctx context.Context) (*Sessions, error) { + m.oldValue = func(ctx context.Context) (*Server, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Sessions.Get(ctx, id) + value, err = m.Client().Server.Get(ctx, id) } }) return value, err @@ -23167,10 +24167,10 @@ func withSessionsID(id string) sessionsOption { } } -// withSessions sets the old Sessions of the mutation. -func withSessions(node *Sessions) sessionsOption { - return func(m *SessionsMutation) { - m.oldValue = func(context.Context) (*Sessions, error) { +// withServer sets the old Server of the mutation. +func withServer(node *Server) serverOption { + return func(m *ServerMutation) { + m.oldValue = func(context.Context) (*Server, error) { return node, nil } m.id = &node.ID @@ -23179,7 +24179,7 @@ func withSessions(node *Sessions) sessionsOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m SessionsMutation) Client() *Client { +func (m ServerMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -23187,7 +24187,7 @@ func (m SessionsMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m SessionsMutation) Tx() (*Tx, error) { +func (m ServerMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -23196,15 +24196,9 @@ func (m SessionsMutation) Tx() (*Tx, error) { return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Sessions entities. -func (m *SessionsMutation) SetID(id string) { - m.id = &id -} - // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SessionsMutation) ID() (id string, exists bool) { +func (m *ServerMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -23215,4290 +24209,4957 @@ func (m *SessionsMutation) ID() (id string, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SessionsMutation) IDs(ctx context.Context) ([]string, error) { +func (m *ServerMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []string{id}, nil + return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Sessions.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Server.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetData sets the "data" field. -func (m *SessionsMutation) SetData(b []byte) { - m.data = &b +// SetHostname sets the "hostname" field. +func (m *ServerMutation) SetHostname(s string) { + m.hostname = &s } -// Data returns the value of the "data" field in the mutation. -func (m *SessionsMutation) Data() (r []byte, exists bool) { - v := m.data +// Hostname returns the value of the "hostname" field in the mutation. +func (m *ServerMutation) Hostname() (r string, exists bool) { + v := m.hostname if v == nil { return } return *v, true } -// OldData returns the old "data" field's value of the Sessions entity. -// If the Sessions object wasn't provided to the builder, the object is fetched from the database. +// OldHostname returns the old "hostname" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SessionsMutation) OldData(ctx context.Context) (v []byte, err error) { +func (m *ServerMutation) OldHostname(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldData is only allowed on UpdateOne operations") + return v, errors.New("OldHostname is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldData requires an ID field in the mutation") + return v, errors.New("OldHostname requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldData: %w", err) + return v, fmt.Errorf("querying old value for OldHostname: %w", err) } - return oldValue.Data, nil + return oldValue.Hostname, nil } -// ResetData resets all changes to the "data" field. -func (m *SessionsMutation) ResetData() { - m.data = nil +// ResetHostname resets all changes to the "hostname" field. +func (m *ServerMutation) ResetHostname() { + m.hostname = nil } -// SetExpiry sets the "expiry" field. -func (m *SessionsMutation) SetExpiry(t time.Time) { - m.expiry = &t +// SetArch sets the "arch" field. +func (m *ServerMutation) SetArch(s string) { + m.arch = &s } -// Expiry returns the value of the "expiry" field in the mutation. -func (m *SessionsMutation) Expiry() (r time.Time, exists bool) { - v := m.expiry +// Arch returns the value of the "arch" field in the mutation. +func (m *ServerMutation) Arch() (r string, exists bool) { + v := m.arch if v == nil { return } return *v, true } -// OldExpiry returns the old "expiry" field's value of the Sessions entity. -// If the Sessions object wasn't provided to the builder, the object is fetched from the database. +// OldArch returns the old "arch" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SessionsMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { +func (m *ServerMutation) OldArch(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExpiry is only allowed on UpdateOne operations") + return v, errors.New("OldArch is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExpiry requires an ID field in the mutation") + return v, errors.New("OldArch requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExpiry: %w", err) + return v, fmt.Errorf("querying old value for OldArch: %w", err) } - return oldValue.Expiry, nil -} - -// ResetExpiry resets all changes to the "expiry" field. -func (m *SessionsMutation) ResetExpiry() { - m.expiry = nil -} - -// SetOwnerID sets the "owner" edge to the User entity by id. -func (m *SessionsMutation) SetOwnerID(id string) { - m.owner = &id + return oldValue.Arch, nil } -// ClearOwner clears the "owner" edge to the User entity. -func (m *SessionsMutation) ClearOwner() { - m.clearedowner = true +// ResetArch resets all changes to the "arch" field. +func (m *ServerMutation) ResetArch() { + m.arch = nil } -// OwnerCleared reports if the "owner" edge to the User entity was cleared. -func (m *SessionsMutation) OwnerCleared() bool { - return m.clearedowner +// SetOs sets the "os" field. +func (m *ServerMutation) SetOs(s string) { + m.os = &s } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *SessionsMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true +// Os returns the value of the "os" field in the mutation. +func (m *ServerMutation) Os() (r string, exists bool) { + v := m.os + if v == nil { + return } - return + return *v, true } -// OwnerIDs returns the "owner" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *SessionsMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { - ids = append(ids, *id) +// OldOs returns the old "os" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldOs(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOs is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOs requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOs: %w", err) + } + return oldValue.Os, nil } -// ResetOwner resets all changes to the "owner" edge. -func (m *SessionsMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ResetOs resets all changes to the "os" field. +func (m *ServerMutation) ResetOs() { + m.os = nil } -// Where appends a list predicates to the SessionsMutation builder. -func (m *SessionsMutation) Where(ps ...predicate.Sessions) { - m.predicates = append(m.predicates, ps...) +// SetVersion sets the "version" field. +func (m *ServerMutation) SetVersion(s string) { + m.version = &s } -// WhereP appends storage-level predicates to the SessionsMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SessionsMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Sessions, len(ps)) - for i := range ps { - p[i] = ps[i] +// Version returns the value of the "version" field in the mutation. +func (m *ServerMutation) Version() (r string, exists bool) { + v := m.version + if v == nil { + return } - m.Where(p...) + return *v, true } -// Op returns the operation name. -func (m *SessionsMutation) Op() Op { - return m.op +// OldVersion returns the old "version" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldVersion(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersion: %w", err) + } + return oldValue.Version, nil } -// SetOp allows setting the mutation operation. -func (m *SessionsMutation) SetOp(op Op) { - m.op = op +// ResetVersion resets all changes to the "version" field. +func (m *ServerMutation) ResetVersion() { + m.version = nil } -// Type returns the node type of this mutation (Sessions). -func (m *SessionsMutation) Type() string { - return m.typ +// SetChannel sets the "channel" field. +func (m *ServerMutation) SetChannel(s server.Channel) { + m.channel = &s } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *SessionsMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.data != nil { - fields = append(fields, sessions.FieldData) - } - if m.expiry != nil { - fields = append(fields, sessions.FieldExpiry) +// Channel returns the value of the "channel" field in the mutation. +func (m *ServerMutation) Channel() (r server.Channel, exists bool) { + v := m.channel + if v == nil { + return } - return fields + return *v, true } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *SessionsMutation) Field(name string) (ent.Value, bool) { - switch name { - case sessions.FieldData: - return m.Data() - case sessions.FieldExpiry: - return m.Expiry() +// OldChannel returns the old "channel" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldChannel(ctx context.Context) (v server.Channel, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannel is only allowed on UpdateOne operations") } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *SessionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case sessions.FieldData: - return m.OldData(ctx) - case sessions.FieldExpiry: - return m.OldExpiry(ctx) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannel requires an ID field in the mutation") } - return nil, fmt.Errorf("unknown Sessions field %s", name) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannel: %w", err) + } + return oldValue.Channel, nil } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *SessionsMutation) SetField(name string, value ent.Value) error { - switch name { - case sessions.FieldData: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetData(v) - return nil - case sessions.FieldExpiry: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetExpiry(v) - return nil - } - return fmt.Errorf("unknown Sessions field %s", name) +// ResetChannel resets all changes to the "channel" field. +func (m *ServerMutation) ResetChannel() { + m.channel = nil } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *SessionsMutation) AddedFields() []string { - return nil +// SetUpdateStatus sets the "update_status" field. +func (m *ServerMutation) SetUpdateStatus(ss server.UpdateStatus) { + m.update_status = &ss } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *SessionsMutation) AddedField(name string) (ent.Value, bool) { - return nil, false +// UpdateStatus returns the value of the "update_status" field in the mutation. +func (m *ServerMutation) UpdateStatus() (r server.UpdateStatus, exists bool) { + v := m.update_status + if v == nil { + return + } + return *v, true } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *SessionsMutation) AddField(name string, value ent.Value) error { - switch name { +// OldUpdateStatus returns the old "update_status" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldUpdateStatus(ctx context.Context) (v server.UpdateStatus, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateStatus is only allowed on UpdateOne operations") } - return fmt.Errorf("unknown Sessions numeric field %s", name) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateStatus: %w", err) + } + return oldValue.UpdateStatus, nil } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *SessionsMutation) ClearedFields() []string { - return nil +// ClearUpdateStatus clears the value of the "update_status" field. +func (m *ServerMutation) ClearUpdateStatus() { + m.update_status = nil + m.clearedFields[server.FieldUpdateStatus] = struct{}{} } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *SessionsMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// UpdateStatusCleared returns if the "update_status" field was cleared in this mutation. +func (m *ServerMutation) UpdateStatusCleared() bool { + _, ok := m.clearedFields[server.FieldUpdateStatus] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *SessionsMutation) ClearField(name string) error { - return fmt.Errorf("unknown Sessions nullable field %s", name) +// ResetUpdateStatus resets all changes to the "update_status" field. +func (m *ServerMutation) ResetUpdateStatus() { + m.update_status = nil + delete(m.clearedFields, server.FieldUpdateStatus) } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *SessionsMutation) ResetField(name string) error { - switch name { - case sessions.FieldData: - m.ResetData() - return nil - case sessions.FieldExpiry: - m.ResetExpiry() - return nil - } - return fmt.Errorf("unknown Sessions field %s", name) +// SetUpdateMessage sets the "update_message" field. +func (m *ServerMutation) SetUpdateMessage(s string) { + m.update_message = &s } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *SessionsMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, sessions.EdgeOwner) +// UpdateMessage returns the value of the "update_message" field in the mutation. +func (m *ServerMutation) UpdateMessage() (r string, exists bool) { + v := m.update_message + if v == nil { + return } - return edges + return *v, true } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *SessionsMutation) AddedIDs(name string) []ent.Value { - switch name { - case sessions.EdgeOwner: - if id := m.owner; id != nil { - return []ent.Value{*id} - } +// OldUpdateMessage returns the old "update_message" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldUpdateMessage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateMessage is only allowed on UpdateOne operations") } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *SessionsMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *SessionsMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SessionsMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, sessions.EdgeOwner) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateMessage requires an ID field in the mutation") } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *SessionsMutation) EdgeCleared(name string) bool { - switch name { - case sessions.EdgeOwner: - return m.clearedowner + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateMessage: %w", err) } - return false + return oldValue.UpdateMessage, nil } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *SessionsMutation) ClearEdge(name string) error { - switch name { - case sessions.EdgeOwner: - m.ClearOwner() - return nil - } - return fmt.Errorf("unknown Sessions unique edge %s", name) +// ClearUpdateMessage clears the value of the "update_message" field. +func (m *ServerMutation) ClearUpdateMessage() { + m.update_message = nil + m.clearedFields[server.FieldUpdateMessage] = struct{}{} } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *SessionsMutation) ResetEdge(name string) error { - switch name { - case sessions.EdgeOwner: - m.ResetOwner() - return nil - } - return fmt.Errorf("unknown Sessions edge %s", name) +// UpdateMessageCleared returns if the "update_message" field was cleared in this mutation. +func (m *ServerMutation) UpdateMessageCleared() bool { + _, ok := m.clearedFields[server.FieldUpdateMessage] + return ok } -// SettingsMutation represents an operation that mutates the Settings nodes in the graph. -type SettingsMutation struct { - config - op Op - typ string - id *int - language *string - organization *string - postal_address *string - postal_code *string - locality *string - province *string - state *string - country *string - smtp_server *string - smtp_port *int - addsmtp_port *int - smtp_user *string - smtp_password *string - smtp_auth *string - smtp_tls *bool - smtp_starttls *bool - nats_server *string - nats_port *string - message_from *string - max_upload_size *string - user_cert_years_valid *int - adduser_cert_years_valid *int - nats_request_timeout_seconds *int - addnats_request_timeout_seconds *int - refresh_time_in_minutes *int - addrefresh_time_in_minutes *int - session_lifetime_in_minutes *int - addsession_lifetime_in_minutes *int - update_channel *string - created *time.Time - modified *time.Time - agent_report_frequence_in_minutes *int - addagent_report_frequence_in_minutes *int - request_vnc_pin *bool - profiles_application_frequence_in_minutes *int - addprofiles_application_frequence_in_minutes *int - use_winget *bool - use_flatpak *bool - use_brew *bool - disable_sftp *bool - disable_remote_assistance *bool - detect_remote_agents *bool - auto_admit_agents *bool - default_items_per_page *int - adddefault_items_per_page *int - clearedFields map[string]struct{} - tag *int - clearedtag bool - tenant *int - clearedtenant bool - done bool - oldValue func(context.Context) (*Settings, error) - predicates []predicate.Settings +// ResetUpdateMessage resets all changes to the "update_message" field. +func (m *ServerMutation) ResetUpdateMessage() { + m.update_message = nil + delete(m.clearedFields, server.FieldUpdateMessage) } -var _ ent.Mutation = (*SettingsMutation)(nil) - -// settingsOption allows management of the mutation configuration using functional options. -type settingsOption func(*SettingsMutation) - -// newSettingsMutation creates new mutation for the Settings entity. -func newSettingsMutation(c config, op Op, opts ...settingsOption) *SettingsMutation { - m := &SettingsMutation{ - config: c, - op: op, - typ: TypeSettings, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m +// SetUpdateWhen sets the "update_when" field. +func (m *ServerMutation) SetUpdateWhen(t time.Time) { + m.update_when = &t } -// withSettingsID sets the ID field of the mutation. -func withSettingsID(id int) settingsOption { - return func(m *SettingsMutation) { - var ( - err error - once sync.Once - value *Settings - ) - m.oldValue = func(ctx context.Context) (*Settings, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Settings.Get(ctx, id) - } - }) - return value, err - } - m.id = &id +// UpdateWhen returns the value of the "update_when" field in the mutation. +func (m *ServerMutation) UpdateWhen() (r time.Time, exists bool) { + v := m.update_when + if v == nil { + return } + return *v, true } -// withSettings sets the old Settings of the mutation. -func withSettings(node *Settings) settingsOption { - return func(m *SettingsMutation) { - m.oldValue = func(context.Context) (*Settings, error) { - return node, nil - } - m.id = &node.ID +// OldUpdateWhen returns the old "update_when" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldUpdateWhen(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateWhen is only allowed on UpdateOne operations") } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateWhen requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateWhen: %w", err) + } + return oldValue.UpdateWhen, nil } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m SettingsMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m SettingsMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// ClearUpdateWhen clears the value of the "update_when" field. +func (m *ServerMutation) ClearUpdateWhen() { + m.update_when = nil + m.clearedFields[server.FieldUpdateWhen] = struct{}{} } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *SettingsMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true +// UpdateWhenCleared returns if the "update_when" field was cleared in this mutation. +func (m *ServerMutation) UpdateWhenCleared() bool { + _, ok := m.clearedFields[server.FieldUpdateWhen] + return ok } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *SettingsMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Settings.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } +// ResetUpdateWhen resets all changes to the "update_when" field. +func (m *ServerMutation) ResetUpdateWhen() { + m.update_when = nil + delete(m.clearedFields, server.FieldUpdateWhen) } -// SetLanguage sets the "language" field. -func (m *SettingsMutation) SetLanguage(s string) { - m.language = &s +// SetNatsComponent sets the "nats_component" field. +func (m *ServerMutation) SetNatsComponent(b bool) { + m.nats_component = &b } -// Language returns the value of the "language" field in the mutation. -func (m *SettingsMutation) Language() (r string, exists bool) { - v := m.language +// NatsComponent returns the value of the "nats_component" field in the mutation. +func (m *ServerMutation) NatsComponent() (r bool, exists bool) { + v := m.nats_component if v == nil { return } return *v, true } -// OldLanguage returns the old "language" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldNatsComponent returns the old "nats_component" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldLanguage(ctx context.Context) (v string, err error) { +func (m *ServerMutation) OldNatsComponent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLanguage is only allowed on UpdateOne operations") + return v, errors.New("OldNatsComponent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLanguage requires an ID field in the mutation") + return v, errors.New("OldNatsComponent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLanguage: %w", err) + return v, fmt.Errorf("querying old value for OldNatsComponent: %w", err) } - return oldValue.Language, nil + return oldValue.NatsComponent, nil } -// ClearLanguage clears the value of the "language" field. -func (m *SettingsMutation) ClearLanguage() { - m.language = nil - m.clearedFields[settings.FieldLanguage] = struct{}{} +// ClearNatsComponent clears the value of the "nats_component" field. +func (m *ServerMutation) ClearNatsComponent() { + m.nats_component = nil + m.clearedFields[server.FieldNatsComponent] = struct{}{} } -// LanguageCleared returns if the "language" field was cleared in this mutation. -func (m *SettingsMutation) LanguageCleared() bool { - _, ok := m.clearedFields[settings.FieldLanguage] +// NatsComponentCleared returns if the "nats_component" field was cleared in this mutation. +func (m *ServerMutation) NatsComponentCleared() bool { + _, ok := m.clearedFields[server.FieldNatsComponent] return ok } -// ResetLanguage resets all changes to the "language" field. -func (m *SettingsMutation) ResetLanguage() { - m.language = nil - delete(m.clearedFields, settings.FieldLanguage) +// ResetNatsComponent resets all changes to the "nats_component" field. +func (m *ServerMutation) ResetNatsComponent() { + m.nats_component = nil + delete(m.clearedFields, server.FieldNatsComponent) } -// SetOrganization sets the "organization" field. -func (m *SettingsMutation) SetOrganization(s string) { - m.organization = &s +// SetOcspComponent sets the "ocsp_component" field. +func (m *ServerMutation) SetOcspComponent(b bool) { + m.ocsp_component = &b } -// Organization returns the value of the "organization" field in the mutation. -func (m *SettingsMutation) Organization() (r string, exists bool) { - v := m.organization +// OcspComponent returns the value of the "ocsp_component" field in the mutation. +func (m *ServerMutation) OcspComponent() (r bool, exists bool) { + v := m.ocsp_component if v == nil { return } return *v, true } -// OldOrganization returns the old "organization" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldOcspComponent returns the old "ocsp_component" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldOrganization(ctx context.Context) (v string, err error) { +func (m *ServerMutation) OldOcspComponent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOrganization is only allowed on UpdateOne operations") + return v, errors.New("OldOcspComponent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOrganization requires an ID field in the mutation") + return v, errors.New("OldOcspComponent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOrganization: %w", err) + return v, fmt.Errorf("querying old value for OldOcspComponent: %w", err) } - return oldValue.Organization, nil + return oldValue.OcspComponent, nil } -// ClearOrganization clears the value of the "organization" field. -func (m *SettingsMutation) ClearOrganization() { - m.organization = nil - m.clearedFields[settings.FieldOrganization] = struct{}{} +// ClearOcspComponent clears the value of the "ocsp_component" field. +func (m *ServerMutation) ClearOcspComponent() { + m.ocsp_component = nil + m.clearedFields[server.FieldOcspComponent] = struct{}{} } -// OrganizationCleared returns if the "organization" field was cleared in this mutation. -func (m *SettingsMutation) OrganizationCleared() bool { - _, ok := m.clearedFields[settings.FieldOrganization] +// OcspComponentCleared returns if the "ocsp_component" field was cleared in this mutation. +func (m *ServerMutation) OcspComponentCleared() bool { + _, ok := m.clearedFields[server.FieldOcspComponent] return ok } -// ResetOrganization resets all changes to the "organization" field. -func (m *SettingsMutation) ResetOrganization() { - m.organization = nil - delete(m.clearedFields, settings.FieldOrganization) +// ResetOcspComponent resets all changes to the "ocsp_component" field. +func (m *ServerMutation) ResetOcspComponent() { + m.ocsp_component = nil + delete(m.clearedFields, server.FieldOcspComponent) } -// SetPostalAddress sets the "postal_address" field. -func (m *SettingsMutation) SetPostalAddress(s string) { - m.postal_address = &s +// SetConsoleComponent sets the "console_component" field. +func (m *ServerMutation) SetConsoleComponent(b bool) { + m.console_component = &b } -// PostalAddress returns the value of the "postal_address" field in the mutation. -func (m *SettingsMutation) PostalAddress() (r string, exists bool) { - v := m.postal_address +// ConsoleComponent returns the value of the "console_component" field in the mutation. +func (m *ServerMutation) ConsoleComponent() (r bool, exists bool) { + v := m.console_component if v == nil { return } return *v, true } -// OldPostalAddress returns the old "postal_address" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldConsoleComponent returns the old "console_component" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldPostalAddress(ctx context.Context) (v string, err error) { +func (m *ServerMutation) OldConsoleComponent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPostalAddress is only allowed on UpdateOne operations") + return v, errors.New("OldConsoleComponent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPostalAddress requires an ID field in the mutation") + return v, errors.New("OldConsoleComponent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPostalAddress: %w", err) + return v, fmt.Errorf("querying old value for OldConsoleComponent: %w", err) } - return oldValue.PostalAddress, nil + return oldValue.ConsoleComponent, nil } -// ClearPostalAddress clears the value of the "postal_address" field. -func (m *SettingsMutation) ClearPostalAddress() { - m.postal_address = nil - m.clearedFields[settings.FieldPostalAddress] = struct{}{} +// ClearConsoleComponent clears the value of the "console_component" field. +func (m *ServerMutation) ClearConsoleComponent() { + m.console_component = nil + m.clearedFields[server.FieldConsoleComponent] = struct{}{} } -// PostalAddressCleared returns if the "postal_address" field was cleared in this mutation. -func (m *SettingsMutation) PostalAddressCleared() bool { - _, ok := m.clearedFields[settings.FieldPostalAddress] +// ConsoleComponentCleared returns if the "console_component" field was cleared in this mutation. +func (m *ServerMutation) ConsoleComponentCleared() bool { + _, ok := m.clearedFields[server.FieldConsoleComponent] return ok } -// ResetPostalAddress resets all changes to the "postal_address" field. -func (m *SettingsMutation) ResetPostalAddress() { - m.postal_address = nil - delete(m.clearedFields, settings.FieldPostalAddress) +// ResetConsoleComponent resets all changes to the "console_component" field. +func (m *ServerMutation) ResetConsoleComponent() { + m.console_component = nil + delete(m.clearedFields, server.FieldConsoleComponent) } -// SetPostalCode sets the "postal_code" field. -func (m *SettingsMutation) SetPostalCode(s string) { - m.postal_code = &s +// SetAgentWorkerComponent sets the "agent_worker_component" field. +func (m *ServerMutation) SetAgentWorkerComponent(b bool) { + m.agent_worker_component = &b } -// PostalCode returns the value of the "postal_code" field in the mutation. -func (m *SettingsMutation) PostalCode() (r string, exists bool) { - v := m.postal_code +// AgentWorkerComponent returns the value of the "agent_worker_component" field in the mutation. +func (m *ServerMutation) AgentWorkerComponent() (r bool, exists bool) { + v := m.agent_worker_component if v == nil { return } return *v, true } -// OldPostalCode returns the old "postal_code" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldAgentWorkerComponent returns the old "agent_worker_component" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldPostalCode(ctx context.Context) (v string, err error) { +func (m *ServerMutation) OldAgentWorkerComponent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPostalCode is only allowed on UpdateOne operations") + return v, errors.New("OldAgentWorkerComponent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPostalCode requires an ID field in the mutation") + return v, errors.New("OldAgentWorkerComponent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPostalCode: %w", err) + return v, fmt.Errorf("querying old value for OldAgentWorkerComponent: %w", err) } - return oldValue.PostalCode, nil + return oldValue.AgentWorkerComponent, nil } -// ClearPostalCode clears the value of the "postal_code" field. -func (m *SettingsMutation) ClearPostalCode() { - m.postal_code = nil - m.clearedFields[settings.FieldPostalCode] = struct{}{} +// ClearAgentWorkerComponent clears the value of the "agent_worker_component" field. +func (m *ServerMutation) ClearAgentWorkerComponent() { + m.agent_worker_component = nil + m.clearedFields[server.FieldAgentWorkerComponent] = struct{}{} } -// PostalCodeCleared returns if the "postal_code" field was cleared in this mutation. -func (m *SettingsMutation) PostalCodeCleared() bool { - _, ok := m.clearedFields[settings.FieldPostalCode] +// AgentWorkerComponentCleared returns if the "agent_worker_component" field was cleared in this mutation. +func (m *ServerMutation) AgentWorkerComponentCleared() bool { + _, ok := m.clearedFields[server.FieldAgentWorkerComponent] return ok } -// ResetPostalCode resets all changes to the "postal_code" field. -func (m *SettingsMutation) ResetPostalCode() { - m.postal_code = nil - delete(m.clearedFields, settings.FieldPostalCode) +// ResetAgentWorkerComponent resets all changes to the "agent_worker_component" field. +func (m *ServerMutation) ResetAgentWorkerComponent() { + m.agent_worker_component = nil + delete(m.clearedFields, server.FieldAgentWorkerComponent) } -// SetLocality sets the "locality" field. -func (m *SettingsMutation) SetLocality(s string) { - m.locality = &s +// SetNotificationWorkerComponent sets the "notification_worker_component" field. +func (m *ServerMutation) SetNotificationWorkerComponent(b bool) { + m.notification_worker_component = &b } -// Locality returns the value of the "locality" field in the mutation. -func (m *SettingsMutation) Locality() (r string, exists bool) { - v := m.locality +// NotificationWorkerComponent returns the value of the "notification_worker_component" field in the mutation. +func (m *ServerMutation) NotificationWorkerComponent() (r bool, exists bool) { + v := m.notification_worker_component if v == nil { return } return *v, true } -// OldLocality returns the old "locality" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldNotificationWorkerComponent returns the old "notification_worker_component" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldLocality(ctx context.Context) (v string, err error) { +func (m *ServerMutation) OldNotificationWorkerComponent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocality is only allowed on UpdateOne operations") + return v, errors.New("OldNotificationWorkerComponent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocality requires an ID field in the mutation") + return v, errors.New("OldNotificationWorkerComponent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocality: %w", err) + return v, fmt.Errorf("querying old value for OldNotificationWorkerComponent: %w", err) } - return oldValue.Locality, nil + return oldValue.NotificationWorkerComponent, nil } -// ClearLocality clears the value of the "locality" field. -func (m *SettingsMutation) ClearLocality() { - m.locality = nil - m.clearedFields[settings.FieldLocality] = struct{}{} +// ClearNotificationWorkerComponent clears the value of the "notification_worker_component" field. +func (m *ServerMutation) ClearNotificationWorkerComponent() { + m.notification_worker_component = nil + m.clearedFields[server.FieldNotificationWorkerComponent] = struct{}{} } -// LocalityCleared returns if the "locality" field was cleared in this mutation. -func (m *SettingsMutation) LocalityCleared() bool { - _, ok := m.clearedFields[settings.FieldLocality] +// NotificationWorkerComponentCleared returns if the "notification_worker_component" field was cleared in this mutation. +func (m *ServerMutation) NotificationWorkerComponentCleared() bool { + _, ok := m.clearedFields[server.FieldNotificationWorkerComponent] return ok } -// ResetLocality resets all changes to the "locality" field. -func (m *SettingsMutation) ResetLocality() { - m.locality = nil - delete(m.clearedFields, settings.FieldLocality) +// ResetNotificationWorkerComponent resets all changes to the "notification_worker_component" field. +func (m *ServerMutation) ResetNotificationWorkerComponent() { + m.notification_worker_component = nil + delete(m.clearedFields, server.FieldNotificationWorkerComponent) } -// SetProvince sets the "province" field. -func (m *SettingsMutation) SetProvince(s string) { - m.province = &s +// SetCertManagerWorkerComponent sets the "cert_manager_worker_component" field. +func (m *ServerMutation) SetCertManagerWorkerComponent(b bool) { + m.cert_manager_worker_component = &b } -// Province returns the value of the "province" field in the mutation. -func (m *SettingsMutation) Province() (r string, exists bool) { - v := m.province +// CertManagerWorkerComponent returns the value of the "cert_manager_worker_component" field in the mutation. +func (m *ServerMutation) CertManagerWorkerComponent() (r bool, exists bool) { + v := m.cert_manager_worker_component if v == nil { return } return *v, true } -// OldProvince returns the old "province" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldProvince(ctx context.Context) (v string, err error) { +// OldCertManagerWorkerComponent returns the old "cert_manager_worker_component" field's value of the Server entity. +// If the Server object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServerMutation) OldCertManagerWorkerComponent(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProvince is only allowed on UpdateOne operations") + return v, errors.New("OldCertManagerWorkerComponent is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProvince requires an ID field in the mutation") + return v, errors.New("OldCertManagerWorkerComponent requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProvince: %w", err) + return v, fmt.Errorf("querying old value for OldCertManagerWorkerComponent: %w", err) } - return oldValue.Province, nil + return oldValue.CertManagerWorkerComponent, nil } -// ClearProvince clears the value of the "province" field. -func (m *SettingsMutation) ClearProvince() { - m.province = nil - m.clearedFields[settings.FieldProvince] = struct{}{} +// ClearCertManagerWorkerComponent clears the value of the "cert_manager_worker_component" field. +func (m *ServerMutation) ClearCertManagerWorkerComponent() { + m.cert_manager_worker_component = nil + m.clearedFields[server.FieldCertManagerWorkerComponent] = struct{}{} } -// ProvinceCleared returns if the "province" field was cleared in this mutation. -func (m *SettingsMutation) ProvinceCleared() bool { - _, ok := m.clearedFields[settings.FieldProvince] +// CertManagerWorkerComponentCleared returns if the "cert_manager_worker_component" field was cleared in this mutation. +func (m *ServerMutation) CertManagerWorkerComponentCleared() bool { + _, ok := m.clearedFields[server.FieldCertManagerWorkerComponent] return ok } -// ResetProvince resets all changes to the "province" field. -func (m *SettingsMutation) ResetProvince() { - m.province = nil - delete(m.clearedFields, settings.FieldProvince) -} - -// SetState sets the "state" field. -func (m *SettingsMutation) SetState(s string) { - m.state = &s +// ResetCertManagerWorkerComponent resets all changes to the "cert_manager_worker_component" field. +func (m *ServerMutation) ResetCertManagerWorkerComponent() { + m.cert_manager_worker_component = nil + delete(m.clearedFields, server.FieldCertManagerWorkerComponent) } -// State returns the value of the "state" field in the mutation. -func (m *SettingsMutation) State() (r string, exists bool) { - v := m.state - if v == nil { - return - } - return *v, true +// Where appends a list predicates to the ServerMutation builder. +func (m *ServerMutation) Where(ps ...predicate.Server) { + m.predicates = append(m.predicates, ps...) } -// OldState returns the old "state" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldState(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldState is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldState requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldState: %w", err) +// WhereP appends storage-level predicates to the ServerMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Server, len(ps)) + for i := range ps { + p[i] = ps[i] } - return oldValue.State, nil -} - -// ClearState clears the value of the "state" field. -func (m *SettingsMutation) ClearState() { - m.state = nil - m.clearedFields[settings.FieldState] = struct{}{} + m.Where(p...) } -// StateCleared returns if the "state" field was cleared in this mutation. -func (m *SettingsMutation) StateCleared() bool { - _, ok := m.clearedFields[settings.FieldState] - return ok +// Op returns the operation name. +func (m *ServerMutation) Op() Op { + return m.op } -// ResetState resets all changes to the "state" field. -func (m *SettingsMutation) ResetState() { - m.state = nil - delete(m.clearedFields, settings.FieldState) +// SetOp allows setting the mutation operation. +func (m *ServerMutation) SetOp(op Op) { + m.op = op } -// SetCountry sets the "country" field. -func (m *SettingsMutation) SetCountry(s string) { - m.country = &s +// Type returns the node type of this mutation (Server). +func (m *ServerMutation) Type() string { + return m.typ } -// Country returns the value of the "country" field in the mutation. -func (m *SettingsMutation) Country() (r string, exists bool) { - v := m.country - if v == nil { - return +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ServerMutation) Fields() []string { + fields := make([]string, 0, 14) + if m.hostname != nil { + fields = append(fields, server.FieldHostname) } - return *v, true -} - -// OldCountry returns the old "country" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldCountry(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCountry is only allowed on UpdateOne operations") + if m.arch != nil { + fields = append(fields, server.FieldArch) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCountry requires an ID field in the mutation") + if m.os != nil { + fields = append(fields, server.FieldOs) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCountry: %w", err) + if m.version != nil { + fields = append(fields, server.FieldVersion) } - return oldValue.Country, nil -} - -// ClearCountry clears the value of the "country" field. -func (m *SettingsMutation) ClearCountry() { - m.country = nil - m.clearedFields[settings.FieldCountry] = struct{}{} -} - -// CountryCleared returns if the "country" field was cleared in this mutation. -func (m *SettingsMutation) CountryCleared() bool { - _, ok := m.clearedFields[settings.FieldCountry] - return ok -} - -// ResetCountry resets all changes to the "country" field. -func (m *SettingsMutation) ResetCountry() { - m.country = nil - delete(m.clearedFields, settings.FieldCountry) -} - -// SetSMTPServer sets the "smtp_server" field. -func (m *SettingsMutation) SetSMTPServer(s string) { - m.smtp_server = &s -} - -// SMTPServer returns the value of the "smtp_server" field in the mutation. -func (m *SettingsMutation) SMTPServer() (r string, exists bool) { - v := m.smtp_server - if v == nil { - return + if m.channel != nil { + fields = append(fields, server.FieldChannel) } - return *v, true -} - -// OldSMTPServer returns the old "smtp_server" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPServer(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPServer is only allowed on UpdateOne operations") + if m.update_status != nil { + fields = append(fields, server.FieldUpdateStatus) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPServer requires an ID field in the mutation") + if m.update_message != nil { + fields = append(fields, server.FieldUpdateMessage) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPServer: %w", err) + if m.update_when != nil { + fields = append(fields, server.FieldUpdateWhen) } - return oldValue.SMTPServer, nil -} - -// ClearSMTPServer clears the value of the "smtp_server" field. -func (m *SettingsMutation) ClearSMTPServer() { - m.smtp_server = nil - m.clearedFields[settings.FieldSMTPServer] = struct{}{} -} - -// SMTPServerCleared returns if the "smtp_server" field was cleared in this mutation. -func (m *SettingsMutation) SMTPServerCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPServer] - return ok -} - -// ResetSMTPServer resets all changes to the "smtp_server" field. -func (m *SettingsMutation) ResetSMTPServer() { - m.smtp_server = nil - delete(m.clearedFields, settings.FieldSMTPServer) -} - -// SetSMTPPort sets the "smtp_port" field. -func (m *SettingsMutation) SetSMTPPort(i int) { - m.smtp_port = &i - m.addsmtp_port = nil -} - -// SMTPPort returns the value of the "smtp_port" field in the mutation. -func (m *SettingsMutation) SMTPPort() (r int, exists bool) { - v := m.smtp_port - if v == nil { - return + if m.nats_component != nil { + fields = append(fields, server.FieldNatsComponent) } - return *v, true -} - -// OldSMTPPort returns the old "smtp_port" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPPort(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPPort is only allowed on UpdateOne operations") + if m.ocsp_component != nil { + fields = append(fields, server.FieldOcspComponent) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPPort requires an ID field in the mutation") + if m.console_component != nil { + fields = append(fields, server.FieldConsoleComponent) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPPort: %w", err) + if m.agent_worker_component != nil { + fields = append(fields, server.FieldAgentWorkerComponent) } - return oldValue.SMTPPort, nil -} - -// AddSMTPPort adds i to the "smtp_port" field. -func (m *SettingsMutation) AddSMTPPort(i int) { - if m.addsmtp_port != nil { - *m.addsmtp_port += i - } else { - m.addsmtp_port = &i + if m.notification_worker_component != nil { + fields = append(fields, server.FieldNotificationWorkerComponent) + } + if m.cert_manager_worker_component != nil { + fields = append(fields, server.FieldCertManagerWorkerComponent) } + return fields } -// AddedSMTPPort returns the value that was added to the "smtp_port" field in this mutation. -func (m *SettingsMutation) AddedSMTPPort() (r int, exists bool) { - v := m.addsmtp_port - if v == nil { - return +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ServerMutation) Field(name string) (ent.Value, bool) { + switch name { + case server.FieldHostname: + return m.Hostname() + case server.FieldArch: + return m.Arch() + case server.FieldOs: + return m.Os() + case server.FieldVersion: + return m.Version() + case server.FieldChannel: + return m.Channel() + case server.FieldUpdateStatus: + return m.UpdateStatus() + case server.FieldUpdateMessage: + return m.UpdateMessage() + case server.FieldUpdateWhen: + return m.UpdateWhen() + case server.FieldNatsComponent: + return m.NatsComponent() + case server.FieldOcspComponent: + return m.OcspComponent() + case server.FieldConsoleComponent: + return m.ConsoleComponent() + case server.FieldAgentWorkerComponent: + return m.AgentWorkerComponent() + case server.FieldNotificationWorkerComponent: + return m.NotificationWorkerComponent() + case server.FieldCertManagerWorkerComponent: + return m.CertManagerWorkerComponent() } - return *v, true + return nil, false } -// ClearSMTPPort clears the value of the "smtp_port" field. -func (m *SettingsMutation) ClearSMTPPort() { - m.smtp_port = nil - m.addsmtp_port = nil - m.clearedFields[settings.FieldSMTPPort] = struct{}{} +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case server.FieldHostname: + return m.OldHostname(ctx) + case server.FieldArch: + return m.OldArch(ctx) + case server.FieldOs: + return m.OldOs(ctx) + case server.FieldVersion: + return m.OldVersion(ctx) + case server.FieldChannel: + return m.OldChannel(ctx) + case server.FieldUpdateStatus: + return m.OldUpdateStatus(ctx) + case server.FieldUpdateMessage: + return m.OldUpdateMessage(ctx) + case server.FieldUpdateWhen: + return m.OldUpdateWhen(ctx) + case server.FieldNatsComponent: + return m.OldNatsComponent(ctx) + case server.FieldOcspComponent: + return m.OldOcspComponent(ctx) + case server.FieldConsoleComponent: + return m.OldConsoleComponent(ctx) + case server.FieldAgentWorkerComponent: + return m.OldAgentWorkerComponent(ctx) + case server.FieldNotificationWorkerComponent: + return m.OldNotificationWorkerComponent(ctx) + case server.FieldCertManagerWorkerComponent: + return m.OldCertManagerWorkerComponent(ctx) + } + return nil, fmt.Errorf("unknown Server field %s", name) } -// SMTPPortCleared returns if the "smtp_port" field was cleared in this mutation. -func (m *SettingsMutation) SMTPPortCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPPort] - return ok +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ServerMutation) SetField(name string, value ent.Value) error { + switch name { + case server.FieldHostname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHostname(v) + return nil + case server.FieldArch: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetArch(v) + return nil + case server.FieldOs: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOs(v) + return nil + case server.FieldVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case server.FieldChannel: + v, ok := value.(server.Channel) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannel(v) + return nil + case server.FieldUpdateStatus: + v, ok := value.(server.UpdateStatus) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateStatus(v) + return nil + case server.FieldUpdateMessage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateMessage(v) + return nil + case server.FieldUpdateWhen: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateWhen(v) + return nil + case server.FieldNatsComponent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNatsComponent(v) + return nil + case server.FieldOcspComponent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOcspComponent(v) + return nil + case server.FieldConsoleComponent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetConsoleComponent(v) + return nil + case server.FieldAgentWorkerComponent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAgentWorkerComponent(v) + return nil + case server.FieldNotificationWorkerComponent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotificationWorkerComponent(v) + return nil + case server.FieldCertManagerWorkerComponent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCertManagerWorkerComponent(v) + return nil + } + return fmt.Errorf("unknown Server field %s", name) } -// ResetSMTPPort resets all changes to the "smtp_port" field. -func (m *SettingsMutation) ResetSMTPPort() { - m.smtp_port = nil - m.addsmtp_port = nil - delete(m.clearedFields, settings.FieldSMTPPort) +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ServerMutation) AddedFields() []string { + return nil } -// SetSMTPUser sets the "smtp_user" field. -func (m *SettingsMutation) SetSMTPUser(s string) { - m.smtp_user = &s +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ServerMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// SMTPUser returns the value of the "smtp_user" field in the mutation. -func (m *SettingsMutation) SMTPUser() (r string, exists bool) { - v := m.smtp_user - if v == nil { - return +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ServerMutation) AddField(name string, value ent.Value) error { + switch name { } - return *v, true + return fmt.Errorf("unknown Server numeric field %s", name) } -// OldSMTPUser returns the old "smtp_user" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPUser(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPUser is only allowed on UpdateOne operations") +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ServerMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(server.FieldUpdateStatus) { + fields = append(fields, server.FieldUpdateStatus) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPUser requires an ID field in the mutation") + if m.FieldCleared(server.FieldUpdateMessage) { + fields = append(fields, server.FieldUpdateMessage) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPUser: %w", err) + if m.FieldCleared(server.FieldUpdateWhen) { + fields = append(fields, server.FieldUpdateWhen) } - return oldValue.SMTPUser, nil + if m.FieldCleared(server.FieldNatsComponent) { + fields = append(fields, server.FieldNatsComponent) + } + if m.FieldCleared(server.FieldOcspComponent) { + fields = append(fields, server.FieldOcspComponent) + } + if m.FieldCleared(server.FieldConsoleComponent) { + fields = append(fields, server.FieldConsoleComponent) + } + if m.FieldCleared(server.FieldAgentWorkerComponent) { + fields = append(fields, server.FieldAgentWorkerComponent) + } + if m.FieldCleared(server.FieldNotificationWorkerComponent) { + fields = append(fields, server.FieldNotificationWorkerComponent) + } + if m.FieldCleared(server.FieldCertManagerWorkerComponent) { + fields = append(fields, server.FieldCertManagerWorkerComponent) + } + return fields } -// ClearSMTPUser clears the value of the "smtp_user" field. -func (m *SettingsMutation) ClearSMTPUser() { - m.smtp_user = nil - m.clearedFields[settings.FieldSMTPUser] = struct{}{} -} - -// SMTPUserCleared returns if the "smtp_user" field was cleared in this mutation. -func (m *SettingsMutation) SMTPUserCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPUser] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ServerMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetSMTPUser resets all changes to the "smtp_user" field. -func (m *SettingsMutation) ResetSMTPUser() { - m.smtp_user = nil - delete(m.clearedFields, settings.FieldSMTPUser) -} - -// SetSMTPPassword sets the "smtp_password" field. -func (m *SettingsMutation) SetSMTPPassword(s string) { - m.smtp_password = &s -} - -// SMTPPassword returns the value of the "smtp_password" field in the mutation. -func (m *SettingsMutation) SMTPPassword() (r string, exists bool) { - v := m.smtp_password - if v == nil { - return +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ServerMutation) ClearField(name string) error { + switch name { + case server.FieldUpdateStatus: + m.ClearUpdateStatus() + return nil + case server.FieldUpdateMessage: + m.ClearUpdateMessage() + return nil + case server.FieldUpdateWhen: + m.ClearUpdateWhen() + return nil + case server.FieldNatsComponent: + m.ClearNatsComponent() + return nil + case server.FieldOcspComponent: + m.ClearOcspComponent() + return nil + case server.FieldConsoleComponent: + m.ClearConsoleComponent() + return nil + case server.FieldAgentWorkerComponent: + m.ClearAgentWorkerComponent() + return nil + case server.FieldNotificationWorkerComponent: + m.ClearNotificationWorkerComponent() + return nil + case server.FieldCertManagerWorkerComponent: + m.ClearCertManagerWorkerComponent() + return nil } - return *v, true + return fmt.Errorf("unknown Server nullable field %s", name) } -// OldSMTPPassword returns the old "smtp_password" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPPassword(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPPassword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPPassword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPPassword: %w", err) +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ServerMutation) ResetField(name string) error { + switch name { + case server.FieldHostname: + m.ResetHostname() + return nil + case server.FieldArch: + m.ResetArch() + return nil + case server.FieldOs: + m.ResetOs() + return nil + case server.FieldVersion: + m.ResetVersion() + return nil + case server.FieldChannel: + m.ResetChannel() + return nil + case server.FieldUpdateStatus: + m.ResetUpdateStatus() + return nil + case server.FieldUpdateMessage: + m.ResetUpdateMessage() + return nil + case server.FieldUpdateWhen: + m.ResetUpdateWhen() + return nil + case server.FieldNatsComponent: + m.ResetNatsComponent() + return nil + case server.FieldOcspComponent: + m.ResetOcspComponent() + return nil + case server.FieldConsoleComponent: + m.ResetConsoleComponent() + return nil + case server.FieldAgentWorkerComponent: + m.ResetAgentWorkerComponent() + return nil + case server.FieldNotificationWorkerComponent: + m.ResetNotificationWorkerComponent() + return nil + case server.FieldCertManagerWorkerComponent: + m.ResetCertManagerWorkerComponent() + return nil } - return oldValue.SMTPPassword, nil + return fmt.Errorf("unknown Server field %s", name) } -// ClearSMTPPassword clears the value of the "smtp_password" field. -func (m *SettingsMutation) ClearSMTPPassword() { - m.smtp_password = nil - m.clearedFields[settings.FieldSMTPPassword] = struct{}{} +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ServerMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges } -// SMTPPasswordCleared returns if the "smtp_password" field was cleared in this mutation. -func (m *SettingsMutation) SMTPPasswordCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPPassword] - return ok +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ServerMutation) AddedIDs(name string) []ent.Value { + return nil } -// ResetSMTPPassword resets all changes to the "smtp_password" field. -func (m *SettingsMutation) ResetSMTPPassword() { - m.smtp_password = nil - delete(m.clearedFields, settings.FieldSMTPPassword) +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ServerMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges } -// SetSMTPAuth sets the "smtp_auth" field. -func (m *SettingsMutation) SetSMTPAuth(s string) { - m.smtp_auth = &s +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ServerMutation) RemovedIDs(name string) []ent.Value { + return nil } -// SMTPAuth returns the value of the "smtp_auth" field in the mutation. -func (m *SettingsMutation) SMTPAuth() (r string, exists bool) { - v := m.smtp_auth - if v == nil { - return - } - return *v, true +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ServerMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges } -// OldSMTPAuth returns the old "smtp_auth" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPAuth(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPAuth is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPAuth requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPAuth: %w", err) - } - return oldValue.SMTPAuth, nil +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ServerMutation) EdgeCleared(name string) bool { + return false } -// ClearSMTPAuth clears the value of the "smtp_auth" field. -func (m *SettingsMutation) ClearSMTPAuth() { - m.smtp_auth = nil - m.clearedFields[settings.FieldSMTPAuth] = struct{}{} +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ServerMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Server unique edge %s", name) } -// SMTPAuthCleared returns if the "smtp_auth" field was cleared in this mutation. -func (m *SettingsMutation) SMTPAuthCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPAuth] - return ok +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ServerMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Server edge %s", name) } -// ResetSMTPAuth resets all changes to the "smtp_auth" field. -func (m *SettingsMutation) ResetSMTPAuth() { - m.smtp_auth = nil - delete(m.clearedFields, settings.FieldSMTPAuth) +// SessionsMutation represents an operation that mutates the Sessions nodes in the graph. +type SessionsMutation struct { + config + op Op + typ string + id *string + data *[]byte + expiry *time.Time + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Sessions, error) + predicates []predicate.Sessions } -// SetSMTPTLS sets the "smtp_tls" field. -func (m *SettingsMutation) SetSMTPTLS(b bool) { - m.smtp_tls = &b -} +var _ ent.Mutation = (*SessionsMutation)(nil) -// SMTPTLS returns the value of the "smtp_tls" field in the mutation. -func (m *SettingsMutation) SMTPTLS() (r bool, exists bool) { - v := m.smtp_tls - if v == nil { - return +// sessionsOption allows management of the mutation configuration using functional options. +type sessionsOption func(*SessionsMutation) + +// newSessionsMutation creates new mutation for the Sessions entity. +func newSessionsMutation(c config, op Op, opts ...sessionsOption) *SessionsMutation { + m := &SessionsMutation{ + config: c, + op: op, + typ: TypeSessions, + clearedFields: make(map[string]struct{}), } - return *v, true + for _, opt := range opts { + opt(m) + } + return m } -// OldSMTPTLS returns the old "smtp_tls" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPTLS(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPTLS is only allowed on UpdateOne operations") +// withSessionsID sets the ID field of the mutation. +func withSessionsID(id string) sessionsOption { + return func(m *SessionsMutation) { + var ( + err error + once sync.Once + value *Sessions + ) + m.oldValue = func(ctx context.Context) (*Sessions, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Sessions.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPTLS requires an ID field in the mutation") +} + +// withSessions sets the old Sessions of the mutation. +func withSessions(node *Sessions) sessionsOption { + return func(m *SessionsMutation) { + m.oldValue = func(context.Context) (*Sessions, error) { + return node, nil + } + m.id = &node.ID } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPTLS: %w", err) +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m SessionsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m SessionsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") } - return oldValue.SMTPTLS, nil + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ClearSMTPTLS clears the value of the "smtp_tls" field. -func (m *SettingsMutation) ClearSMTPTLS() { - m.smtp_tls = nil - m.clearedFields[settings.FieldSMTPTLS] = struct{}{} +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Sessions entities. +func (m *SessionsMutation) SetID(id string) { + m.id = &id } -// SMTPTLSCleared returns if the "smtp_tls" field was cleared in this mutation. -func (m *SettingsMutation) SMTPTLSCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPTLS] - return ok +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *SessionsMutation) ID() (id string, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// ResetSMTPTLS resets all changes to the "smtp_tls" field. -func (m *SettingsMutation) ResetSMTPTLS() { - m.smtp_tls = nil - delete(m.clearedFields, settings.FieldSMTPTLS) +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *SessionsMutation) IDs(ctx context.Context) ([]string, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []string{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Sessions.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// SetSMTPStarttls sets the "smtp_starttls" field. -func (m *SettingsMutation) SetSMTPStarttls(b bool) { - m.smtp_starttls = &b +// SetData sets the "data" field. +func (m *SessionsMutation) SetData(b []byte) { + m.data = &b } -// SMTPStarttls returns the value of the "smtp_starttls" field in the mutation. -func (m *SettingsMutation) SMTPStarttls() (r bool, exists bool) { - v := m.smtp_starttls +// Data returns the value of the "data" field in the mutation. +func (m *SessionsMutation) Data() (r []byte, exists bool) { + v := m.data if v == nil { return } return *v, true } -// OldSMTPStarttls returns the old "smtp_starttls" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldData returns the old "data" field's value of the Sessions entity. +// If the Sessions object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSMTPStarttls(ctx context.Context) (v bool, err error) { +func (m *SessionsMutation) OldData(ctx context.Context) (v []byte, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSMTPStarttls is only allowed on UpdateOne operations") + return v, errors.New("OldData is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSMTPStarttls requires an ID field in the mutation") + return v, errors.New("OldData requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSMTPStarttls: %w", err) + return v, fmt.Errorf("querying old value for OldData: %w", err) } - return oldValue.SMTPStarttls, nil -} - -// ClearSMTPStarttls clears the value of the "smtp_starttls" field. -func (m *SettingsMutation) ClearSMTPStarttls() { - m.smtp_starttls = nil - m.clearedFields[settings.FieldSMTPStarttls] = struct{}{} -} - -// SMTPStarttlsCleared returns if the "smtp_starttls" field was cleared in this mutation. -func (m *SettingsMutation) SMTPStarttlsCleared() bool { - _, ok := m.clearedFields[settings.FieldSMTPStarttls] - return ok + return oldValue.Data, nil } -// ResetSMTPStarttls resets all changes to the "smtp_starttls" field. -func (m *SettingsMutation) ResetSMTPStarttls() { - m.smtp_starttls = nil - delete(m.clearedFields, settings.FieldSMTPStarttls) +// ResetData resets all changes to the "data" field. +func (m *SessionsMutation) ResetData() { + m.data = nil } -// SetNatsServer sets the "nats_server" field. -func (m *SettingsMutation) SetNatsServer(s string) { - m.nats_server = &s +// SetExpiry sets the "expiry" field. +func (m *SessionsMutation) SetExpiry(t time.Time) { + m.expiry = &t } -// NatsServer returns the value of the "nats_server" field in the mutation. -func (m *SettingsMutation) NatsServer() (r string, exists bool) { - v := m.nats_server +// Expiry returns the value of the "expiry" field in the mutation. +func (m *SessionsMutation) Expiry() (r time.Time, exists bool) { + v := m.expiry if v == nil { return } return *v, true } -// OldNatsServer returns the old "nats_server" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// OldExpiry returns the old "expiry" field's value of the Sessions entity. +// If the Sessions object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldNatsServer(ctx context.Context) (v string, err error) { +func (m *SessionsMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNatsServer is only allowed on UpdateOne operations") + return v, errors.New("OldExpiry is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNatsServer requires an ID field in the mutation") + return v, errors.New("OldExpiry requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNatsServer: %w", err) + return v, fmt.Errorf("querying old value for OldExpiry: %w", err) } - return oldValue.NatsServer, nil + return oldValue.Expiry, nil } -// ClearNatsServer clears the value of the "nats_server" field. -func (m *SettingsMutation) ClearNatsServer() { - m.nats_server = nil - m.clearedFields[settings.FieldNatsServer] = struct{}{} +// ResetExpiry resets all changes to the "expiry" field. +func (m *SessionsMutation) ResetExpiry() { + m.expiry = nil } -// NatsServerCleared returns if the "nats_server" field was cleared in this mutation. -func (m *SettingsMutation) NatsServerCleared() bool { - _, ok := m.clearedFields[settings.FieldNatsServer] - return ok +// SetOwnerID sets the "owner" edge to the User entity by id. +func (m *SessionsMutation) SetOwnerID(id string) { + m.owner = &id } -// ResetNatsServer resets all changes to the "nats_server" field. -func (m *SettingsMutation) ResetNatsServer() { - m.nats_server = nil - delete(m.clearedFields, settings.FieldNatsServer) +// ClearOwner clears the "owner" edge to the User entity. +func (m *SessionsMutation) ClearOwner() { + m.clearedowner = true } -// SetNatsPort sets the "nats_port" field. -func (m *SettingsMutation) SetNatsPort(s string) { - m.nats_port = &s +// OwnerCleared reports if the "owner" edge to the User entity was cleared. +func (m *SessionsMutation) OwnerCleared() bool { + return m.clearedowner } -// NatsPort returns the value of the "nats_port" field in the mutation. -func (m *SettingsMutation) NatsPort() (r string, exists bool) { - v := m.nats_port - if v == nil { - return +// OwnerID returns the "owner" edge ID in the mutation. +func (m *SessionsMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true } - return *v, true + return } -// OldNatsPort returns the old "nats_port" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldNatsPort(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNatsPort is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNatsPort requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldNatsPort: %w", err) +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *SessionsMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { + ids = append(ids, *id) } - return oldValue.NatsPort, nil + return } -// ClearNatsPort clears the value of the "nats_port" field. -func (m *SettingsMutation) ClearNatsPort() { - m.nats_port = nil - m.clearedFields[settings.FieldNatsPort] = struct{}{} +// ResetOwner resets all changes to the "owner" edge. +func (m *SessionsMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// NatsPortCleared returns if the "nats_port" field was cleared in this mutation. -func (m *SettingsMutation) NatsPortCleared() bool { - _, ok := m.clearedFields[settings.FieldNatsPort] - return ok +// Where appends a list predicates to the SessionsMutation builder. +func (m *SessionsMutation) Where(ps ...predicate.Sessions) { + m.predicates = append(m.predicates, ps...) } -// ResetNatsPort resets all changes to the "nats_port" field. -func (m *SettingsMutation) ResetNatsPort() { - m.nats_port = nil - delete(m.clearedFields, settings.FieldNatsPort) +// WhereP appends storage-level predicates to the SessionsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *SessionsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Sessions, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// SetMessageFrom sets the "message_from" field. -func (m *SettingsMutation) SetMessageFrom(s string) { - m.message_from = &s +// Op returns the operation name. +func (m *SessionsMutation) Op() Op { + return m.op } -// MessageFrom returns the value of the "message_from" field in the mutation. -func (m *SettingsMutation) MessageFrom() (r string, exists bool) { - v := m.message_from - if v == nil { - return - } - return *v, true +// SetOp allows setting the mutation operation. +func (m *SessionsMutation) SetOp(op Op) { + m.op = op } -// OldMessageFrom returns the old "message_from" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldMessageFrom(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMessageFrom is only allowed on UpdateOne operations") +// Type returns the node type of this mutation (Sessions). +func (m *SessionsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *SessionsMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.data != nil { + fields = append(fields, sessions.FieldData) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMessageFrom requires an ID field in the mutation") + if m.expiry != nil { + fields = append(fields, sessions.FieldExpiry) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMessageFrom: %w", err) + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *SessionsMutation) Field(name string) (ent.Value, bool) { + switch name { + case sessions.FieldData: + return m.Data() + case sessions.FieldExpiry: + return m.Expiry() } - return oldValue.MessageFrom, nil + return nil, false } -// ClearMessageFrom clears the value of the "message_from" field. -func (m *SettingsMutation) ClearMessageFrom() { - m.message_from = nil - m.clearedFields[settings.FieldMessageFrom] = struct{}{} +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *SessionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case sessions.FieldData: + return m.OldData(ctx) + case sessions.FieldExpiry: + return m.OldExpiry(ctx) + } + return nil, fmt.Errorf("unknown Sessions field %s", name) } -// MessageFromCleared returns if the "message_from" field was cleared in this mutation. -func (m *SettingsMutation) MessageFromCleared() bool { - _, ok := m.clearedFields[settings.FieldMessageFrom] - return ok +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SessionsMutation) SetField(name string, value ent.Value) error { + switch name { + case sessions.FieldData: + v, ok := value.([]byte) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetData(v) + return nil + case sessions.FieldExpiry: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExpiry(v) + return nil + } + return fmt.Errorf("unknown Sessions field %s", name) } -// ResetMessageFrom resets all changes to the "message_from" field. -func (m *SettingsMutation) ResetMessageFrom() { - m.message_from = nil - delete(m.clearedFields, settings.FieldMessageFrom) +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SessionsMutation) AddedFields() []string { + return nil } -// SetMaxUploadSize sets the "max_upload_size" field. -func (m *SettingsMutation) SetMaxUploadSize(s string) { - m.max_upload_size = &s +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *SessionsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// MaxUploadSize returns the value of the "max_upload_size" field in the mutation. -func (m *SettingsMutation) MaxUploadSize() (r string, exists bool) { - v := m.max_upload_size - if v == nil { - return +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SessionsMutation) AddField(name string, value ent.Value) error { + switch name { } - return *v, true + return fmt.Errorf("unknown Sessions numeric field %s", name) } -// OldMaxUploadSize returns the old "max_upload_size" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldMaxUploadSize(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMaxUploadSize is only allowed on UpdateOne operations") +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SessionsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SessionsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *SessionsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Sessions nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *SessionsMutation) ResetField(name string) error { + switch name { + case sessions.FieldData: + m.ResetData() + return nil + case sessions.FieldExpiry: + m.ResetExpiry() + return nil } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMaxUploadSize requires an ID field in the mutation") + return fmt.Errorf("unknown Sessions field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SessionsMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.owner != nil { + edges = append(edges, sessions.EdgeOwner) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMaxUploadSize: %w", err) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SessionsMutation) AddedIDs(name string) []ent.Value { + switch name { + case sessions.EdgeOwner: + if id := m.owner; id != nil { + return []ent.Value{*id} + } } - return oldValue.MaxUploadSize, nil + return nil } -// ClearMaxUploadSize clears the value of the "max_upload_size" field. -func (m *SettingsMutation) ClearMaxUploadSize() { - m.max_upload_size = nil - m.clearedFields[settings.FieldMaxUploadSize] = struct{}{} +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SessionsMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges } -// MaxUploadSizeCleared returns if the "max_upload_size" field was cleared in this mutation. -func (m *SettingsMutation) MaxUploadSizeCleared() bool { - _, ok := m.clearedFields[settings.FieldMaxUploadSize] - return ok +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *SessionsMutation) RemovedIDs(name string) []ent.Value { + return nil } -// ResetMaxUploadSize resets all changes to the "max_upload_size" field. -func (m *SettingsMutation) ResetMaxUploadSize() { - m.max_upload_size = nil - delete(m.clearedFields, settings.FieldMaxUploadSize) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SessionsMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedowner { + edges = append(edges, sessions.EdgeOwner) + } + return edges } -// SetUserCertYearsValid sets the "user_cert_years_valid" field. -func (m *SettingsMutation) SetUserCertYearsValid(i int) { - m.user_cert_years_valid = &i - m.adduser_cert_years_valid = nil +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SessionsMutation) EdgeCleared(name string) bool { + switch name { + case sessions.EdgeOwner: + return m.clearedowner + } + return false } -// UserCertYearsValid returns the value of the "user_cert_years_valid" field in the mutation. -func (m *SettingsMutation) UserCertYearsValid() (r int, exists bool) { - v := m.user_cert_years_valid - if v == nil { - return +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *SessionsMutation) ClearEdge(name string) error { + switch name { + case sessions.EdgeOwner: + m.ClearOwner() + return nil } - return *v, true + return fmt.Errorf("unknown Sessions unique edge %s", name) } -// OldUserCertYearsValid returns the old "user_cert_years_valid" field's value of the Settings entity. -// If the Settings object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldUserCertYearsValid(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserCertYearsValid is only allowed on UpdateOne operations") +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *SessionsMutation) ResetEdge(name string) error { + switch name { + case sessions.EdgeOwner: + m.ResetOwner() + return nil } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserCertYearsValid requires an ID field in the mutation") + return fmt.Errorf("unknown Sessions edge %s", name) +} + +// SettingsMutation represents an operation that mutates the Settings nodes in the graph. +type SettingsMutation struct { + config + op Op + typ string + id *int + language *string + organization *string + postal_address *string + postal_code *string + locality *string + province *string + state *string + country *string + smtp_server *string + smtp_port *int + addsmtp_port *int + smtp_user *string + smtp_password *string + smtp_auth *string + smtp_tls *bool + smtp_starttls *bool + nats_server *string + nats_port *string + message_from *string + max_upload_size *string + user_cert_years_valid *int + adduser_cert_years_valid *int + nats_request_timeout_seconds *int + addnats_request_timeout_seconds *int + refresh_time_in_minutes *int + addrefresh_time_in_minutes *int + session_lifetime_in_minutes *int + addsession_lifetime_in_minutes *int + update_channel *string + created *time.Time + modified *time.Time + agent_report_frequence_in_minutes *int + addagent_report_frequence_in_minutes *int + request_vnc_pin *bool + profiles_application_frequence_in_minutes *int + addprofiles_application_frequence_in_minutes *int + use_winget *bool + use_flatpak *bool + use_brew *bool + disable_sftp *bool + disable_remote_assistance *bool + detect_remote_agents *bool + auto_admit_agents *bool + default_items_per_page *int + adddefault_items_per_page *int + clearedFields map[string]struct{} + tag *int + clearedtag bool + tenant *int + clearedtenant bool + done bool + oldValue func(context.Context) (*Settings, error) + predicates []predicate.Settings +} + +var _ ent.Mutation = (*SettingsMutation)(nil) + +// settingsOption allows management of the mutation configuration using functional options. +type settingsOption func(*SettingsMutation) + +// newSettingsMutation creates new mutation for the Settings entity. +func newSettingsMutation(c config, op Op, opts ...settingsOption) *SettingsMutation { + m := &SettingsMutation{ + config: c, + op: op, + typ: TypeSettings, + clearedFields: make(map[string]struct{}), } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserCertYearsValid: %w", err) + for _, opt := range opts { + opt(m) } - return oldValue.UserCertYearsValid, nil + return m } -// AddUserCertYearsValid adds i to the "user_cert_years_valid" field. -func (m *SettingsMutation) AddUserCertYearsValid(i int) { - if m.adduser_cert_years_valid != nil { - *m.adduser_cert_years_valid += i - } else { - m.adduser_cert_years_valid = &i +// withSettingsID sets the ID field of the mutation. +func withSettingsID(id int) settingsOption { + return func(m *SettingsMutation) { + var ( + err error + once sync.Once + value *Settings + ) + m.oldValue = func(ctx context.Context) (*Settings, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Settings.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } } -// AddedUserCertYearsValid returns the value that was added to the "user_cert_years_valid" field in this mutation. -func (m *SettingsMutation) AddedUserCertYearsValid() (r int, exists bool) { - v := m.adduser_cert_years_valid - if v == nil { - return +// withSettings sets the old Settings of the mutation. +func withSettings(node *Settings) settingsOption { + return func(m *SettingsMutation) { + m.oldValue = func(context.Context) (*Settings, error) { + return node, nil + } + m.id = &node.ID } - return *v, true } -// ClearUserCertYearsValid clears the value of the "user_cert_years_valid" field. -func (m *SettingsMutation) ClearUserCertYearsValid() { - m.user_cert_years_valid = nil - m.adduser_cert_years_valid = nil - m.clearedFields[settings.FieldUserCertYearsValid] = struct{}{} +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m SettingsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// UserCertYearsValidCleared returns if the "user_cert_years_valid" field was cleared in this mutation. -func (m *SettingsMutation) UserCertYearsValidCleared() bool { - _, ok := m.clearedFields[settings.FieldUserCertYearsValid] - return ok +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m SettingsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetUserCertYearsValid resets all changes to the "user_cert_years_valid" field. -func (m *SettingsMutation) ResetUserCertYearsValid() { - m.user_cert_years_valid = nil - m.adduser_cert_years_valid = nil - delete(m.clearedFields, settings.FieldUserCertYearsValid) +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *SettingsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// SetNatsRequestTimeoutSeconds sets the "nats_request_timeout_seconds" field. -func (m *SettingsMutation) SetNatsRequestTimeoutSeconds(i int) { - m.nats_request_timeout_seconds = &i - m.addnats_request_timeout_seconds = nil +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *SettingsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Settings.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// NatsRequestTimeoutSeconds returns the value of the "nats_request_timeout_seconds" field in the mutation. -func (m *SettingsMutation) NatsRequestTimeoutSeconds() (r int, exists bool) { - v := m.nats_request_timeout_seconds +// SetLanguage sets the "language" field. +func (m *SettingsMutation) SetLanguage(s string) { + m.language = &s +} + +// Language returns the value of the "language" field in the mutation. +func (m *SettingsMutation) Language() (r string, exists bool) { + v := m.language if v == nil { return } return *v, true } -// OldNatsRequestTimeoutSeconds returns the old "nats_request_timeout_seconds" field's value of the Settings entity. +// OldLanguage returns the old "language" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldNatsRequestTimeoutSeconds(ctx context.Context) (v int, err error) { +func (m *SettingsMutation) OldLanguage(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNatsRequestTimeoutSeconds is only allowed on UpdateOne operations") + return v, errors.New("OldLanguage is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNatsRequestTimeoutSeconds requires an ID field in the mutation") + return v, errors.New("OldLanguage requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNatsRequestTimeoutSeconds: %w", err) - } - return oldValue.NatsRequestTimeoutSeconds, nil -} - -// AddNatsRequestTimeoutSeconds adds i to the "nats_request_timeout_seconds" field. -func (m *SettingsMutation) AddNatsRequestTimeoutSeconds(i int) { - if m.addnats_request_timeout_seconds != nil { - *m.addnats_request_timeout_seconds += i - } else { - m.addnats_request_timeout_seconds = &i - } -} - -// AddedNatsRequestTimeoutSeconds returns the value that was added to the "nats_request_timeout_seconds" field in this mutation. -func (m *SettingsMutation) AddedNatsRequestTimeoutSeconds() (r int, exists bool) { - v := m.addnats_request_timeout_seconds - if v == nil { - return + return v, fmt.Errorf("querying old value for OldLanguage: %w", err) } - return *v, true + return oldValue.Language, nil } -// ClearNatsRequestTimeoutSeconds clears the value of the "nats_request_timeout_seconds" field. -func (m *SettingsMutation) ClearNatsRequestTimeoutSeconds() { - m.nats_request_timeout_seconds = nil - m.addnats_request_timeout_seconds = nil - m.clearedFields[settings.FieldNatsRequestTimeoutSeconds] = struct{}{} +// ClearLanguage clears the value of the "language" field. +func (m *SettingsMutation) ClearLanguage() { + m.language = nil + m.clearedFields[settings.FieldLanguage] = struct{}{} } -// NatsRequestTimeoutSecondsCleared returns if the "nats_request_timeout_seconds" field was cleared in this mutation. -func (m *SettingsMutation) NatsRequestTimeoutSecondsCleared() bool { - _, ok := m.clearedFields[settings.FieldNatsRequestTimeoutSeconds] +// LanguageCleared returns if the "language" field was cleared in this mutation. +func (m *SettingsMutation) LanguageCleared() bool { + _, ok := m.clearedFields[settings.FieldLanguage] return ok } -// ResetNatsRequestTimeoutSeconds resets all changes to the "nats_request_timeout_seconds" field. -func (m *SettingsMutation) ResetNatsRequestTimeoutSeconds() { - m.nats_request_timeout_seconds = nil - m.addnats_request_timeout_seconds = nil - delete(m.clearedFields, settings.FieldNatsRequestTimeoutSeconds) +// ResetLanguage resets all changes to the "language" field. +func (m *SettingsMutation) ResetLanguage() { + m.language = nil + delete(m.clearedFields, settings.FieldLanguage) } -// SetRefreshTimeInMinutes sets the "refresh_time_in_minutes" field. -func (m *SettingsMutation) SetRefreshTimeInMinutes(i int) { - m.refresh_time_in_minutes = &i - m.addrefresh_time_in_minutes = nil +// SetOrganization sets the "organization" field. +func (m *SettingsMutation) SetOrganization(s string) { + m.organization = &s } -// RefreshTimeInMinutes returns the value of the "refresh_time_in_minutes" field in the mutation. -func (m *SettingsMutation) RefreshTimeInMinutes() (r int, exists bool) { - v := m.refresh_time_in_minutes +// Organization returns the value of the "organization" field in the mutation. +func (m *SettingsMutation) Organization() (r string, exists bool) { + v := m.organization if v == nil { return } return *v, true } -// OldRefreshTimeInMinutes returns the old "refresh_time_in_minutes" field's value of the Settings entity. +// OldOrganization returns the old "organization" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldRefreshTimeInMinutes(ctx context.Context) (v int, err error) { +func (m *SettingsMutation) OldOrganization(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRefreshTimeInMinutes is only allowed on UpdateOne operations") + return v, errors.New("OldOrganization is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRefreshTimeInMinutes requires an ID field in the mutation") + return v, errors.New("OldOrganization requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRefreshTimeInMinutes: %w", err) + return v, fmt.Errorf("querying old value for OldOrganization: %w", err) } - return oldValue.RefreshTimeInMinutes, nil + return oldValue.Organization, nil } -// AddRefreshTimeInMinutes adds i to the "refresh_time_in_minutes" field. -func (m *SettingsMutation) AddRefreshTimeInMinutes(i int) { - if m.addrefresh_time_in_minutes != nil { - *m.addrefresh_time_in_minutes += i - } else { - m.addrefresh_time_in_minutes = &i - } -} - -// AddedRefreshTimeInMinutes returns the value that was added to the "refresh_time_in_minutes" field in this mutation. -func (m *SettingsMutation) AddedRefreshTimeInMinutes() (r int, exists bool) { - v := m.addrefresh_time_in_minutes - if v == nil { - return - } - return *v, true -} - -// ClearRefreshTimeInMinutes clears the value of the "refresh_time_in_minutes" field. -func (m *SettingsMutation) ClearRefreshTimeInMinutes() { - m.refresh_time_in_minutes = nil - m.addrefresh_time_in_minutes = nil - m.clearedFields[settings.FieldRefreshTimeInMinutes] = struct{}{} +// ClearOrganization clears the value of the "organization" field. +func (m *SettingsMutation) ClearOrganization() { + m.organization = nil + m.clearedFields[settings.FieldOrganization] = struct{}{} } -// RefreshTimeInMinutesCleared returns if the "refresh_time_in_minutes" field was cleared in this mutation. -func (m *SettingsMutation) RefreshTimeInMinutesCleared() bool { - _, ok := m.clearedFields[settings.FieldRefreshTimeInMinutes] +// OrganizationCleared returns if the "organization" field was cleared in this mutation. +func (m *SettingsMutation) OrganizationCleared() bool { + _, ok := m.clearedFields[settings.FieldOrganization] return ok } -// ResetRefreshTimeInMinutes resets all changes to the "refresh_time_in_minutes" field. -func (m *SettingsMutation) ResetRefreshTimeInMinutes() { - m.refresh_time_in_minutes = nil - m.addrefresh_time_in_minutes = nil - delete(m.clearedFields, settings.FieldRefreshTimeInMinutes) +// ResetOrganization resets all changes to the "organization" field. +func (m *SettingsMutation) ResetOrganization() { + m.organization = nil + delete(m.clearedFields, settings.FieldOrganization) } -// SetSessionLifetimeInMinutes sets the "session_lifetime_in_minutes" field. -func (m *SettingsMutation) SetSessionLifetimeInMinutes(i int) { - m.session_lifetime_in_minutes = &i - m.addsession_lifetime_in_minutes = nil +// SetPostalAddress sets the "postal_address" field. +func (m *SettingsMutation) SetPostalAddress(s string) { + m.postal_address = &s } -// SessionLifetimeInMinutes returns the value of the "session_lifetime_in_minutes" field in the mutation. -func (m *SettingsMutation) SessionLifetimeInMinutes() (r int, exists bool) { - v := m.session_lifetime_in_minutes +// PostalAddress returns the value of the "postal_address" field in the mutation. +func (m *SettingsMutation) PostalAddress() (r string, exists bool) { + v := m.postal_address if v == nil { return } return *v, true } -// OldSessionLifetimeInMinutes returns the old "session_lifetime_in_minutes" field's value of the Settings entity. +// OldPostalAddress returns the old "postal_address" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldSessionLifetimeInMinutes(ctx context.Context) (v int, err error) { +func (m *SettingsMutation) OldPostalAddress(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSessionLifetimeInMinutes is only allowed on UpdateOne operations") + return v, errors.New("OldPostalAddress is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSessionLifetimeInMinutes requires an ID field in the mutation") + return v, errors.New("OldPostalAddress requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSessionLifetimeInMinutes: %w", err) - } - return oldValue.SessionLifetimeInMinutes, nil -} - -// AddSessionLifetimeInMinutes adds i to the "session_lifetime_in_minutes" field. -func (m *SettingsMutation) AddSessionLifetimeInMinutes(i int) { - if m.addsession_lifetime_in_minutes != nil { - *m.addsession_lifetime_in_minutes += i - } else { - m.addsession_lifetime_in_minutes = &i - } -} - -// AddedSessionLifetimeInMinutes returns the value that was added to the "session_lifetime_in_minutes" field in this mutation. -func (m *SettingsMutation) AddedSessionLifetimeInMinutes() (r int, exists bool) { - v := m.addsession_lifetime_in_minutes - if v == nil { - return + return v, fmt.Errorf("querying old value for OldPostalAddress: %w", err) } - return *v, true + return oldValue.PostalAddress, nil } -// ClearSessionLifetimeInMinutes clears the value of the "session_lifetime_in_minutes" field. -func (m *SettingsMutation) ClearSessionLifetimeInMinutes() { - m.session_lifetime_in_minutes = nil - m.addsession_lifetime_in_minutes = nil - m.clearedFields[settings.FieldSessionLifetimeInMinutes] = struct{}{} +// ClearPostalAddress clears the value of the "postal_address" field. +func (m *SettingsMutation) ClearPostalAddress() { + m.postal_address = nil + m.clearedFields[settings.FieldPostalAddress] = struct{}{} } -// SessionLifetimeInMinutesCleared returns if the "session_lifetime_in_minutes" field was cleared in this mutation. -func (m *SettingsMutation) SessionLifetimeInMinutesCleared() bool { - _, ok := m.clearedFields[settings.FieldSessionLifetimeInMinutes] +// PostalAddressCleared returns if the "postal_address" field was cleared in this mutation. +func (m *SettingsMutation) PostalAddressCleared() bool { + _, ok := m.clearedFields[settings.FieldPostalAddress] return ok } -// ResetSessionLifetimeInMinutes resets all changes to the "session_lifetime_in_minutes" field. -func (m *SettingsMutation) ResetSessionLifetimeInMinutes() { - m.session_lifetime_in_minutes = nil - m.addsession_lifetime_in_minutes = nil - delete(m.clearedFields, settings.FieldSessionLifetimeInMinutes) +// ResetPostalAddress resets all changes to the "postal_address" field. +func (m *SettingsMutation) ResetPostalAddress() { + m.postal_address = nil + delete(m.clearedFields, settings.FieldPostalAddress) } -// SetUpdateChannel sets the "update_channel" field. -func (m *SettingsMutation) SetUpdateChannel(s string) { - m.update_channel = &s +// SetPostalCode sets the "postal_code" field. +func (m *SettingsMutation) SetPostalCode(s string) { + m.postal_code = &s } -// UpdateChannel returns the value of the "update_channel" field in the mutation. -func (m *SettingsMutation) UpdateChannel() (r string, exists bool) { - v := m.update_channel +// PostalCode returns the value of the "postal_code" field in the mutation. +func (m *SettingsMutation) PostalCode() (r string, exists bool) { + v := m.postal_code if v == nil { return } return *v, true } -// OldUpdateChannel returns the old "update_channel" field's value of the Settings entity. +// OldPostalCode returns the old "postal_code" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldUpdateChannel(ctx context.Context) (v string, err error) { +func (m *SettingsMutation) OldPostalCode(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateChannel is only allowed on UpdateOne operations") + return v, errors.New("OldPostalCode is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateChannel requires an ID field in the mutation") + return v, errors.New("OldPostalCode requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateChannel: %w", err) + return v, fmt.Errorf("querying old value for OldPostalCode: %w", err) } - return oldValue.UpdateChannel, nil + return oldValue.PostalCode, nil } -// ClearUpdateChannel clears the value of the "update_channel" field. -func (m *SettingsMutation) ClearUpdateChannel() { - m.update_channel = nil - m.clearedFields[settings.FieldUpdateChannel] = struct{}{} +// ClearPostalCode clears the value of the "postal_code" field. +func (m *SettingsMutation) ClearPostalCode() { + m.postal_code = nil + m.clearedFields[settings.FieldPostalCode] = struct{}{} } -// UpdateChannelCleared returns if the "update_channel" field was cleared in this mutation. -func (m *SettingsMutation) UpdateChannelCleared() bool { - _, ok := m.clearedFields[settings.FieldUpdateChannel] +// PostalCodeCleared returns if the "postal_code" field was cleared in this mutation. +func (m *SettingsMutation) PostalCodeCleared() bool { + _, ok := m.clearedFields[settings.FieldPostalCode] return ok } -// ResetUpdateChannel resets all changes to the "update_channel" field. -func (m *SettingsMutation) ResetUpdateChannel() { - m.update_channel = nil - delete(m.clearedFields, settings.FieldUpdateChannel) +// ResetPostalCode resets all changes to the "postal_code" field. +func (m *SettingsMutation) ResetPostalCode() { + m.postal_code = nil + delete(m.clearedFields, settings.FieldPostalCode) } -// SetCreated sets the "created" field. -func (m *SettingsMutation) SetCreated(t time.Time) { - m.created = &t +// SetLocality sets the "locality" field. +func (m *SettingsMutation) SetLocality(s string) { + m.locality = &s } -// Created returns the value of the "created" field in the mutation. -func (m *SettingsMutation) Created() (r time.Time, exists bool) { - v := m.created +// Locality returns the value of the "locality" field in the mutation. +func (m *SettingsMutation) Locality() (r string, exists bool) { + v := m.locality if v == nil { return } return *v, true } -// OldCreated returns the old "created" field's value of the Settings entity. +// OldLocality returns the old "locality" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldCreated(ctx context.Context) (v time.Time, err error) { +func (m *SettingsMutation) OldLocality(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreated is only allowed on UpdateOne operations") + return v, errors.New("OldLocality is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreated requires an ID field in the mutation") + return v, errors.New("OldLocality requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreated: %w", err) + return v, fmt.Errorf("querying old value for OldLocality: %w", err) } - return oldValue.Created, nil + return oldValue.Locality, nil } -// ClearCreated clears the value of the "created" field. -func (m *SettingsMutation) ClearCreated() { - m.created = nil - m.clearedFields[settings.FieldCreated] = struct{}{} +// ClearLocality clears the value of the "locality" field. +func (m *SettingsMutation) ClearLocality() { + m.locality = nil + m.clearedFields[settings.FieldLocality] = struct{}{} } -// CreatedCleared returns if the "created" field was cleared in this mutation. -func (m *SettingsMutation) CreatedCleared() bool { - _, ok := m.clearedFields[settings.FieldCreated] +// LocalityCleared returns if the "locality" field was cleared in this mutation. +func (m *SettingsMutation) LocalityCleared() bool { + _, ok := m.clearedFields[settings.FieldLocality] return ok } -// ResetCreated resets all changes to the "created" field. -func (m *SettingsMutation) ResetCreated() { - m.created = nil - delete(m.clearedFields, settings.FieldCreated) +// ResetLocality resets all changes to the "locality" field. +func (m *SettingsMutation) ResetLocality() { + m.locality = nil + delete(m.clearedFields, settings.FieldLocality) } -// SetModified sets the "modified" field. -func (m *SettingsMutation) SetModified(t time.Time) { - m.modified = &t +// SetProvince sets the "province" field. +func (m *SettingsMutation) SetProvince(s string) { + m.province = &s } -// Modified returns the value of the "modified" field in the mutation. -func (m *SettingsMutation) Modified() (r time.Time, exists bool) { - v := m.modified +// Province returns the value of the "province" field in the mutation. +func (m *SettingsMutation) Province() (r string, exists bool) { + v := m.province if v == nil { return } return *v, true } -// OldModified returns the old "modified" field's value of the Settings entity. +// OldProvince returns the old "province" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldModified(ctx context.Context) (v time.Time, err error) { +func (m *SettingsMutation) OldProvince(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModified is only allowed on UpdateOne operations") + return v, errors.New("OldProvince is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModified requires an ID field in the mutation") + return v, errors.New("OldProvince requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldModified: %w", err) + return v, fmt.Errorf("querying old value for OldProvince: %w", err) } - return oldValue.Modified, nil + return oldValue.Province, nil } -// ClearModified clears the value of the "modified" field. -func (m *SettingsMutation) ClearModified() { - m.modified = nil - m.clearedFields[settings.FieldModified] = struct{}{} +// ClearProvince clears the value of the "province" field. +func (m *SettingsMutation) ClearProvince() { + m.province = nil + m.clearedFields[settings.FieldProvince] = struct{}{} } -// ModifiedCleared returns if the "modified" field was cleared in this mutation. -func (m *SettingsMutation) ModifiedCleared() bool { - _, ok := m.clearedFields[settings.FieldModified] +// ProvinceCleared returns if the "province" field was cleared in this mutation. +func (m *SettingsMutation) ProvinceCleared() bool { + _, ok := m.clearedFields[settings.FieldProvince] return ok } -// ResetModified resets all changes to the "modified" field. -func (m *SettingsMutation) ResetModified() { - m.modified = nil - delete(m.clearedFields, settings.FieldModified) +// ResetProvince resets all changes to the "province" field. +func (m *SettingsMutation) ResetProvince() { + m.province = nil + delete(m.clearedFields, settings.FieldProvince) } -// SetAgentReportFrequenceInMinutes sets the "agent_report_frequence_in_minutes" field. -func (m *SettingsMutation) SetAgentReportFrequenceInMinutes(i int) { - m.agent_report_frequence_in_minutes = &i - m.addagent_report_frequence_in_minutes = nil +// SetState sets the "state" field. +func (m *SettingsMutation) SetState(s string) { + m.state = &s } -// AgentReportFrequenceInMinutes returns the value of the "agent_report_frequence_in_minutes" field in the mutation. -func (m *SettingsMutation) AgentReportFrequenceInMinutes() (r int, exists bool) { - v := m.agent_report_frequence_in_minutes +// State returns the value of the "state" field in the mutation. +func (m *SettingsMutation) State() (r string, exists bool) { + v := m.state if v == nil { return } return *v, true } -// OldAgentReportFrequenceInMinutes returns the old "agent_report_frequence_in_minutes" field's value of the Settings entity. +// OldState returns the old "state" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldAgentReportFrequenceInMinutes(ctx context.Context) (v int, err error) { +func (m *SettingsMutation) OldState(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAgentReportFrequenceInMinutes is only allowed on UpdateOne operations") + return v, errors.New("OldState is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAgentReportFrequenceInMinutes requires an ID field in the mutation") + return v, errors.New("OldState requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAgentReportFrequenceInMinutes: %w", err) + return v, fmt.Errorf("querying old value for OldState: %w", err) } - return oldValue.AgentReportFrequenceInMinutes, nil + return oldValue.State, nil } -// AddAgentReportFrequenceInMinutes adds i to the "agent_report_frequence_in_minutes" field. -func (m *SettingsMutation) AddAgentReportFrequenceInMinutes(i int) { - if m.addagent_report_frequence_in_minutes != nil { - *m.addagent_report_frequence_in_minutes += i - } else { - m.addagent_report_frequence_in_minutes = &i - } +// ClearState clears the value of the "state" field. +func (m *SettingsMutation) ClearState() { + m.state = nil + m.clearedFields[settings.FieldState] = struct{}{} } -// AddedAgentReportFrequenceInMinutes returns the value that was added to the "agent_report_frequence_in_minutes" field in this mutation. -func (m *SettingsMutation) AddedAgentReportFrequenceInMinutes() (r int, exists bool) { - v := m.addagent_report_frequence_in_minutes +// StateCleared returns if the "state" field was cleared in this mutation. +func (m *SettingsMutation) StateCleared() bool { + _, ok := m.clearedFields[settings.FieldState] + return ok +} + +// ResetState resets all changes to the "state" field. +func (m *SettingsMutation) ResetState() { + m.state = nil + delete(m.clearedFields, settings.FieldState) +} + +// SetCountry sets the "country" field. +func (m *SettingsMutation) SetCountry(s string) { + m.country = &s +} + +// Country returns the value of the "country" field in the mutation. +func (m *SettingsMutation) Country() (r string, exists bool) { + v := m.country if v == nil { return } return *v, true } -// ClearAgentReportFrequenceInMinutes clears the value of the "agent_report_frequence_in_minutes" field. -func (m *SettingsMutation) ClearAgentReportFrequenceInMinutes() { - m.agent_report_frequence_in_minutes = nil - m.addagent_report_frequence_in_minutes = nil - m.clearedFields[settings.FieldAgentReportFrequenceInMinutes] = struct{}{} +// OldCountry returns the old "country" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldCountry(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCountry is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCountry requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCountry: %w", err) + } + return oldValue.Country, nil } -// AgentReportFrequenceInMinutesCleared returns if the "agent_report_frequence_in_minutes" field was cleared in this mutation. -func (m *SettingsMutation) AgentReportFrequenceInMinutesCleared() bool { - _, ok := m.clearedFields[settings.FieldAgentReportFrequenceInMinutes] +// ClearCountry clears the value of the "country" field. +func (m *SettingsMutation) ClearCountry() { + m.country = nil + m.clearedFields[settings.FieldCountry] = struct{}{} +} + +// CountryCleared returns if the "country" field was cleared in this mutation. +func (m *SettingsMutation) CountryCleared() bool { + _, ok := m.clearedFields[settings.FieldCountry] return ok } -// ResetAgentReportFrequenceInMinutes resets all changes to the "agent_report_frequence_in_minutes" field. -func (m *SettingsMutation) ResetAgentReportFrequenceInMinutes() { - m.agent_report_frequence_in_minutes = nil - m.addagent_report_frequence_in_minutes = nil - delete(m.clearedFields, settings.FieldAgentReportFrequenceInMinutes) +// ResetCountry resets all changes to the "country" field. +func (m *SettingsMutation) ResetCountry() { + m.country = nil + delete(m.clearedFields, settings.FieldCountry) } -// SetRequestVncPin sets the "request_vnc_pin" field. -func (m *SettingsMutation) SetRequestVncPin(b bool) { - m.request_vnc_pin = &b +// SetSMTPServer sets the "smtp_server" field. +func (m *SettingsMutation) SetSMTPServer(s string) { + m.smtp_server = &s } -// RequestVncPin returns the value of the "request_vnc_pin" field in the mutation. -func (m *SettingsMutation) RequestVncPin() (r bool, exists bool) { - v := m.request_vnc_pin +// SMTPServer returns the value of the "smtp_server" field in the mutation. +func (m *SettingsMutation) SMTPServer() (r string, exists bool) { + v := m.smtp_server if v == nil { return } return *v, true } -// OldRequestVncPin returns the old "request_vnc_pin" field's value of the Settings entity. +// OldSMTPServer returns the old "smtp_server" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldRequestVncPin(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldSMTPServer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRequestVncPin is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPServer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRequestVncPin requires an ID field in the mutation") + return v, errors.New("OldSMTPServer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRequestVncPin: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPServer: %w", err) } - return oldValue.RequestVncPin, nil + return oldValue.SMTPServer, nil } -// ClearRequestVncPin clears the value of the "request_vnc_pin" field. -func (m *SettingsMutation) ClearRequestVncPin() { - m.request_vnc_pin = nil - m.clearedFields[settings.FieldRequestVncPin] = struct{}{} +// ClearSMTPServer clears the value of the "smtp_server" field. +func (m *SettingsMutation) ClearSMTPServer() { + m.smtp_server = nil + m.clearedFields[settings.FieldSMTPServer] = struct{}{} } -// RequestVncPinCleared returns if the "request_vnc_pin" field was cleared in this mutation. -func (m *SettingsMutation) RequestVncPinCleared() bool { - _, ok := m.clearedFields[settings.FieldRequestVncPin] +// SMTPServerCleared returns if the "smtp_server" field was cleared in this mutation. +func (m *SettingsMutation) SMTPServerCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPServer] return ok } -// ResetRequestVncPin resets all changes to the "request_vnc_pin" field. -func (m *SettingsMutation) ResetRequestVncPin() { - m.request_vnc_pin = nil - delete(m.clearedFields, settings.FieldRequestVncPin) +// ResetSMTPServer resets all changes to the "smtp_server" field. +func (m *SettingsMutation) ResetSMTPServer() { + m.smtp_server = nil + delete(m.clearedFields, settings.FieldSMTPServer) } -// SetProfilesApplicationFrequenceInMinutes sets the "profiles_application_frequence_in_minutes" field. -func (m *SettingsMutation) SetProfilesApplicationFrequenceInMinutes(i int) { - m.profiles_application_frequence_in_minutes = &i - m.addprofiles_application_frequence_in_minutes = nil +// SetSMTPPort sets the "smtp_port" field. +func (m *SettingsMutation) SetSMTPPort(i int) { + m.smtp_port = &i + m.addsmtp_port = nil } -// ProfilesApplicationFrequenceInMinutes returns the value of the "profiles_application_frequence_in_minutes" field in the mutation. -func (m *SettingsMutation) ProfilesApplicationFrequenceInMinutes() (r int, exists bool) { - v := m.profiles_application_frequence_in_minutes +// SMTPPort returns the value of the "smtp_port" field in the mutation. +func (m *SettingsMutation) SMTPPort() (r int, exists bool) { + v := m.smtp_port if v == nil { return } return *v, true } -// OldProfilesApplicationFrequenceInMinutes returns the old "profiles_application_frequence_in_minutes" field's value of the Settings entity. +// OldSMTPPort returns the old "smtp_port" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldProfilesApplicationFrequenceInMinutes(ctx context.Context) (v int, err error) { +func (m *SettingsMutation) OldSMTPPort(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProfilesApplicationFrequenceInMinutes is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPPort is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProfilesApplicationFrequenceInMinutes requires an ID field in the mutation") + return v, errors.New("OldSMTPPort requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProfilesApplicationFrequenceInMinutes: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPPort: %w", err) } - return oldValue.ProfilesApplicationFrequenceInMinutes, nil + return oldValue.SMTPPort, nil } -// AddProfilesApplicationFrequenceInMinutes adds i to the "profiles_application_frequence_in_minutes" field. -func (m *SettingsMutation) AddProfilesApplicationFrequenceInMinutes(i int) { - if m.addprofiles_application_frequence_in_minutes != nil { - *m.addprofiles_application_frequence_in_minutes += i +// AddSMTPPort adds i to the "smtp_port" field. +func (m *SettingsMutation) AddSMTPPort(i int) { + if m.addsmtp_port != nil { + *m.addsmtp_port += i } else { - m.addprofiles_application_frequence_in_minutes = &i + m.addsmtp_port = &i } } -// AddedProfilesApplicationFrequenceInMinutes returns the value that was added to the "profiles_application_frequence_in_minutes" field in this mutation. -func (m *SettingsMutation) AddedProfilesApplicationFrequenceInMinutes() (r int, exists bool) { - v := m.addprofiles_application_frequence_in_minutes +// AddedSMTPPort returns the value that was added to the "smtp_port" field in this mutation. +func (m *SettingsMutation) AddedSMTPPort() (r int, exists bool) { + v := m.addsmtp_port if v == nil { return } return *v, true } -// ClearProfilesApplicationFrequenceInMinutes clears the value of the "profiles_application_frequence_in_minutes" field. -func (m *SettingsMutation) ClearProfilesApplicationFrequenceInMinutes() { - m.profiles_application_frequence_in_minutes = nil - m.addprofiles_application_frequence_in_minutes = nil - m.clearedFields[settings.FieldProfilesApplicationFrequenceInMinutes] = struct{}{} +// ClearSMTPPort clears the value of the "smtp_port" field. +func (m *SettingsMutation) ClearSMTPPort() { + m.smtp_port = nil + m.addsmtp_port = nil + m.clearedFields[settings.FieldSMTPPort] = struct{}{} } -// ProfilesApplicationFrequenceInMinutesCleared returns if the "profiles_application_frequence_in_minutes" field was cleared in this mutation. -func (m *SettingsMutation) ProfilesApplicationFrequenceInMinutesCleared() bool { - _, ok := m.clearedFields[settings.FieldProfilesApplicationFrequenceInMinutes] +// SMTPPortCleared returns if the "smtp_port" field was cleared in this mutation. +func (m *SettingsMutation) SMTPPortCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPPort] return ok } -// ResetProfilesApplicationFrequenceInMinutes resets all changes to the "profiles_application_frequence_in_minutes" field. -func (m *SettingsMutation) ResetProfilesApplicationFrequenceInMinutes() { - m.profiles_application_frequence_in_minutes = nil - m.addprofiles_application_frequence_in_minutes = nil - delete(m.clearedFields, settings.FieldProfilesApplicationFrequenceInMinutes) +// ResetSMTPPort resets all changes to the "smtp_port" field. +func (m *SettingsMutation) ResetSMTPPort() { + m.smtp_port = nil + m.addsmtp_port = nil + delete(m.clearedFields, settings.FieldSMTPPort) } -// SetUseWinget sets the "use_winget" field. -func (m *SettingsMutation) SetUseWinget(b bool) { - m.use_winget = &b +// SetSMTPUser sets the "smtp_user" field. +func (m *SettingsMutation) SetSMTPUser(s string) { + m.smtp_user = &s } -// UseWinget returns the value of the "use_winget" field in the mutation. -func (m *SettingsMutation) UseWinget() (r bool, exists bool) { - v := m.use_winget +// SMTPUser returns the value of the "smtp_user" field in the mutation. +func (m *SettingsMutation) SMTPUser() (r string, exists bool) { + v := m.smtp_user if v == nil { return } return *v, true } -// OldUseWinget returns the old "use_winget" field's value of the Settings entity. +// OldSMTPUser returns the old "smtp_user" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldUseWinget(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldSMTPUser(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUseWinget is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPUser is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUseWinget requires an ID field in the mutation") + return v, errors.New("OldSMTPUser requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUseWinget: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPUser: %w", err) } - return oldValue.UseWinget, nil + return oldValue.SMTPUser, nil } -// ClearUseWinget clears the value of the "use_winget" field. -func (m *SettingsMutation) ClearUseWinget() { - m.use_winget = nil - m.clearedFields[settings.FieldUseWinget] = struct{}{} +// ClearSMTPUser clears the value of the "smtp_user" field. +func (m *SettingsMutation) ClearSMTPUser() { + m.smtp_user = nil + m.clearedFields[settings.FieldSMTPUser] = struct{}{} } -// UseWingetCleared returns if the "use_winget" field was cleared in this mutation. -func (m *SettingsMutation) UseWingetCleared() bool { - _, ok := m.clearedFields[settings.FieldUseWinget] +// SMTPUserCleared returns if the "smtp_user" field was cleared in this mutation. +func (m *SettingsMutation) SMTPUserCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPUser] return ok } -// ResetUseWinget resets all changes to the "use_winget" field. -func (m *SettingsMutation) ResetUseWinget() { - m.use_winget = nil - delete(m.clearedFields, settings.FieldUseWinget) +// ResetSMTPUser resets all changes to the "smtp_user" field. +func (m *SettingsMutation) ResetSMTPUser() { + m.smtp_user = nil + delete(m.clearedFields, settings.FieldSMTPUser) } -// SetUseFlatpak sets the "use_flatpak" field. -func (m *SettingsMutation) SetUseFlatpak(b bool) { - m.use_flatpak = &b +// SetSMTPPassword sets the "smtp_password" field. +func (m *SettingsMutation) SetSMTPPassword(s string) { + m.smtp_password = &s } -// UseFlatpak returns the value of the "use_flatpak" field in the mutation. -func (m *SettingsMutation) UseFlatpak() (r bool, exists bool) { - v := m.use_flatpak +// SMTPPassword returns the value of the "smtp_password" field in the mutation. +func (m *SettingsMutation) SMTPPassword() (r string, exists bool) { + v := m.smtp_password if v == nil { return } return *v, true } -// OldUseFlatpak returns the old "use_flatpak" field's value of the Settings entity. +// OldSMTPPassword returns the old "smtp_password" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldUseFlatpak(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldSMTPPassword(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUseFlatpak is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPPassword is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUseFlatpak requires an ID field in the mutation") + return v, errors.New("OldSMTPPassword requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUseFlatpak: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPPassword: %w", err) } - return oldValue.UseFlatpak, nil + return oldValue.SMTPPassword, nil } -// ClearUseFlatpak clears the value of the "use_flatpak" field. -func (m *SettingsMutation) ClearUseFlatpak() { - m.use_flatpak = nil - m.clearedFields[settings.FieldUseFlatpak] = struct{}{} +// ClearSMTPPassword clears the value of the "smtp_password" field. +func (m *SettingsMutation) ClearSMTPPassword() { + m.smtp_password = nil + m.clearedFields[settings.FieldSMTPPassword] = struct{}{} } -// UseFlatpakCleared returns if the "use_flatpak" field was cleared in this mutation. -func (m *SettingsMutation) UseFlatpakCleared() bool { - _, ok := m.clearedFields[settings.FieldUseFlatpak] +// SMTPPasswordCleared returns if the "smtp_password" field was cleared in this mutation. +func (m *SettingsMutation) SMTPPasswordCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPPassword] return ok } -// ResetUseFlatpak resets all changes to the "use_flatpak" field. -func (m *SettingsMutation) ResetUseFlatpak() { - m.use_flatpak = nil - delete(m.clearedFields, settings.FieldUseFlatpak) +// ResetSMTPPassword resets all changes to the "smtp_password" field. +func (m *SettingsMutation) ResetSMTPPassword() { + m.smtp_password = nil + delete(m.clearedFields, settings.FieldSMTPPassword) } -// SetUseBrew sets the "use_brew" field. -func (m *SettingsMutation) SetUseBrew(b bool) { - m.use_brew = &b +// SetSMTPAuth sets the "smtp_auth" field. +func (m *SettingsMutation) SetSMTPAuth(s string) { + m.smtp_auth = &s } -// UseBrew returns the value of the "use_brew" field in the mutation. -func (m *SettingsMutation) UseBrew() (r bool, exists bool) { - v := m.use_brew +// SMTPAuth returns the value of the "smtp_auth" field in the mutation. +func (m *SettingsMutation) SMTPAuth() (r string, exists bool) { + v := m.smtp_auth if v == nil { return } return *v, true } -// OldUseBrew returns the old "use_brew" field's value of the Settings entity. +// OldSMTPAuth returns the old "smtp_auth" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldUseBrew(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldSMTPAuth(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUseBrew is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPAuth is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUseBrew requires an ID field in the mutation") + return v, errors.New("OldSMTPAuth requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUseBrew: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPAuth: %w", err) } - return oldValue.UseBrew, nil + return oldValue.SMTPAuth, nil } -// ClearUseBrew clears the value of the "use_brew" field. -func (m *SettingsMutation) ClearUseBrew() { - m.use_brew = nil - m.clearedFields[settings.FieldUseBrew] = struct{}{} +// ClearSMTPAuth clears the value of the "smtp_auth" field. +func (m *SettingsMutation) ClearSMTPAuth() { + m.smtp_auth = nil + m.clearedFields[settings.FieldSMTPAuth] = struct{}{} } -// UseBrewCleared returns if the "use_brew" field was cleared in this mutation. -func (m *SettingsMutation) UseBrewCleared() bool { - _, ok := m.clearedFields[settings.FieldUseBrew] +// SMTPAuthCleared returns if the "smtp_auth" field was cleared in this mutation. +func (m *SettingsMutation) SMTPAuthCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPAuth] return ok } -// ResetUseBrew resets all changes to the "use_brew" field. -func (m *SettingsMutation) ResetUseBrew() { - m.use_brew = nil - delete(m.clearedFields, settings.FieldUseBrew) +// ResetSMTPAuth resets all changes to the "smtp_auth" field. +func (m *SettingsMutation) ResetSMTPAuth() { + m.smtp_auth = nil + delete(m.clearedFields, settings.FieldSMTPAuth) } -// SetDisableSftp sets the "disable_sftp" field. -func (m *SettingsMutation) SetDisableSftp(b bool) { - m.disable_sftp = &b +// SetSMTPTLS sets the "smtp_tls" field. +func (m *SettingsMutation) SetSMTPTLS(b bool) { + m.smtp_tls = &b } -// DisableSftp returns the value of the "disable_sftp" field in the mutation. -func (m *SettingsMutation) DisableSftp() (r bool, exists bool) { - v := m.disable_sftp +// SMTPTLS returns the value of the "smtp_tls" field in the mutation. +func (m *SettingsMutation) SMTPTLS() (r bool, exists bool) { + v := m.smtp_tls if v == nil { return } return *v, true } -// OldDisableSftp returns the old "disable_sftp" field's value of the Settings entity. +// OldSMTPTLS returns the old "smtp_tls" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldDisableSftp(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldSMTPTLS(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDisableSftp is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPTLS is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDisableSftp requires an ID field in the mutation") + return v, errors.New("OldSMTPTLS requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDisableSftp: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPTLS: %w", err) } - return oldValue.DisableSftp, nil + return oldValue.SMTPTLS, nil } -// ClearDisableSftp clears the value of the "disable_sftp" field. -func (m *SettingsMutation) ClearDisableSftp() { - m.disable_sftp = nil - m.clearedFields[settings.FieldDisableSftp] = struct{}{} +// ClearSMTPTLS clears the value of the "smtp_tls" field. +func (m *SettingsMutation) ClearSMTPTLS() { + m.smtp_tls = nil + m.clearedFields[settings.FieldSMTPTLS] = struct{}{} } -// DisableSftpCleared returns if the "disable_sftp" field was cleared in this mutation. -func (m *SettingsMutation) DisableSftpCleared() bool { - _, ok := m.clearedFields[settings.FieldDisableSftp] +// SMTPTLSCleared returns if the "smtp_tls" field was cleared in this mutation. +func (m *SettingsMutation) SMTPTLSCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPTLS] return ok } -// ResetDisableSftp resets all changes to the "disable_sftp" field. -func (m *SettingsMutation) ResetDisableSftp() { - m.disable_sftp = nil - delete(m.clearedFields, settings.FieldDisableSftp) +// ResetSMTPTLS resets all changes to the "smtp_tls" field. +func (m *SettingsMutation) ResetSMTPTLS() { + m.smtp_tls = nil + delete(m.clearedFields, settings.FieldSMTPTLS) } -// SetDisableRemoteAssistance sets the "disable_remote_assistance" field. -func (m *SettingsMutation) SetDisableRemoteAssistance(b bool) { - m.disable_remote_assistance = &b +// SetSMTPStarttls sets the "smtp_starttls" field. +func (m *SettingsMutation) SetSMTPStarttls(b bool) { + m.smtp_starttls = &b } -// DisableRemoteAssistance returns the value of the "disable_remote_assistance" field in the mutation. -func (m *SettingsMutation) DisableRemoteAssistance() (r bool, exists bool) { - v := m.disable_remote_assistance +// SMTPStarttls returns the value of the "smtp_starttls" field in the mutation. +func (m *SettingsMutation) SMTPStarttls() (r bool, exists bool) { + v := m.smtp_starttls if v == nil { return } return *v, true } -// OldDisableRemoteAssistance returns the old "disable_remote_assistance" field's value of the Settings entity. +// OldSMTPStarttls returns the old "smtp_starttls" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldDisableRemoteAssistance(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldSMTPStarttls(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDisableRemoteAssistance is only allowed on UpdateOne operations") + return v, errors.New("OldSMTPStarttls is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDisableRemoteAssistance requires an ID field in the mutation") + return v, errors.New("OldSMTPStarttls requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDisableRemoteAssistance: %w", err) + return v, fmt.Errorf("querying old value for OldSMTPStarttls: %w", err) } - return oldValue.DisableRemoteAssistance, nil + return oldValue.SMTPStarttls, nil } -// ClearDisableRemoteAssistance clears the value of the "disable_remote_assistance" field. -func (m *SettingsMutation) ClearDisableRemoteAssistance() { - m.disable_remote_assistance = nil - m.clearedFields[settings.FieldDisableRemoteAssistance] = struct{}{} +// ClearSMTPStarttls clears the value of the "smtp_starttls" field. +func (m *SettingsMutation) ClearSMTPStarttls() { + m.smtp_starttls = nil + m.clearedFields[settings.FieldSMTPStarttls] = struct{}{} } -// DisableRemoteAssistanceCleared returns if the "disable_remote_assistance" field was cleared in this mutation. -func (m *SettingsMutation) DisableRemoteAssistanceCleared() bool { - _, ok := m.clearedFields[settings.FieldDisableRemoteAssistance] +// SMTPStarttlsCleared returns if the "smtp_starttls" field was cleared in this mutation. +func (m *SettingsMutation) SMTPStarttlsCleared() bool { + _, ok := m.clearedFields[settings.FieldSMTPStarttls] return ok } -// ResetDisableRemoteAssistance resets all changes to the "disable_remote_assistance" field. -func (m *SettingsMutation) ResetDisableRemoteAssistance() { - m.disable_remote_assistance = nil - delete(m.clearedFields, settings.FieldDisableRemoteAssistance) +// ResetSMTPStarttls resets all changes to the "smtp_starttls" field. +func (m *SettingsMutation) ResetSMTPStarttls() { + m.smtp_starttls = nil + delete(m.clearedFields, settings.FieldSMTPStarttls) } -// SetDetectRemoteAgents sets the "detect_remote_agents" field. -func (m *SettingsMutation) SetDetectRemoteAgents(b bool) { - m.detect_remote_agents = &b +// SetNatsServer sets the "nats_server" field. +func (m *SettingsMutation) SetNatsServer(s string) { + m.nats_server = &s } -// DetectRemoteAgents returns the value of the "detect_remote_agents" field in the mutation. -func (m *SettingsMutation) DetectRemoteAgents() (r bool, exists bool) { - v := m.detect_remote_agents +// NatsServer returns the value of the "nats_server" field in the mutation. +func (m *SettingsMutation) NatsServer() (r string, exists bool) { + v := m.nats_server if v == nil { return } return *v, true } -// OldDetectRemoteAgents returns the old "detect_remote_agents" field's value of the Settings entity. +// OldNatsServer returns the old "nats_server" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldDetectRemoteAgents(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldNatsServer(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDetectRemoteAgents is only allowed on UpdateOne operations") + return v, errors.New("OldNatsServer is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDetectRemoteAgents requires an ID field in the mutation") + return v, errors.New("OldNatsServer requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDetectRemoteAgents: %w", err) + return v, fmt.Errorf("querying old value for OldNatsServer: %w", err) } - return oldValue.DetectRemoteAgents, nil + return oldValue.NatsServer, nil } -// ClearDetectRemoteAgents clears the value of the "detect_remote_agents" field. -func (m *SettingsMutation) ClearDetectRemoteAgents() { - m.detect_remote_agents = nil - m.clearedFields[settings.FieldDetectRemoteAgents] = struct{}{} +// ClearNatsServer clears the value of the "nats_server" field. +func (m *SettingsMutation) ClearNatsServer() { + m.nats_server = nil + m.clearedFields[settings.FieldNatsServer] = struct{}{} } -// DetectRemoteAgentsCleared returns if the "detect_remote_agents" field was cleared in this mutation. -func (m *SettingsMutation) DetectRemoteAgentsCleared() bool { - _, ok := m.clearedFields[settings.FieldDetectRemoteAgents] +// NatsServerCleared returns if the "nats_server" field was cleared in this mutation. +func (m *SettingsMutation) NatsServerCleared() bool { + _, ok := m.clearedFields[settings.FieldNatsServer] return ok } -// ResetDetectRemoteAgents resets all changes to the "detect_remote_agents" field. -func (m *SettingsMutation) ResetDetectRemoteAgents() { - m.detect_remote_agents = nil - delete(m.clearedFields, settings.FieldDetectRemoteAgents) +// ResetNatsServer resets all changes to the "nats_server" field. +func (m *SettingsMutation) ResetNatsServer() { + m.nats_server = nil + delete(m.clearedFields, settings.FieldNatsServer) } -// SetAutoAdmitAgents sets the "auto_admit_agents" field. -func (m *SettingsMutation) SetAutoAdmitAgents(b bool) { - m.auto_admit_agents = &b +// SetNatsPort sets the "nats_port" field. +func (m *SettingsMutation) SetNatsPort(s string) { + m.nats_port = &s } -// AutoAdmitAgents returns the value of the "auto_admit_agents" field in the mutation. -func (m *SettingsMutation) AutoAdmitAgents() (r bool, exists bool) { - v := m.auto_admit_agents +// NatsPort returns the value of the "nats_port" field in the mutation. +func (m *SettingsMutation) NatsPort() (r string, exists bool) { + v := m.nats_port if v == nil { return } return *v, true } -// OldAutoAdmitAgents returns the old "auto_admit_agents" field's value of the Settings entity. +// OldNatsPort returns the old "nats_port" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldAutoAdmitAgents(ctx context.Context) (v bool, err error) { +func (m *SettingsMutation) OldNatsPort(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAutoAdmitAgents is only allowed on UpdateOne operations") + return v, errors.New("OldNatsPort is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAutoAdmitAgents requires an ID field in the mutation") + return v, errors.New("OldNatsPort requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAutoAdmitAgents: %w", err) + return v, fmt.Errorf("querying old value for OldNatsPort: %w", err) } - return oldValue.AutoAdmitAgents, nil + return oldValue.NatsPort, nil } -// ClearAutoAdmitAgents clears the value of the "auto_admit_agents" field. -func (m *SettingsMutation) ClearAutoAdmitAgents() { - m.auto_admit_agents = nil - m.clearedFields[settings.FieldAutoAdmitAgents] = struct{}{} +// ClearNatsPort clears the value of the "nats_port" field. +func (m *SettingsMutation) ClearNatsPort() { + m.nats_port = nil + m.clearedFields[settings.FieldNatsPort] = struct{}{} } -// AutoAdmitAgentsCleared returns if the "auto_admit_agents" field was cleared in this mutation. -func (m *SettingsMutation) AutoAdmitAgentsCleared() bool { - _, ok := m.clearedFields[settings.FieldAutoAdmitAgents] +// NatsPortCleared returns if the "nats_port" field was cleared in this mutation. +func (m *SettingsMutation) NatsPortCleared() bool { + _, ok := m.clearedFields[settings.FieldNatsPort] return ok } -// ResetAutoAdmitAgents resets all changes to the "auto_admit_agents" field. -func (m *SettingsMutation) ResetAutoAdmitAgents() { - m.auto_admit_agents = nil - delete(m.clearedFields, settings.FieldAutoAdmitAgents) +// ResetNatsPort resets all changes to the "nats_port" field. +func (m *SettingsMutation) ResetNatsPort() { + m.nats_port = nil + delete(m.clearedFields, settings.FieldNatsPort) } -// SetDefaultItemsPerPage sets the "default_items_per_page" field. -func (m *SettingsMutation) SetDefaultItemsPerPage(i int) { - m.default_items_per_page = &i - m.adddefault_items_per_page = nil +// SetMessageFrom sets the "message_from" field. +func (m *SettingsMutation) SetMessageFrom(s string) { + m.message_from = &s } -// DefaultItemsPerPage returns the value of the "default_items_per_page" field in the mutation. -func (m *SettingsMutation) DefaultItemsPerPage() (r int, exists bool) { - v := m.default_items_per_page +// MessageFrom returns the value of the "message_from" field in the mutation. +func (m *SettingsMutation) MessageFrom() (r string, exists bool) { + v := m.message_from if v == nil { return } return *v, true } -// OldDefaultItemsPerPage returns the old "default_items_per_page" field's value of the Settings entity. +// OldMessageFrom returns the old "message_from" field's value of the Settings entity. // If the Settings object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SettingsMutation) OldDefaultItemsPerPage(ctx context.Context) (v int, err error) { +func (m *SettingsMutation) OldMessageFrom(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDefaultItemsPerPage is only allowed on UpdateOne operations") + return v, errors.New("OldMessageFrom is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDefaultItemsPerPage requires an ID field in the mutation") + return v, errors.New("OldMessageFrom requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDefaultItemsPerPage: %w", err) + return v, fmt.Errorf("querying old value for OldMessageFrom: %w", err) } - return oldValue.DefaultItemsPerPage, nil + return oldValue.MessageFrom, nil } -// AddDefaultItemsPerPage adds i to the "default_items_per_page" field. -func (m *SettingsMutation) AddDefaultItemsPerPage(i int) { - if m.adddefault_items_per_page != nil { - *m.adddefault_items_per_page += i - } else { - m.adddefault_items_per_page = &i - } +// ClearMessageFrom clears the value of the "message_from" field. +func (m *SettingsMutation) ClearMessageFrom() { + m.message_from = nil + m.clearedFields[settings.FieldMessageFrom] = struct{}{} } -// AddedDefaultItemsPerPage returns the value that was added to the "default_items_per_page" field in this mutation. -func (m *SettingsMutation) AddedDefaultItemsPerPage() (r int, exists bool) { - v := m.adddefault_items_per_page +// MessageFromCleared returns if the "message_from" field was cleared in this mutation. +func (m *SettingsMutation) MessageFromCleared() bool { + _, ok := m.clearedFields[settings.FieldMessageFrom] + return ok +} + +// ResetMessageFrom resets all changes to the "message_from" field. +func (m *SettingsMutation) ResetMessageFrom() { + m.message_from = nil + delete(m.clearedFields, settings.FieldMessageFrom) +} + +// SetMaxUploadSize sets the "max_upload_size" field. +func (m *SettingsMutation) SetMaxUploadSize(s string) { + m.max_upload_size = &s +} + +// MaxUploadSize returns the value of the "max_upload_size" field in the mutation. +func (m *SettingsMutation) MaxUploadSize() (r string, exists bool) { + v := m.max_upload_size if v == nil { return } return *v, true } -// ClearDefaultItemsPerPage clears the value of the "default_items_per_page" field. -func (m *SettingsMutation) ClearDefaultItemsPerPage() { - m.default_items_per_page = nil - m.adddefault_items_per_page = nil - m.clearedFields[settings.FieldDefaultItemsPerPage] = struct{}{} +// OldMaxUploadSize returns the old "max_upload_size" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldMaxUploadSize(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMaxUploadSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMaxUploadSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMaxUploadSize: %w", err) + } + return oldValue.MaxUploadSize, nil } -// DefaultItemsPerPageCleared returns if the "default_items_per_page" field was cleared in this mutation. -func (m *SettingsMutation) DefaultItemsPerPageCleared() bool { - _, ok := m.clearedFields[settings.FieldDefaultItemsPerPage] +// ClearMaxUploadSize clears the value of the "max_upload_size" field. +func (m *SettingsMutation) ClearMaxUploadSize() { + m.max_upload_size = nil + m.clearedFields[settings.FieldMaxUploadSize] = struct{}{} +} + +// MaxUploadSizeCleared returns if the "max_upload_size" field was cleared in this mutation. +func (m *SettingsMutation) MaxUploadSizeCleared() bool { + _, ok := m.clearedFields[settings.FieldMaxUploadSize] return ok } -// ResetDefaultItemsPerPage resets all changes to the "default_items_per_page" field. -func (m *SettingsMutation) ResetDefaultItemsPerPage() { - m.default_items_per_page = nil - m.adddefault_items_per_page = nil - delete(m.clearedFields, settings.FieldDefaultItemsPerPage) +// ResetMaxUploadSize resets all changes to the "max_upload_size" field. +func (m *SettingsMutation) ResetMaxUploadSize() { + m.max_upload_size = nil + delete(m.clearedFields, settings.FieldMaxUploadSize) } -// SetTagID sets the "tag" edge to the Tag entity by id. -func (m *SettingsMutation) SetTagID(id int) { - m.tag = &id +// SetUserCertYearsValid sets the "user_cert_years_valid" field. +func (m *SettingsMutation) SetUserCertYearsValid(i int) { + m.user_cert_years_valid = &i + m.adduser_cert_years_valid = nil } -// ClearTag clears the "tag" edge to the Tag entity. -func (m *SettingsMutation) ClearTag() { - m.clearedtag = true +// UserCertYearsValid returns the value of the "user_cert_years_valid" field in the mutation. +func (m *SettingsMutation) UserCertYearsValid() (r int, exists bool) { + v := m.user_cert_years_valid + if v == nil { + return + } + return *v, true } -// TagCleared reports if the "tag" edge to the Tag entity was cleared. -func (m *SettingsMutation) TagCleared() bool { - return m.clearedtag +// OldUserCertYearsValid returns the old "user_cert_years_valid" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldUserCertYearsValid(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserCertYearsValid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserCertYearsValid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserCertYearsValid: %w", err) + } + return oldValue.UserCertYearsValid, nil } -// TagID returns the "tag" edge ID in the mutation. -func (m *SettingsMutation) TagID() (id int, exists bool) { - if m.tag != nil { - return *m.tag, true +// AddUserCertYearsValid adds i to the "user_cert_years_valid" field. +func (m *SettingsMutation) AddUserCertYearsValid(i int) { + if m.adduser_cert_years_valid != nil { + *m.adduser_cert_years_valid += i + } else { + m.adduser_cert_years_valid = &i } - return } -// TagIDs returns the "tag" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TagID instead. It exists only for internal usage by the builders. -func (m *SettingsMutation) TagIDs() (ids []int) { - if id := m.tag; id != nil { - ids = append(ids, *id) +// AddedUserCertYearsValid returns the value that was added to the "user_cert_years_valid" field in this mutation. +func (m *SettingsMutation) AddedUserCertYearsValid() (r int, exists bool) { + v := m.adduser_cert_years_valid + if v == nil { + return } - return + return *v, true } -// ResetTag resets all changes to the "tag" edge. -func (m *SettingsMutation) ResetTag() { - m.tag = nil - m.clearedtag = false +// ClearUserCertYearsValid clears the value of the "user_cert_years_valid" field. +func (m *SettingsMutation) ClearUserCertYearsValid() { + m.user_cert_years_valid = nil + m.adduser_cert_years_valid = nil + m.clearedFields[settings.FieldUserCertYearsValid] = struct{}{} } -// SetTenantID sets the "tenant" edge to the Tenant entity by id. -func (m *SettingsMutation) SetTenantID(id int) { - m.tenant = &id +// UserCertYearsValidCleared returns if the "user_cert_years_valid" field was cleared in this mutation. +func (m *SettingsMutation) UserCertYearsValidCleared() bool { + _, ok := m.clearedFields[settings.FieldUserCertYearsValid] + return ok } -// ClearTenant clears the "tenant" edge to the Tenant entity. -func (m *SettingsMutation) ClearTenant() { - m.clearedtenant = true +// ResetUserCertYearsValid resets all changes to the "user_cert_years_valid" field. +func (m *SettingsMutation) ResetUserCertYearsValid() { + m.user_cert_years_valid = nil + m.adduser_cert_years_valid = nil + delete(m.clearedFields, settings.FieldUserCertYearsValid) } -// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. -func (m *SettingsMutation) TenantCleared() bool { - return m.clearedtenant +// SetNatsRequestTimeoutSeconds sets the "nats_request_timeout_seconds" field. +func (m *SettingsMutation) SetNatsRequestTimeoutSeconds(i int) { + m.nats_request_timeout_seconds = &i + m.addnats_request_timeout_seconds = nil } -// TenantID returns the "tenant" edge ID in the mutation. -func (m *SettingsMutation) TenantID() (id int, exists bool) { - if m.tenant != nil { - return *m.tenant, true +// NatsRequestTimeoutSeconds returns the value of the "nats_request_timeout_seconds" field in the mutation. +func (m *SettingsMutation) NatsRequestTimeoutSeconds() (r int, exists bool) { + v := m.nats_request_timeout_seconds + if v == nil { + return } - return + return *v, true } -// TenantIDs returns the "tenant" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TenantID instead. It exists only for internal usage by the builders. -func (m *SettingsMutation) TenantIDs() (ids []int) { - if id := m.tenant; id != nil { - ids = append(ids, *id) +// OldNatsRequestTimeoutSeconds returns the old "nats_request_timeout_seconds" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldNatsRequestTimeoutSeconds(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNatsRequestTimeoutSeconds is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNatsRequestTimeoutSeconds requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNatsRequestTimeoutSeconds: %w", err) + } + return oldValue.NatsRequestTimeoutSeconds, nil } -// ResetTenant resets all changes to the "tenant" edge. -func (m *SettingsMutation) ResetTenant() { - m.tenant = nil - m.clearedtenant = false +// AddNatsRequestTimeoutSeconds adds i to the "nats_request_timeout_seconds" field. +func (m *SettingsMutation) AddNatsRequestTimeoutSeconds(i int) { + if m.addnats_request_timeout_seconds != nil { + *m.addnats_request_timeout_seconds += i + } else { + m.addnats_request_timeout_seconds = &i + } } -// Where appends a list predicates to the SettingsMutation builder. -func (m *SettingsMutation) Where(ps ...predicate.Settings) { - m.predicates = append(m.predicates, ps...) +// AddedNatsRequestTimeoutSeconds returns the value that was added to the "nats_request_timeout_seconds" field in this mutation. +func (m *SettingsMutation) AddedNatsRequestTimeoutSeconds() (r int, exists bool) { + v := m.addnats_request_timeout_seconds + if v == nil { + return + } + return *v, true } -// WhereP appends storage-level predicates to the SettingsMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SettingsMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Settings, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// ClearNatsRequestTimeoutSeconds clears the value of the "nats_request_timeout_seconds" field. +func (m *SettingsMutation) ClearNatsRequestTimeoutSeconds() { + m.nats_request_timeout_seconds = nil + m.addnats_request_timeout_seconds = nil + m.clearedFields[settings.FieldNatsRequestTimeoutSeconds] = struct{}{} } -// Op returns the operation name. -func (m *SettingsMutation) Op() Op { - return m.op +// NatsRequestTimeoutSecondsCleared returns if the "nats_request_timeout_seconds" field was cleared in this mutation. +func (m *SettingsMutation) NatsRequestTimeoutSecondsCleared() bool { + _, ok := m.clearedFields[settings.FieldNatsRequestTimeoutSeconds] + return ok } -// SetOp allows setting the mutation operation. -func (m *SettingsMutation) SetOp(op Op) { - m.op = op +// ResetNatsRequestTimeoutSeconds resets all changes to the "nats_request_timeout_seconds" field. +func (m *SettingsMutation) ResetNatsRequestTimeoutSeconds() { + m.nats_request_timeout_seconds = nil + m.addnats_request_timeout_seconds = nil + delete(m.clearedFields, settings.FieldNatsRequestTimeoutSeconds) } -// Type returns the node type of this mutation (Settings). -func (m *SettingsMutation) Type() string { - return m.typ +// SetRefreshTimeInMinutes sets the "refresh_time_in_minutes" field. +func (m *SettingsMutation) SetRefreshTimeInMinutes(i int) { + m.refresh_time_in_minutes = &i + m.addrefresh_time_in_minutes = nil } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *SettingsMutation) Fields() []string { - fields := make([]string, 0, 37) - if m.language != nil { - fields = append(fields, settings.FieldLanguage) +// RefreshTimeInMinutes returns the value of the "refresh_time_in_minutes" field in the mutation. +func (m *SettingsMutation) RefreshTimeInMinutes() (r int, exists bool) { + v := m.refresh_time_in_minutes + if v == nil { + return } - if m.organization != nil { - fields = append(fields, settings.FieldOrganization) + return *v, true +} + +// OldRefreshTimeInMinutes returns the old "refresh_time_in_minutes" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldRefreshTimeInMinutes(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefreshTimeInMinutes is only allowed on UpdateOne operations") } - if m.postal_address != nil { - fields = append(fields, settings.FieldPostalAddress) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefreshTimeInMinutes requires an ID field in the mutation") } - if m.postal_code != nil { - fields = append(fields, settings.FieldPostalCode) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefreshTimeInMinutes: %w", err) } - if m.locality != nil { - fields = append(fields, settings.FieldLocality) + return oldValue.RefreshTimeInMinutes, nil +} + +// AddRefreshTimeInMinutes adds i to the "refresh_time_in_minutes" field. +func (m *SettingsMutation) AddRefreshTimeInMinutes(i int) { + if m.addrefresh_time_in_minutes != nil { + *m.addrefresh_time_in_minutes += i + } else { + m.addrefresh_time_in_minutes = &i } - if m.province != nil { - fields = append(fields, settings.FieldProvince) +} + +// AddedRefreshTimeInMinutes returns the value that was added to the "refresh_time_in_minutes" field in this mutation. +func (m *SettingsMutation) AddedRefreshTimeInMinutes() (r int, exists bool) { + v := m.addrefresh_time_in_minutes + if v == nil { + return } - if m.state != nil { - fields = append(fields, settings.FieldState) + return *v, true +} + +// ClearRefreshTimeInMinutes clears the value of the "refresh_time_in_minutes" field. +func (m *SettingsMutation) ClearRefreshTimeInMinutes() { + m.refresh_time_in_minutes = nil + m.addrefresh_time_in_minutes = nil + m.clearedFields[settings.FieldRefreshTimeInMinutes] = struct{}{} +} + +// RefreshTimeInMinutesCleared returns if the "refresh_time_in_minutes" field was cleared in this mutation. +func (m *SettingsMutation) RefreshTimeInMinutesCleared() bool { + _, ok := m.clearedFields[settings.FieldRefreshTimeInMinutes] + return ok +} + +// ResetRefreshTimeInMinutes resets all changes to the "refresh_time_in_minutes" field. +func (m *SettingsMutation) ResetRefreshTimeInMinutes() { + m.refresh_time_in_minutes = nil + m.addrefresh_time_in_minutes = nil + delete(m.clearedFields, settings.FieldRefreshTimeInMinutes) +} + +// SetSessionLifetimeInMinutes sets the "session_lifetime_in_minutes" field. +func (m *SettingsMutation) SetSessionLifetimeInMinutes(i int) { + m.session_lifetime_in_minutes = &i + m.addsession_lifetime_in_minutes = nil +} + +// SessionLifetimeInMinutes returns the value of the "session_lifetime_in_minutes" field in the mutation. +func (m *SettingsMutation) SessionLifetimeInMinutes() (r int, exists bool) { + v := m.session_lifetime_in_minutes + if v == nil { + return } - if m.country != nil { - fields = append(fields, settings.FieldCountry) + return *v, true +} + +// OldSessionLifetimeInMinutes returns the old "session_lifetime_in_minutes" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldSessionLifetimeInMinutes(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSessionLifetimeInMinutes is only allowed on UpdateOne operations") } - if m.smtp_server != nil { - fields = append(fields, settings.FieldSMTPServer) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSessionLifetimeInMinutes requires an ID field in the mutation") } - if m.smtp_port != nil { - fields = append(fields, settings.FieldSMTPPort) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSessionLifetimeInMinutes: %w", err) } - if m.smtp_user != nil { - fields = append(fields, settings.FieldSMTPUser) + return oldValue.SessionLifetimeInMinutes, nil +} + +// AddSessionLifetimeInMinutes adds i to the "session_lifetime_in_minutes" field. +func (m *SettingsMutation) AddSessionLifetimeInMinutes(i int) { + if m.addsession_lifetime_in_minutes != nil { + *m.addsession_lifetime_in_minutes += i + } else { + m.addsession_lifetime_in_minutes = &i } - if m.smtp_password != nil { - fields = append(fields, settings.FieldSMTPPassword) +} + +// AddedSessionLifetimeInMinutes returns the value that was added to the "session_lifetime_in_minutes" field in this mutation. +func (m *SettingsMutation) AddedSessionLifetimeInMinutes() (r int, exists bool) { + v := m.addsession_lifetime_in_minutes + if v == nil { + return } - if m.smtp_auth != nil { - fields = append(fields, settings.FieldSMTPAuth) + return *v, true +} + +// ClearSessionLifetimeInMinutes clears the value of the "session_lifetime_in_minutes" field. +func (m *SettingsMutation) ClearSessionLifetimeInMinutes() { + m.session_lifetime_in_minutes = nil + m.addsession_lifetime_in_minutes = nil + m.clearedFields[settings.FieldSessionLifetimeInMinutes] = struct{}{} +} + +// SessionLifetimeInMinutesCleared returns if the "session_lifetime_in_minutes" field was cleared in this mutation. +func (m *SettingsMutation) SessionLifetimeInMinutesCleared() bool { + _, ok := m.clearedFields[settings.FieldSessionLifetimeInMinutes] + return ok +} + +// ResetSessionLifetimeInMinutes resets all changes to the "session_lifetime_in_minutes" field. +func (m *SettingsMutation) ResetSessionLifetimeInMinutes() { + m.session_lifetime_in_minutes = nil + m.addsession_lifetime_in_minutes = nil + delete(m.clearedFields, settings.FieldSessionLifetimeInMinutes) +} + +// SetUpdateChannel sets the "update_channel" field. +func (m *SettingsMutation) SetUpdateChannel(s string) { + m.update_channel = &s +} + +// UpdateChannel returns the value of the "update_channel" field in the mutation. +func (m *SettingsMutation) UpdateChannel() (r string, exists bool) { + v := m.update_channel + if v == nil { + return } - if m.smtp_tls != nil { - fields = append(fields, settings.FieldSMTPTLS) + return *v, true +} + +// OldUpdateChannel returns the old "update_channel" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldUpdateChannel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateChannel is only allowed on UpdateOne operations") } - if m.smtp_starttls != nil { - fields = append(fields, settings.FieldSMTPStarttls) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateChannel requires an ID field in the mutation") } - if m.nats_server != nil { - fields = append(fields, settings.FieldNatsServer) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateChannel: %w", err) } - if m.nats_port != nil { - fields = append(fields, settings.FieldNatsPort) + return oldValue.UpdateChannel, nil +} + +// ClearUpdateChannel clears the value of the "update_channel" field. +func (m *SettingsMutation) ClearUpdateChannel() { + m.update_channel = nil + m.clearedFields[settings.FieldUpdateChannel] = struct{}{} +} + +// UpdateChannelCleared returns if the "update_channel" field was cleared in this mutation. +func (m *SettingsMutation) UpdateChannelCleared() bool { + _, ok := m.clearedFields[settings.FieldUpdateChannel] + return ok +} + +// ResetUpdateChannel resets all changes to the "update_channel" field. +func (m *SettingsMutation) ResetUpdateChannel() { + m.update_channel = nil + delete(m.clearedFields, settings.FieldUpdateChannel) +} + +// SetCreated sets the "created" field. +func (m *SettingsMutation) SetCreated(t time.Time) { + m.created = &t +} + +// Created returns the value of the "created" field in the mutation. +func (m *SettingsMutation) Created() (r time.Time, exists bool) { + v := m.created + if v == nil { + return } - if m.message_from != nil { - fields = append(fields, settings.FieldMessageFrom) + return *v, true +} + +// OldCreated returns the old "created" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldCreated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreated is only allowed on UpdateOne operations") } - if m.max_upload_size != nil { - fields = append(fields, settings.FieldMaxUploadSize) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreated requires an ID field in the mutation") } - if m.user_cert_years_valid != nil { - fields = append(fields, settings.FieldUserCertYearsValid) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreated: %w", err) } - if m.nats_request_timeout_seconds != nil { - fields = append(fields, settings.FieldNatsRequestTimeoutSeconds) + return oldValue.Created, nil +} + +// ClearCreated clears the value of the "created" field. +func (m *SettingsMutation) ClearCreated() { + m.created = nil + m.clearedFields[settings.FieldCreated] = struct{}{} +} + +// CreatedCleared returns if the "created" field was cleared in this mutation. +func (m *SettingsMutation) CreatedCleared() bool { + _, ok := m.clearedFields[settings.FieldCreated] + return ok +} + +// ResetCreated resets all changes to the "created" field. +func (m *SettingsMutation) ResetCreated() { + m.created = nil + delete(m.clearedFields, settings.FieldCreated) +} + +// SetModified sets the "modified" field. +func (m *SettingsMutation) SetModified(t time.Time) { + m.modified = &t +} + +// Modified returns the value of the "modified" field in the mutation. +func (m *SettingsMutation) Modified() (r time.Time, exists bool) { + v := m.modified + if v == nil { + return } - if m.refresh_time_in_minutes != nil { - fields = append(fields, settings.FieldRefreshTimeInMinutes) + return *v, true +} + +// OldModified returns the old "modified" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldModified(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModified is only allowed on UpdateOne operations") } - if m.session_lifetime_in_minutes != nil { - fields = append(fields, settings.FieldSessionLifetimeInMinutes) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModified requires an ID field in the mutation") } - if m.update_channel != nil { - fields = append(fields, settings.FieldUpdateChannel) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModified: %w", err) } - if m.created != nil { - fields = append(fields, settings.FieldCreated) + return oldValue.Modified, nil +} + +// ClearModified clears the value of the "modified" field. +func (m *SettingsMutation) ClearModified() { + m.modified = nil + m.clearedFields[settings.FieldModified] = struct{}{} +} + +// ModifiedCleared returns if the "modified" field was cleared in this mutation. +func (m *SettingsMutation) ModifiedCleared() bool { + _, ok := m.clearedFields[settings.FieldModified] + return ok +} + +// ResetModified resets all changes to the "modified" field. +func (m *SettingsMutation) ResetModified() { + m.modified = nil + delete(m.clearedFields, settings.FieldModified) +} + +// SetAgentReportFrequenceInMinutes sets the "agent_report_frequence_in_minutes" field. +func (m *SettingsMutation) SetAgentReportFrequenceInMinutes(i int) { + m.agent_report_frequence_in_minutes = &i + m.addagent_report_frequence_in_minutes = nil +} + +// AgentReportFrequenceInMinutes returns the value of the "agent_report_frequence_in_minutes" field in the mutation. +func (m *SettingsMutation) AgentReportFrequenceInMinutes() (r int, exists bool) { + v := m.agent_report_frequence_in_minutes + if v == nil { + return } - if m.modified != nil { - fields = append(fields, settings.FieldModified) + return *v, true +} + +// OldAgentReportFrequenceInMinutes returns the old "agent_report_frequence_in_minutes" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldAgentReportFrequenceInMinutes(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAgentReportFrequenceInMinutes is only allowed on UpdateOne operations") } - if m.agent_report_frequence_in_minutes != nil { - fields = append(fields, settings.FieldAgentReportFrequenceInMinutes) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAgentReportFrequenceInMinutes requires an ID field in the mutation") } - if m.request_vnc_pin != nil { - fields = append(fields, settings.FieldRequestVncPin) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAgentReportFrequenceInMinutes: %w", err) } - if m.profiles_application_frequence_in_minutes != nil { - fields = append(fields, settings.FieldProfilesApplicationFrequenceInMinutes) + return oldValue.AgentReportFrequenceInMinutes, nil +} + +// AddAgentReportFrequenceInMinutes adds i to the "agent_report_frequence_in_minutes" field. +func (m *SettingsMutation) AddAgentReportFrequenceInMinutes(i int) { + if m.addagent_report_frequence_in_minutes != nil { + *m.addagent_report_frequence_in_minutes += i + } else { + m.addagent_report_frequence_in_minutes = &i } - if m.use_winget != nil { - fields = append(fields, settings.FieldUseWinget) +} + +// AddedAgentReportFrequenceInMinutes returns the value that was added to the "agent_report_frequence_in_minutes" field in this mutation. +func (m *SettingsMutation) AddedAgentReportFrequenceInMinutes() (r int, exists bool) { + v := m.addagent_report_frequence_in_minutes + if v == nil { + return } - if m.use_flatpak != nil { - fields = append(fields, settings.FieldUseFlatpak) + return *v, true +} + +// ClearAgentReportFrequenceInMinutes clears the value of the "agent_report_frequence_in_minutes" field. +func (m *SettingsMutation) ClearAgentReportFrequenceInMinutes() { + m.agent_report_frequence_in_minutes = nil + m.addagent_report_frequence_in_minutes = nil + m.clearedFields[settings.FieldAgentReportFrequenceInMinutes] = struct{}{} +} + +// AgentReportFrequenceInMinutesCleared returns if the "agent_report_frequence_in_minutes" field was cleared in this mutation. +func (m *SettingsMutation) AgentReportFrequenceInMinutesCleared() bool { + _, ok := m.clearedFields[settings.FieldAgentReportFrequenceInMinutes] + return ok +} + +// ResetAgentReportFrequenceInMinutes resets all changes to the "agent_report_frequence_in_minutes" field. +func (m *SettingsMutation) ResetAgentReportFrequenceInMinutes() { + m.agent_report_frequence_in_minutes = nil + m.addagent_report_frequence_in_minutes = nil + delete(m.clearedFields, settings.FieldAgentReportFrequenceInMinutes) +} + +// SetRequestVncPin sets the "request_vnc_pin" field. +func (m *SettingsMutation) SetRequestVncPin(b bool) { + m.request_vnc_pin = &b +} + +// RequestVncPin returns the value of the "request_vnc_pin" field in the mutation. +func (m *SettingsMutation) RequestVncPin() (r bool, exists bool) { + v := m.request_vnc_pin + if v == nil { + return } - if m.use_brew != nil { - fields = append(fields, settings.FieldUseBrew) + return *v, true +} + +// OldRequestVncPin returns the old "request_vnc_pin" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldRequestVncPin(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRequestVncPin is only allowed on UpdateOne operations") } - if m.disable_sftp != nil { - fields = append(fields, settings.FieldDisableSftp) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRequestVncPin requires an ID field in the mutation") } - if m.disable_remote_assistance != nil { - fields = append(fields, settings.FieldDisableRemoteAssistance) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRequestVncPin: %w", err) } - if m.detect_remote_agents != nil { - fields = append(fields, settings.FieldDetectRemoteAgents) + return oldValue.RequestVncPin, nil +} + +// ClearRequestVncPin clears the value of the "request_vnc_pin" field. +func (m *SettingsMutation) ClearRequestVncPin() { + m.request_vnc_pin = nil + m.clearedFields[settings.FieldRequestVncPin] = struct{}{} +} + +// RequestVncPinCleared returns if the "request_vnc_pin" field was cleared in this mutation. +func (m *SettingsMutation) RequestVncPinCleared() bool { + _, ok := m.clearedFields[settings.FieldRequestVncPin] + return ok +} + +// ResetRequestVncPin resets all changes to the "request_vnc_pin" field. +func (m *SettingsMutation) ResetRequestVncPin() { + m.request_vnc_pin = nil + delete(m.clearedFields, settings.FieldRequestVncPin) +} + +// SetProfilesApplicationFrequenceInMinutes sets the "profiles_application_frequence_in_minutes" field. +func (m *SettingsMutation) SetProfilesApplicationFrequenceInMinutes(i int) { + m.profiles_application_frequence_in_minutes = &i + m.addprofiles_application_frequence_in_minutes = nil +} + +// ProfilesApplicationFrequenceInMinutes returns the value of the "profiles_application_frequence_in_minutes" field in the mutation. +func (m *SettingsMutation) ProfilesApplicationFrequenceInMinutes() (r int, exists bool) { + v := m.profiles_application_frequence_in_minutes + if v == nil { + return } - if m.auto_admit_agents != nil { - fields = append(fields, settings.FieldAutoAdmitAgents) + return *v, true +} + +// OldProfilesApplicationFrequenceInMinutes returns the old "profiles_application_frequence_in_minutes" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldProfilesApplicationFrequenceInMinutes(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProfilesApplicationFrequenceInMinutes is only allowed on UpdateOne operations") } - if m.default_items_per_page != nil { - fields = append(fields, settings.FieldDefaultItemsPerPage) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProfilesApplicationFrequenceInMinutes requires an ID field in the mutation") } - return fields + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProfilesApplicationFrequenceInMinutes: %w", err) + } + return oldValue.ProfilesApplicationFrequenceInMinutes, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *SettingsMutation) Field(name string) (ent.Value, bool) { - switch name { - case settings.FieldLanguage: - return m.Language() - case settings.FieldOrganization: - return m.Organization() - case settings.FieldPostalAddress: - return m.PostalAddress() - case settings.FieldPostalCode: - return m.PostalCode() - case settings.FieldLocality: - return m.Locality() - case settings.FieldProvince: - return m.Province() - case settings.FieldState: - return m.State() - case settings.FieldCountry: - return m.Country() - case settings.FieldSMTPServer: - return m.SMTPServer() - case settings.FieldSMTPPort: - return m.SMTPPort() - case settings.FieldSMTPUser: - return m.SMTPUser() - case settings.FieldSMTPPassword: - return m.SMTPPassword() - case settings.FieldSMTPAuth: - return m.SMTPAuth() - case settings.FieldSMTPTLS: - return m.SMTPTLS() - case settings.FieldSMTPStarttls: - return m.SMTPStarttls() - case settings.FieldNatsServer: - return m.NatsServer() - case settings.FieldNatsPort: - return m.NatsPort() - case settings.FieldMessageFrom: - return m.MessageFrom() - case settings.FieldMaxUploadSize: - return m.MaxUploadSize() - case settings.FieldUserCertYearsValid: - return m.UserCertYearsValid() - case settings.FieldNatsRequestTimeoutSeconds: - return m.NatsRequestTimeoutSeconds() - case settings.FieldRefreshTimeInMinutes: - return m.RefreshTimeInMinutes() - case settings.FieldSessionLifetimeInMinutes: - return m.SessionLifetimeInMinutes() - case settings.FieldUpdateChannel: - return m.UpdateChannel() - case settings.FieldCreated: - return m.Created() - case settings.FieldModified: - return m.Modified() - case settings.FieldAgentReportFrequenceInMinutes: - return m.AgentReportFrequenceInMinutes() - case settings.FieldRequestVncPin: - return m.RequestVncPin() - case settings.FieldProfilesApplicationFrequenceInMinutes: - return m.ProfilesApplicationFrequenceInMinutes() - case settings.FieldUseWinget: - return m.UseWinget() - case settings.FieldUseFlatpak: - return m.UseFlatpak() - case settings.FieldUseBrew: - return m.UseBrew() - case settings.FieldDisableSftp: - return m.DisableSftp() - case settings.FieldDisableRemoteAssistance: - return m.DisableRemoteAssistance() - case settings.FieldDetectRemoteAgents: - return m.DetectRemoteAgents() - case settings.FieldAutoAdmitAgents: - return m.AutoAdmitAgents() - case settings.FieldDefaultItemsPerPage: - return m.DefaultItemsPerPage() +// AddProfilesApplicationFrequenceInMinutes adds i to the "profiles_application_frequence_in_minutes" field. +func (m *SettingsMutation) AddProfilesApplicationFrequenceInMinutes(i int) { + if m.addprofiles_application_frequence_in_minutes != nil { + *m.addprofiles_application_frequence_in_minutes += i + } else { + m.addprofiles_application_frequence_in_minutes = &i } - return nil, false } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *SettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case settings.FieldLanguage: - return m.OldLanguage(ctx) - case settings.FieldOrganization: - return m.OldOrganization(ctx) - case settings.FieldPostalAddress: - return m.OldPostalAddress(ctx) - case settings.FieldPostalCode: - return m.OldPostalCode(ctx) - case settings.FieldLocality: - return m.OldLocality(ctx) - case settings.FieldProvince: - return m.OldProvince(ctx) - case settings.FieldState: - return m.OldState(ctx) - case settings.FieldCountry: - return m.OldCountry(ctx) - case settings.FieldSMTPServer: - return m.OldSMTPServer(ctx) - case settings.FieldSMTPPort: - return m.OldSMTPPort(ctx) - case settings.FieldSMTPUser: - return m.OldSMTPUser(ctx) - case settings.FieldSMTPPassword: - return m.OldSMTPPassword(ctx) - case settings.FieldSMTPAuth: - return m.OldSMTPAuth(ctx) - case settings.FieldSMTPTLS: - return m.OldSMTPTLS(ctx) - case settings.FieldSMTPStarttls: - return m.OldSMTPStarttls(ctx) - case settings.FieldNatsServer: - return m.OldNatsServer(ctx) - case settings.FieldNatsPort: - return m.OldNatsPort(ctx) - case settings.FieldMessageFrom: - return m.OldMessageFrom(ctx) - case settings.FieldMaxUploadSize: - return m.OldMaxUploadSize(ctx) - case settings.FieldUserCertYearsValid: - return m.OldUserCertYearsValid(ctx) - case settings.FieldNatsRequestTimeoutSeconds: - return m.OldNatsRequestTimeoutSeconds(ctx) - case settings.FieldRefreshTimeInMinutes: - return m.OldRefreshTimeInMinutes(ctx) - case settings.FieldSessionLifetimeInMinutes: - return m.OldSessionLifetimeInMinutes(ctx) - case settings.FieldUpdateChannel: - return m.OldUpdateChannel(ctx) - case settings.FieldCreated: - return m.OldCreated(ctx) - case settings.FieldModified: - return m.OldModified(ctx) - case settings.FieldAgentReportFrequenceInMinutes: - return m.OldAgentReportFrequenceInMinutes(ctx) - case settings.FieldRequestVncPin: - return m.OldRequestVncPin(ctx) - case settings.FieldProfilesApplicationFrequenceInMinutes: - return m.OldProfilesApplicationFrequenceInMinutes(ctx) - case settings.FieldUseWinget: - return m.OldUseWinget(ctx) - case settings.FieldUseFlatpak: - return m.OldUseFlatpak(ctx) - case settings.FieldUseBrew: - return m.OldUseBrew(ctx) - case settings.FieldDisableSftp: - return m.OldDisableSftp(ctx) - case settings.FieldDisableRemoteAssistance: - return m.OldDisableRemoteAssistance(ctx) - case settings.FieldDetectRemoteAgents: - return m.OldDetectRemoteAgents(ctx) - case settings.FieldAutoAdmitAgents: - return m.OldAutoAdmitAgents(ctx) - case settings.FieldDefaultItemsPerPage: - return m.OldDefaultItemsPerPage(ctx) +// AddedProfilesApplicationFrequenceInMinutes returns the value that was added to the "profiles_application_frequence_in_minutes" field in this mutation. +func (m *SettingsMutation) AddedProfilesApplicationFrequenceInMinutes() (r int, exists bool) { + v := m.addprofiles_application_frequence_in_minutes + if v == nil { + return } - return nil, fmt.Errorf("unknown Settings field %s", name) + return *v, true } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *SettingsMutation) SetField(name string, value ent.Value) error { - switch name { - case settings.FieldLanguage: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLanguage(v) - return nil - case settings.FieldOrganization: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetOrganization(v) - return nil - case settings.FieldPostalAddress: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPostalAddress(v) - return nil - case settings.FieldPostalCode: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPostalCode(v) - return nil - case settings.FieldLocality: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocality(v) - return nil - case settings.FieldProvince: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetProvince(v) - return nil - case settings.FieldState: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetState(v) - return nil - case settings.FieldCountry: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCountry(v) - return nil - case settings.FieldSMTPServer: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPServer(v) - return nil - case settings.FieldSMTPPort: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPPort(v) - return nil - case settings.FieldSMTPUser: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPUser(v) - return nil - case settings.FieldSMTPPassword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPPassword(v) - return nil - case settings.FieldSMTPAuth: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPAuth(v) - return nil - case settings.FieldSMTPTLS: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPTLS(v) - return nil - case settings.FieldSMTPStarttls: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSMTPStarttls(v) - return nil - case settings.FieldNatsServer: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNatsServer(v) - return nil - case settings.FieldNatsPort: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNatsPort(v) - return nil - case settings.FieldMessageFrom: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMessageFrom(v) - return nil - case settings.FieldMaxUploadSize: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMaxUploadSize(v) - return nil - case settings.FieldUserCertYearsValid: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUserCertYearsValid(v) - return nil - case settings.FieldNatsRequestTimeoutSeconds: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNatsRequestTimeoutSeconds(v) - return nil - case settings.FieldRefreshTimeInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRefreshTimeInMinutes(v) - return nil - case settings.FieldSessionLifetimeInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSessionLifetimeInMinutes(v) - return nil - case settings.FieldUpdateChannel: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateChannel(v) - return nil - case settings.FieldCreated: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreated(v) - return nil - case settings.FieldModified: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetModified(v) - return nil - case settings.FieldAgentReportFrequenceInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAgentReportFrequenceInMinutes(v) - return nil - case settings.FieldRequestVncPin: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRequestVncPin(v) - return nil - case settings.FieldProfilesApplicationFrequenceInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetProfilesApplicationFrequenceInMinutes(v) - return nil - case settings.FieldUseWinget: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUseWinget(v) - return nil - case settings.FieldUseFlatpak: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUseFlatpak(v) - return nil - case settings.FieldUseBrew: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUseBrew(v) - return nil - case settings.FieldDisableSftp: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDisableSftp(v) - return nil - case settings.FieldDisableRemoteAssistance: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDisableRemoteAssistance(v) - return nil - case settings.FieldDetectRemoteAgents: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDetectRemoteAgents(v) - return nil - case settings.FieldAutoAdmitAgents: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAutoAdmitAgents(v) - return nil - case settings.FieldDefaultItemsPerPage: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDefaultItemsPerPage(v) - return nil - } - return fmt.Errorf("unknown Settings field %s", name) +// ClearProfilesApplicationFrequenceInMinutes clears the value of the "profiles_application_frequence_in_minutes" field. +func (m *SettingsMutation) ClearProfilesApplicationFrequenceInMinutes() { + m.profiles_application_frequence_in_minutes = nil + m.addprofiles_application_frequence_in_minutes = nil + m.clearedFields[settings.FieldProfilesApplicationFrequenceInMinutes] = struct{}{} } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *SettingsMutation) AddedFields() []string { - var fields []string - if m.addsmtp_port != nil { - fields = append(fields, settings.FieldSMTPPort) - } - if m.adduser_cert_years_valid != nil { - fields = append(fields, settings.FieldUserCertYearsValid) - } - if m.addnats_request_timeout_seconds != nil { - fields = append(fields, settings.FieldNatsRequestTimeoutSeconds) - } - if m.addrefresh_time_in_minutes != nil { - fields = append(fields, settings.FieldRefreshTimeInMinutes) - } - if m.addsession_lifetime_in_minutes != nil { - fields = append(fields, settings.FieldSessionLifetimeInMinutes) +// ProfilesApplicationFrequenceInMinutesCleared returns if the "profiles_application_frequence_in_minutes" field was cleared in this mutation. +func (m *SettingsMutation) ProfilesApplicationFrequenceInMinutesCleared() bool { + _, ok := m.clearedFields[settings.FieldProfilesApplicationFrequenceInMinutes] + return ok +} + +// ResetProfilesApplicationFrequenceInMinutes resets all changes to the "profiles_application_frequence_in_minutes" field. +func (m *SettingsMutation) ResetProfilesApplicationFrequenceInMinutes() { + m.profiles_application_frequence_in_minutes = nil + m.addprofiles_application_frequence_in_minutes = nil + delete(m.clearedFields, settings.FieldProfilesApplicationFrequenceInMinutes) +} + +// SetUseWinget sets the "use_winget" field. +func (m *SettingsMutation) SetUseWinget(b bool) { + m.use_winget = &b +} + +// UseWinget returns the value of the "use_winget" field in the mutation. +func (m *SettingsMutation) UseWinget() (r bool, exists bool) { + v := m.use_winget + if v == nil { + return } - if m.addagent_report_frequence_in_minutes != nil { - fields = append(fields, settings.FieldAgentReportFrequenceInMinutes) + return *v, true +} + +// OldUseWinget returns the old "use_winget" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldUseWinget(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUseWinget is only allowed on UpdateOne operations") } - if m.addprofiles_application_frequence_in_minutes != nil { - fields = append(fields, settings.FieldProfilesApplicationFrequenceInMinutes) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUseWinget requires an ID field in the mutation") } - if m.adddefault_items_per_page != nil { - fields = append(fields, settings.FieldDefaultItemsPerPage) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUseWinget: %w", err) } - return fields + return oldValue.UseWinget, nil } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *SettingsMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case settings.FieldSMTPPort: - return m.AddedSMTPPort() - case settings.FieldUserCertYearsValid: - return m.AddedUserCertYearsValid() - case settings.FieldNatsRequestTimeoutSeconds: - return m.AddedNatsRequestTimeoutSeconds() - case settings.FieldRefreshTimeInMinutes: - return m.AddedRefreshTimeInMinutes() - case settings.FieldSessionLifetimeInMinutes: - return m.AddedSessionLifetimeInMinutes() - case settings.FieldAgentReportFrequenceInMinutes: - return m.AddedAgentReportFrequenceInMinutes() - case settings.FieldProfilesApplicationFrequenceInMinutes: - return m.AddedProfilesApplicationFrequenceInMinutes() - case settings.FieldDefaultItemsPerPage: - return m.AddedDefaultItemsPerPage() - } - return nil, false +// ClearUseWinget clears the value of the "use_winget" field. +func (m *SettingsMutation) ClearUseWinget() { + m.use_winget = nil + m.clearedFields[settings.FieldUseWinget] = struct{}{} } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *SettingsMutation) AddField(name string, value ent.Value) error { - switch name { - case settings.FieldSMTPPort: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSMTPPort(v) - return nil - case settings.FieldUserCertYearsValid: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddUserCertYearsValid(v) - return nil - case settings.FieldNatsRequestTimeoutSeconds: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddNatsRequestTimeoutSeconds(v) - return nil - case settings.FieldRefreshTimeInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddRefreshTimeInMinutes(v) - return nil - case settings.FieldSessionLifetimeInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSessionLifetimeInMinutes(v) - return nil - case settings.FieldAgentReportFrequenceInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddAgentReportFrequenceInMinutes(v) - return nil - case settings.FieldProfilesApplicationFrequenceInMinutes: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddProfilesApplicationFrequenceInMinutes(v) - return nil - case settings.FieldDefaultItemsPerPage: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddDefaultItemsPerPage(v) - return nil - } - return fmt.Errorf("unknown Settings numeric field %s", name) +// UseWingetCleared returns if the "use_winget" field was cleared in this mutation. +func (m *SettingsMutation) UseWingetCleared() bool { + _, ok := m.clearedFields[settings.FieldUseWinget] + return ok } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *SettingsMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(settings.FieldLanguage) { - fields = append(fields, settings.FieldLanguage) - } - if m.FieldCleared(settings.FieldOrganization) { - fields = append(fields, settings.FieldOrganization) - } - if m.FieldCleared(settings.FieldPostalAddress) { - fields = append(fields, settings.FieldPostalAddress) - } - if m.FieldCleared(settings.FieldPostalCode) { - fields = append(fields, settings.FieldPostalCode) - } - if m.FieldCleared(settings.FieldLocality) { - fields = append(fields, settings.FieldLocality) - } - if m.FieldCleared(settings.FieldProvince) { - fields = append(fields, settings.FieldProvince) - } - if m.FieldCleared(settings.FieldState) { - fields = append(fields, settings.FieldState) - } - if m.FieldCleared(settings.FieldCountry) { - fields = append(fields, settings.FieldCountry) +// ResetUseWinget resets all changes to the "use_winget" field. +func (m *SettingsMutation) ResetUseWinget() { + m.use_winget = nil + delete(m.clearedFields, settings.FieldUseWinget) +} + +// SetUseFlatpak sets the "use_flatpak" field. +func (m *SettingsMutation) SetUseFlatpak(b bool) { + m.use_flatpak = &b +} + +// UseFlatpak returns the value of the "use_flatpak" field in the mutation. +func (m *SettingsMutation) UseFlatpak() (r bool, exists bool) { + v := m.use_flatpak + if v == nil { + return } - if m.FieldCleared(settings.FieldSMTPServer) { - fields = append(fields, settings.FieldSMTPServer) + return *v, true +} + +// OldUseFlatpak returns the old "use_flatpak" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldUseFlatpak(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUseFlatpak is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldSMTPPort) { - fields = append(fields, settings.FieldSMTPPort) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUseFlatpak requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldSMTPUser) { - fields = append(fields, settings.FieldSMTPUser) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUseFlatpak: %w", err) } - if m.FieldCleared(settings.FieldSMTPPassword) { - fields = append(fields, settings.FieldSMTPPassword) + return oldValue.UseFlatpak, nil +} + +// ClearUseFlatpak clears the value of the "use_flatpak" field. +func (m *SettingsMutation) ClearUseFlatpak() { + m.use_flatpak = nil + m.clearedFields[settings.FieldUseFlatpak] = struct{}{} +} + +// UseFlatpakCleared returns if the "use_flatpak" field was cleared in this mutation. +func (m *SettingsMutation) UseFlatpakCleared() bool { + _, ok := m.clearedFields[settings.FieldUseFlatpak] + return ok +} + +// ResetUseFlatpak resets all changes to the "use_flatpak" field. +func (m *SettingsMutation) ResetUseFlatpak() { + m.use_flatpak = nil + delete(m.clearedFields, settings.FieldUseFlatpak) +} + +// SetUseBrew sets the "use_brew" field. +func (m *SettingsMutation) SetUseBrew(b bool) { + m.use_brew = &b +} + +// UseBrew returns the value of the "use_brew" field in the mutation. +func (m *SettingsMutation) UseBrew() (r bool, exists bool) { + v := m.use_brew + if v == nil { + return } - if m.FieldCleared(settings.FieldSMTPAuth) { - fields = append(fields, settings.FieldSMTPAuth) + return *v, true +} + +// OldUseBrew returns the old "use_brew" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldUseBrew(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUseBrew is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldSMTPTLS) { - fields = append(fields, settings.FieldSMTPTLS) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUseBrew requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldSMTPStarttls) { - fields = append(fields, settings.FieldSMTPStarttls) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUseBrew: %w", err) } - if m.FieldCleared(settings.FieldNatsServer) { - fields = append(fields, settings.FieldNatsServer) + return oldValue.UseBrew, nil +} + +// ClearUseBrew clears the value of the "use_brew" field. +func (m *SettingsMutation) ClearUseBrew() { + m.use_brew = nil + m.clearedFields[settings.FieldUseBrew] = struct{}{} +} + +// UseBrewCleared returns if the "use_brew" field was cleared in this mutation. +func (m *SettingsMutation) UseBrewCleared() bool { + _, ok := m.clearedFields[settings.FieldUseBrew] + return ok +} + +// ResetUseBrew resets all changes to the "use_brew" field. +func (m *SettingsMutation) ResetUseBrew() { + m.use_brew = nil + delete(m.clearedFields, settings.FieldUseBrew) +} + +// SetDisableSftp sets the "disable_sftp" field. +func (m *SettingsMutation) SetDisableSftp(b bool) { + m.disable_sftp = &b +} + +// DisableSftp returns the value of the "disable_sftp" field in the mutation. +func (m *SettingsMutation) DisableSftp() (r bool, exists bool) { + v := m.disable_sftp + if v == nil { + return } - if m.FieldCleared(settings.FieldNatsPort) { - fields = append(fields, settings.FieldNatsPort) + return *v, true +} + +// OldDisableSftp returns the old "disable_sftp" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldDisableSftp(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDisableSftp is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldMessageFrom) { - fields = append(fields, settings.FieldMessageFrom) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDisableSftp requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldMaxUploadSize) { - fields = append(fields, settings.FieldMaxUploadSize) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDisableSftp: %w", err) } - if m.FieldCleared(settings.FieldUserCertYearsValid) { - fields = append(fields, settings.FieldUserCertYearsValid) + return oldValue.DisableSftp, nil +} + +// ClearDisableSftp clears the value of the "disable_sftp" field. +func (m *SettingsMutation) ClearDisableSftp() { + m.disable_sftp = nil + m.clearedFields[settings.FieldDisableSftp] = struct{}{} +} + +// DisableSftpCleared returns if the "disable_sftp" field was cleared in this mutation. +func (m *SettingsMutation) DisableSftpCleared() bool { + _, ok := m.clearedFields[settings.FieldDisableSftp] + return ok +} + +// ResetDisableSftp resets all changes to the "disable_sftp" field. +func (m *SettingsMutation) ResetDisableSftp() { + m.disable_sftp = nil + delete(m.clearedFields, settings.FieldDisableSftp) +} + +// SetDisableRemoteAssistance sets the "disable_remote_assistance" field. +func (m *SettingsMutation) SetDisableRemoteAssistance(b bool) { + m.disable_remote_assistance = &b +} + +// DisableRemoteAssistance returns the value of the "disable_remote_assistance" field in the mutation. +func (m *SettingsMutation) DisableRemoteAssistance() (r bool, exists bool) { + v := m.disable_remote_assistance + if v == nil { + return } - if m.FieldCleared(settings.FieldNatsRequestTimeoutSeconds) { - fields = append(fields, settings.FieldNatsRequestTimeoutSeconds) + return *v, true +} + +// OldDisableRemoteAssistance returns the old "disable_remote_assistance" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldDisableRemoteAssistance(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDisableRemoteAssistance is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldRefreshTimeInMinutes) { - fields = append(fields, settings.FieldRefreshTimeInMinutes) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDisableRemoteAssistance requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldSessionLifetimeInMinutes) { - fields = append(fields, settings.FieldSessionLifetimeInMinutes) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDisableRemoteAssistance: %w", err) } - if m.FieldCleared(settings.FieldUpdateChannel) { - fields = append(fields, settings.FieldUpdateChannel) + return oldValue.DisableRemoteAssistance, nil +} + +// ClearDisableRemoteAssistance clears the value of the "disable_remote_assistance" field. +func (m *SettingsMutation) ClearDisableRemoteAssistance() { + m.disable_remote_assistance = nil + m.clearedFields[settings.FieldDisableRemoteAssistance] = struct{}{} +} + +// DisableRemoteAssistanceCleared returns if the "disable_remote_assistance" field was cleared in this mutation. +func (m *SettingsMutation) DisableRemoteAssistanceCleared() bool { + _, ok := m.clearedFields[settings.FieldDisableRemoteAssistance] + return ok +} + +// ResetDisableRemoteAssistance resets all changes to the "disable_remote_assistance" field. +func (m *SettingsMutation) ResetDisableRemoteAssistance() { + m.disable_remote_assistance = nil + delete(m.clearedFields, settings.FieldDisableRemoteAssistance) +} + +// SetDetectRemoteAgents sets the "detect_remote_agents" field. +func (m *SettingsMutation) SetDetectRemoteAgents(b bool) { + m.detect_remote_agents = &b +} + +// DetectRemoteAgents returns the value of the "detect_remote_agents" field in the mutation. +func (m *SettingsMutation) DetectRemoteAgents() (r bool, exists bool) { + v := m.detect_remote_agents + if v == nil { + return } - if m.FieldCleared(settings.FieldCreated) { - fields = append(fields, settings.FieldCreated) + return *v, true +} + +// OldDetectRemoteAgents returns the old "detect_remote_agents" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldDetectRemoteAgents(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDetectRemoteAgents is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldModified) { - fields = append(fields, settings.FieldModified) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDetectRemoteAgents requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldAgentReportFrequenceInMinutes) { - fields = append(fields, settings.FieldAgentReportFrequenceInMinutes) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDetectRemoteAgents: %w", err) } - if m.FieldCleared(settings.FieldRequestVncPin) { - fields = append(fields, settings.FieldRequestVncPin) + return oldValue.DetectRemoteAgents, nil +} + +// ClearDetectRemoteAgents clears the value of the "detect_remote_agents" field. +func (m *SettingsMutation) ClearDetectRemoteAgents() { + m.detect_remote_agents = nil + m.clearedFields[settings.FieldDetectRemoteAgents] = struct{}{} +} + +// DetectRemoteAgentsCleared returns if the "detect_remote_agents" field was cleared in this mutation. +func (m *SettingsMutation) DetectRemoteAgentsCleared() bool { + _, ok := m.clearedFields[settings.FieldDetectRemoteAgents] + return ok +} + +// ResetDetectRemoteAgents resets all changes to the "detect_remote_agents" field. +func (m *SettingsMutation) ResetDetectRemoteAgents() { + m.detect_remote_agents = nil + delete(m.clearedFields, settings.FieldDetectRemoteAgents) +} + +// SetAutoAdmitAgents sets the "auto_admit_agents" field. +func (m *SettingsMutation) SetAutoAdmitAgents(b bool) { + m.auto_admit_agents = &b +} + +// AutoAdmitAgents returns the value of the "auto_admit_agents" field in the mutation. +func (m *SettingsMutation) AutoAdmitAgents() (r bool, exists bool) { + v := m.auto_admit_agents + if v == nil { + return } - if m.FieldCleared(settings.FieldProfilesApplicationFrequenceInMinutes) { - fields = append(fields, settings.FieldProfilesApplicationFrequenceInMinutes) + return *v, true +} + +// OldAutoAdmitAgents returns the old "auto_admit_agents" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldAutoAdmitAgents(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAutoAdmitAgents is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldUseWinget) { - fields = append(fields, settings.FieldUseWinget) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAutoAdmitAgents requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldUseFlatpak) { - fields = append(fields, settings.FieldUseFlatpak) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAutoAdmitAgents: %w", err) } - if m.FieldCleared(settings.FieldUseBrew) { - fields = append(fields, settings.FieldUseBrew) + return oldValue.AutoAdmitAgents, nil +} + +// ClearAutoAdmitAgents clears the value of the "auto_admit_agents" field. +func (m *SettingsMutation) ClearAutoAdmitAgents() { + m.auto_admit_agents = nil + m.clearedFields[settings.FieldAutoAdmitAgents] = struct{}{} +} + +// AutoAdmitAgentsCleared returns if the "auto_admit_agents" field was cleared in this mutation. +func (m *SettingsMutation) AutoAdmitAgentsCleared() bool { + _, ok := m.clearedFields[settings.FieldAutoAdmitAgents] + return ok +} + +// ResetAutoAdmitAgents resets all changes to the "auto_admit_agents" field. +func (m *SettingsMutation) ResetAutoAdmitAgents() { + m.auto_admit_agents = nil + delete(m.clearedFields, settings.FieldAutoAdmitAgents) +} + +// SetDefaultItemsPerPage sets the "default_items_per_page" field. +func (m *SettingsMutation) SetDefaultItemsPerPage(i int) { + m.default_items_per_page = &i + m.adddefault_items_per_page = nil +} + +// DefaultItemsPerPage returns the value of the "default_items_per_page" field in the mutation. +func (m *SettingsMutation) DefaultItemsPerPage() (r int, exists bool) { + v := m.default_items_per_page + if v == nil { + return } - if m.FieldCleared(settings.FieldDisableSftp) { - fields = append(fields, settings.FieldDisableSftp) + return *v, true +} + +// OldDefaultItemsPerPage returns the old "default_items_per_page" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldDefaultItemsPerPage(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDefaultItemsPerPage is only allowed on UpdateOne operations") } - if m.FieldCleared(settings.FieldDisableRemoteAssistance) { - fields = append(fields, settings.FieldDisableRemoteAssistance) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDefaultItemsPerPage requires an ID field in the mutation") } - if m.FieldCleared(settings.FieldDetectRemoteAgents) { - fields = append(fields, settings.FieldDetectRemoteAgents) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDefaultItemsPerPage: %w", err) } - if m.FieldCleared(settings.FieldAutoAdmitAgents) { - fields = append(fields, settings.FieldAutoAdmitAgents) + return oldValue.DefaultItemsPerPage, nil +} + +// AddDefaultItemsPerPage adds i to the "default_items_per_page" field. +func (m *SettingsMutation) AddDefaultItemsPerPage(i int) { + if m.adddefault_items_per_page != nil { + *m.adddefault_items_per_page += i + } else { + m.adddefault_items_per_page = &i } - if m.FieldCleared(settings.FieldDefaultItemsPerPage) { - fields = append(fields, settings.FieldDefaultItemsPerPage) +} + +// AddedDefaultItemsPerPage returns the value that was added to the "default_items_per_page" field in this mutation. +func (m *SettingsMutation) AddedDefaultItemsPerPage() (r int, exists bool) { + v := m.adddefault_items_per_page + if v == nil { + return } - return fields + return *v, true } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *SettingsMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// ClearDefaultItemsPerPage clears the value of the "default_items_per_page" field. +func (m *SettingsMutation) ClearDefaultItemsPerPage() { + m.default_items_per_page = nil + m.adddefault_items_per_page = nil + m.clearedFields[settings.FieldDefaultItemsPerPage] = struct{}{} +} + +// DefaultItemsPerPageCleared returns if the "default_items_per_page" field was cleared in this mutation. +func (m *SettingsMutation) DefaultItemsPerPageCleared() bool { + _, ok := m.clearedFields[settings.FieldDefaultItemsPerPage] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *SettingsMutation) ClearField(name string) error { - switch name { - case settings.FieldLanguage: - m.ClearLanguage() - return nil - case settings.FieldOrganization: - m.ClearOrganization() - return nil - case settings.FieldPostalAddress: - m.ClearPostalAddress() - return nil - case settings.FieldPostalCode: - m.ClearPostalCode() - return nil +// ResetDefaultItemsPerPage resets all changes to the "default_items_per_page" field. +func (m *SettingsMutation) ResetDefaultItemsPerPage() { + m.default_items_per_page = nil + m.adddefault_items_per_page = nil + delete(m.clearedFields, settings.FieldDefaultItemsPerPage) +} + +// SetTagID sets the "tag" edge to the Tag entity by id. +func (m *SettingsMutation) SetTagID(id int) { + m.tag = &id +} + +// ClearTag clears the "tag" edge to the Tag entity. +func (m *SettingsMutation) ClearTag() { + m.clearedtag = true +} + +// TagCleared reports if the "tag" edge to the Tag entity was cleared. +func (m *SettingsMutation) TagCleared() bool { + return m.clearedtag +} + +// TagID returns the "tag" edge ID in the mutation. +func (m *SettingsMutation) TagID() (id int, exists bool) { + if m.tag != nil { + return *m.tag, true + } + return +} + +// TagIDs returns the "tag" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TagID instead. It exists only for internal usage by the builders. +func (m *SettingsMutation) TagIDs() (ids []int) { + if id := m.tag; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTag resets all changes to the "tag" edge. +func (m *SettingsMutation) ResetTag() { + m.tag = nil + m.clearedtag = false +} + +// SetTenantID sets the "tenant" edge to the Tenant entity by id. +func (m *SettingsMutation) SetTenantID(id int) { + m.tenant = &id +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *SettingsMutation) ClearTenant() { + m.clearedtenant = true +} + +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *SettingsMutation) TenantCleared() bool { + return m.clearedtenant +} + +// TenantID returns the "tenant" edge ID in the mutation. +func (m *SettingsMutation) TenantID() (id int, exists bool) { + if m.tenant != nil { + return *m.tenant, true + } + return +} + +// TenantIDs returns the "tenant" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TenantID instead. It exists only for internal usage by the builders. +func (m *SettingsMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTenant resets all changes to the "tenant" edge. +func (m *SettingsMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false +} + +// Where appends a list predicates to the SettingsMutation builder. +func (m *SettingsMutation) Where(ps ...predicate.Settings) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the SettingsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *SettingsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Settings, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *SettingsMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *SettingsMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Settings). +func (m *SettingsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *SettingsMutation) Fields() []string { + fields := make([]string, 0, 37) + if m.language != nil { + fields = append(fields, settings.FieldLanguage) + } + if m.organization != nil { + fields = append(fields, settings.FieldOrganization) + } + if m.postal_address != nil { + fields = append(fields, settings.FieldPostalAddress) + } + if m.postal_code != nil { + fields = append(fields, settings.FieldPostalCode) + } + if m.locality != nil { + fields = append(fields, settings.FieldLocality) + } + if m.province != nil { + fields = append(fields, settings.FieldProvince) + } + if m.state != nil { + fields = append(fields, settings.FieldState) + } + if m.country != nil { + fields = append(fields, settings.FieldCountry) + } + if m.smtp_server != nil { + fields = append(fields, settings.FieldSMTPServer) + } + if m.smtp_port != nil { + fields = append(fields, settings.FieldSMTPPort) + } + if m.smtp_user != nil { + fields = append(fields, settings.FieldSMTPUser) + } + if m.smtp_password != nil { + fields = append(fields, settings.FieldSMTPPassword) + } + if m.smtp_auth != nil { + fields = append(fields, settings.FieldSMTPAuth) + } + if m.smtp_tls != nil { + fields = append(fields, settings.FieldSMTPTLS) + } + if m.smtp_starttls != nil { + fields = append(fields, settings.FieldSMTPStarttls) + } + if m.nats_server != nil { + fields = append(fields, settings.FieldNatsServer) + } + if m.nats_port != nil { + fields = append(fields, settings.FieldNatsPort) + } + if m.message_from != nil { + fields = append(fields, settings.FieldMessageFrom) + } + if m.max_upload_size != nil { + fields = append(fields, settings.FieldMaxUploadSize) + } + if m.user_cert_years_valid != nil { + fields = append(fields, settings.FieldUserCertYearsValid) + } + if m.nats_request_timeout_seconds != nil { + fields = append(fields, settings.FieldNatsRequestTimeoutSeconds) + } + if m.refresh_time_in_minutes != nil { + fields = append(fields, settings.FieldRefreshTimeInMinutes) + } + if m.session_lifetime_in_minutes != nil { + fields = append(fields, settings.FieldSessionLifetimeInMinutes) + } + if m.update_channel != nil { + fields = append(fields, settings.FieldUpdateChannel) + } + if m.created != nil { + fields = append(fields, settings.FieldCreated) + } + if m.modified != nil { + fields = append(fields, settings.FieldModified) + } + if m.agent_report_frequence_in_minutes != nil { + fields = append(fields, settings.FieldAgentReportFrequenceInMinutes) + } + if m.request_vnc_pin != nil { + fields = append(fields, settings.FieldRequestVncPin) + } + if m.profiles_application_frequence_in_minutes != nil { + fields = append(fields, settings.FieldProfilesApplicationFrequenceInMinutes) + } + if m.use_winget != nil { + fields = append(fields, settings.FieldUseWinget) + } + if m.use_flatpak != nil { + fields = append(fields, settings.FieldUseFlatpak) + } + if m.use_brew != nil { + fields = append(fields, settings.FieldUseBrew) + } + if m.disable_sftp != nil { + fields = append(fields, settings.FieldDisableSftp) + } + if m.disable_remote_assistance != nil { + fields = append(fields, settings.FieldDisableRemoteAssistance) + } + if m.detect_remote_agents != nil { + fields = append(fields, settings.FieldDetectRemoteAgents) + } + if m.auto_admit_agents != nil { + fields = append(fields, settings.FieldAutoAdmitAgents) + } + if m.default_items_per_page != nil { + fields = append(fields, settings.FieldDefaultItemsPerPage) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *SettingsMutation) Field(name string) (ent.Value, bool) { + switch name { + case settings.FieldLanguage: + return m.Language() + case settings.FieldOrganization: + return m.Organization() + case settings.FieldPostalAddress: + return m.PostalAddress() + case settings.FieldPostalCode: + return m.PostalCode() case settings.FieldLocality: - m.ClearLocality() - return nil + return m.Locality() case settings.FieldProvince: - m.ClearProvince() - return nil + return m.Province() case settings.FieldState: - m.ClearState() - return nil + return m.State() case settings.FieldCountry: - m.ClearCountry() - return nil + return m.Country() case settings.FieldSMTPServer: - m.ClearSMTPServer() - return nil + return m.SMTPServer() case settings.FieldSMTPPort: - m.ClearSMTPPort() - return nil + return m.SMTPPort() case settings.FieldSMTPUser: - m.ClearSMTPUser() - return nil + return m.SMTPUser() case settings.FieldSMTPPassword: - m.ClearSMTPPassword() - return nil + return m.SMTPPassword() case settings.FieldSMTPAuth: - m.ClearSMTPAuth() - return nil + return m.SMTPAuth() case settings.FieldSMTPTLS: - m.ClearSMTPTLS() - return nil + return m.SMTPTLS() case settings.FieldSMTPStarttls: - m.ClearSMTPStarttls() - return nil + return m.SMTPStarttls() case settings.FieldNatsServer: - m.ClearNatsServer() - return nil + return m.NatsServer() case settings.FieldNatsPort: - m.ClearNatsPort() - return nil + return m.NatsPort() case settings.FieldMessageFrom: - m.ClearMessageFrom() - return nil + return m.MessageFrom() case settings.FieldMaxUploadSize: - m.ClearMaxUploadSize() - return nil + return m.MaxUploadSize() case settings.FieldUserCertYearsValid: - m.ClearUserCertYearsValid() - return nil + return m.UserCertYearsValid() case settings.FieldNatsRequestTimeoutSeconds: - m.ClearNatsRequestTimeoutSeconds() - return nil + return m.NatsRequestTimeoutSeconds() case settings.FieldRefreshTimeInMinutes: - m.ClearRefreshTimeInMinutes() - return nil + return m.RefreshTimeInMinutes() case settings.FieldSessionLifetimeInMinutes: - m.ClearSessionLifetimeInMinutes() - return nil + return m.SessionLifetimeInMinutes() case settings.FieldUpdateChannel: - m.ClearUpdateChannel() - return nil + return m.UpdateChannel() case settings.FieldCreated: - m.ClearCreated() - return nil + return m.Created() case settings.FieldModified: - m.ClearModified() - return nil + return m.Modified() case settings.FieldAgentReportFrequenceInMinutes: - m.ClearAgentReportFrequenceInMinutes() - return nil + return m.AgentReportFrequenceInMinutes() case settings.FieldRequestVncPin: - m.ClearRequestVncPin() - return nil + return m.RequestVncPin() case settings.FieldProfilesApplicationFrequenceInMinutes: - m.ClearProfilesApplicationFrequenceInMinutes() - return nil + return m.ProfilesApplicationFrequenceInMinutes() case settings.FieldUseWinget: - m.ClearUseWinget() - return nil + return m.UseWinget() case settings.FieldUseFlatpak: - m.ClearUseFlatpak() - return nil + return m.UseFlatpak() case settings.FieldUseBrew: - m.ClearUseBrew() - return nil + return m.UseBrew() case settings.FieldDisableSftp: - m.ClearDisableSftp() - return nil + return m.DisableSftp() case settings.FieldDisableRemoteAssistance: - m.ClearDisableRemoteAssistance() - return nil + return m.DisableRemoteAssistance() case settings.FieldDetectRemoteAgents: - m.ClearDetectRemoteAgents() - return nil + return m.DetectRemoteAgents() case settings.FieldAutoAdmitAgents: - m.ClearAutoAdmitAgents() - return nil + return m.AutoAdmitAgents() case settings.FieldDefaultItemsPerPage: - m.ClearDefaultItemsPerPage() - return nil + return m.DefaultItemsPerPage() } - return fmt.Errorf("unknown Settings nullable field %s", name) + return nil, false } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *SettingsMutation) ResetField(name string) error { +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *SettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case settings.FieldLanguage: - m.ResetLanguage() - return nil + return m.OldLanguage(ctx) case settings.FieldOrganization: - m.ResetOrganization() - return nil + return m.OldOrganization(ctx) case settings.FieldPostalAddress: - m.ResetPostalAddress() - return nil + return m.OldPostalAddress(ctx) case settings.FieldPostalCode: - m.ResetPostalCode() - return nil + return m.OldPostalCode(ctx) case settings.FieldLocality: - m.ResetLocality() - return nil + return m.OldLocality(ctx) case settings.FieldProvince: - m.ResetProvince() - return nil + return m.OldProvince(ctx) case settings.FieldState: - m.ResetState() - return nil + return m.OldState(ctx) case settings.FieldCountry: - m.ResetCountry() - return nil + return m.OldCountry(ctx) case settings.FieldSMTPServer: - m.ResetSMTPServer() - return nil + return m.OldSMTPServer(ctx) case settings.FieldSMTPPort: - m.ResetSMTPPort() - return nil + return m.OldSMTPPort(ctx) case settings.FieldSMTPUser: - m.ResetSMTPUser() - return nil + return m.OldSMTPUser(ctx) case settings.FieldSMTPPassword: - m.ResetSMTPPassword() - return nil + return m.OldSMTPPassword(ctx) case settings.FieldSMTPAuth: - m.ResetSMTPAuth() - return nil + return m.OldSMTPAuth(ctx) case settings.FieldSMTPTLS: - m.ResetSMTPTLS() - return nil + return m.OldSMTPTLS(ctx) case settings.FieldSMTPStarttls: - m.ResetSMTPStarttls() - return nil + return m.OldSMTPStarttls(ctx) case settings.FieldNatsServer: - m.ResetNatsServer() - return nil + return m.OldNatsServer(ctx) case settings.FieldNatsPort: - m.ResetNatsPort() - return nil + return m.OldNatsPort(ctx) case settings.FieldMessageFrom: - m.ResetMessageFrom() - return nil + return m.OldMessageFrom(ctx) case settings.FieldMaxUploadSize: - m.ResetMaxUploadSize() - return nil + return m.OldMaxUploadSize(ctx) case settings.FieldUserCertYearsValid: - m.ResetUserCertYearsValid() - return nil + return m.OldUserCertYearsValid(ctx) case settings.FieldNatsRequestTimeoutSeconds: - m.ResetNatsRequestTimeoutSeconds() - return nil + return m.OldNatsRequestTimeoutSeconds(ctx) case settings.FieldRefreshTimeInMinutes: - m.ResetRefreshTimeInMinutes() - return nil + return m.OldRefreshTimeInMinutes(ctx) case settings.FieldSessionLifetimeInMinutes: - m.ResetSessionLifetimeInMinutes() - return nil + return m.OldSessionLifetimeInMinutes(ctx) case settings.FieldUpdateChannel: - m.ResetUpdateChannel() - return nil + return m.OldUpdateChannel(ctx) case settings.FieldCreated: - m.ResetCreated() - return nil + return m.OldCreated(ctx) case settings.FieldModified: - m.ResetModified() - return nil + return m.OldModified(ctx) case settings.FieldAgentReportFrequenceInMinutes: - m.ResetAgentReportFrequenceInMinutes() - return nil + return m.OldAgentReportFrequenceInMinutes(ctx) case settings.FieldRequestVncPin: - m.ResetRequestVncPin() - return nil + return m.OldRequestVncPin(ctx) case settings.FieldProfilesApplicationFrequenceInMinutes: - m.ResetProfilesApplicationFrequenceInMinutes() - return nil + return m.OldProfilesApplicationFrequenceInMinutes(ctx) case settings.FieldUseWinget: - m.ResetUseWinget() - return nil + return m.OldUseWinget(ctx) case settings.FieldUseFlatpak: - m.ResetUseFlatpak() - return nil + return m.OldUseFlatpak(ctx) case settings.FieldUseBrew: - m.ResetUseBrew() - return nil + return m.OldUseBrew(ctx) case settings.FieldDisableSftp: - m.ResetDisableSftp() - return nil + return m.OldDisableSftp(ctx) case settings.FieldDisableRemoteAssistance: - m.ResetDisableRemoteAssistance() - return nil + return m.OldDisableRemoteAssistance(ctx) case settings.FieldDetectRemoteAgents: - m.ResetDetectRemoteAgents() - return nil + return m.OldDetectRemoteAgents(ctx) case settings.FieldAutoAdmitAgents: - m.ResetAutoAdmitAgents() - return nil + return m.OldAutoAdmitAgents(ctx) case settings.FieldDefaultItemsPerPage: - m.ResetDefaultItemsPerPage() - return nil - } - return fmt.Errorf("unknown Settings field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *SettingsMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.tag != nil { - edges = append(edges, settings.EdgeTag) - } - if m.tenant != nil { - edges = append(edges, settings.EdgeTenant) + return m.OldDefaultItemsPerPage(ctx) } - return edges + return nil, fmt.Errorf("unknown Settings field %s", name) } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *SettingsMutation) AddedIDs(name string) []ent.Value { +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SettingsMutation) SetField(name string, value ent.Value) error { switch name { - case settings.EdgeTag: - if id := m.tag; id != nil { - return []ent.Value{*id} + case settings.FieldLanguage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) } - case settings.EdgeTenant: - if id := m.tenant; id != nil { - return []ent.Value{*id} + m.SetLanguage(v) + return nil + case settings.FieldOrganization: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *SettingsMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *SettingsMutation) RemovedIDs(name string) []ent.Value { - return nil + m.SetOrganization(v) + return nil + case settings.FieldPostalAddress: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPostalAddress(v) + return nil + case settings.FieldPostalCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPostalCode(v) + return nil + case settings.FieldLocality: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocality(v) + return nil + case settings.FieldProvince: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProvince(v) + return nil + case settings.FieldState: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetState(v) + return nil + case settings.FieldCountry: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCountry(v) + return nil + case settings.FieldSMTPServer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPServer(v) + return nil + case settings.FieldSMTPPort: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPPort(v) + return nil + case settings.FieldSMTPUser: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPUser(v) + return nil + case settings.FieldSMTPPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPPassword(v) + return nil + case settings.FieldSMTPAuth: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPAuth(v) + return nil + case settings.FieldSMTPTLS: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPTLS(v) + return nil + case settings.FieldSMTPStarttls: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSMTPStarttls(v) + return nil + case settings.FieldNatsServer: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNatsServer(v) + return nil + case settings.FieldNatsPort: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNatsPort(v) + return nil + case settings.FieldMessageFrom: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMessageFrom(v) + return nil + case settings.FieldMaxUploadSize: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMaxUploadSize(v) + return nil + case settings.FieldUserCertYearsValid: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserCertYearsValid(v) + return nil + case settings.FieldNatsRequestTimeoutSeconds: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNatsRequestTimeoutSeconds(v) + return nil + case settings.FieldRefreshTimeInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefreshTimeInMinutes(v) + return nil + case settings.FieldSessionLifetimeInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSessionLifetimeInMinutes(v) + return nil + case settings.FieldUpdateChannel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateChannel(v) + return nil + case settings.FieldCreated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreated(v) + return nil + case settings.FieldModified: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModified(v) + return nil + case settings.FieldAgentReportFrequenceInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAgentReportFrequenceInMinutes(v) + return nil + case settings.FieldRequestVncPin: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRequestVncPin(v) + return nil + case settings.FieldProfilesApplicationFrequenceInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProfilesApplicationFrequenceInMinutes(v) + return nil + case settings.FieldUseWinget: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUseWinget(v) + return nil + case settings.FieldUseFlatpak: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUseFlatpak(v) + return nil + case settings.FieldUseBrew: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUseBrew(v) + return nil + case settings.FieldDisableSftp: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDisableSftp(v) + return nil + case settings.FieldDisableRemoteAssistance: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDisableRemoteAssistance(v) + return nil + case settings.FieldDetectRemoteAgents: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDetectRemoteAgents(v) + return nil + case settings.FieldAutoAdmitAgents: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAutoAdmitAgents(v) + return nil + case settings.FieldDefaultItemsPerPage: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDefaultItemsPerPage(v) + return nil + } + return fmt.Errorf("unknown Settings field %s", name) } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SettingsMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedtag { - edges = append(edges, settings.EdgeTag) +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SettingsMutation) AddedFields() []string { + var fields []string + if m.addsmtp_port != nil { + fields = append(fields, settings.FieldSMTPPort) } - if m.clearedtenant { - edges = append(edges, settings.EdgeTenant) + if m.adduser_cert_years_valid != nil { + fields = append(fields, settings.FieldUserCertYearsValid) } - return edges + if m.addnats_request_timeout_seconds != nil { + fields = append(fields, settings.FieldNatsRequestTimeoutSeconds) + } + if m.addrefresh_time_in_minutes != nil { + fields = append(fields, settings.FieldRefreshTimeInMinutes) + } + if m.addsession_lifetime_in_minutes != nil { + fields = append(fields, settings.FieldSessionLifetimeInMinutes) + } + if m.addagent_report_frequence_in_minutes != nil { + fields = append(fields, settings.FieldAgentReportFrequenceInMinutes) + } + if m.addprofiles_application_frequence_in_minutes != nil { + fields = append(fields, settings.FieldProfilesApplicationFrequenceInMinutes) + } + if m.adddefault_items_per_page != nil { + fields = append(fields, settings.FieldDefaultItemsPerPage) + } + return fields } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *SettingsMutation) EdgeCleared(name string) bool { +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *SettingsMutation) AddedField(name string) (ent.Value, bool) { switch name { - case settings.EdgeTag: - return m.clearedtag - case settings.EdgeTenant: - return m.clearedtenant + case settings.FieldSMTPPort: + return m.AddedSMTPPort() + case settings.FieldUserCertYearsValid: + return m.AddedUserCertYearsValid() + case settings.FieldNatsRequestTimeoutSeconds: + return m.AddedNatsRequestTimeoutSeconds() + case settings.FieldRefreshTimeInMinutes: + return m.AddedRefreshTimeInMinutes() + case settings.FieldSessionLifetimeInMinutes: + return m.AddedSessionLifetimeInMinutes() + case settings.FieldAgentReportFrequenceInMinutes: + return m.AddedAgentReportFrequenceInMinutes() + case settings.FieldProfilesApplicationFrequenceInMinutes: + return m.AddedProfilesApplicationFrequenceInMinutes() + case settings.FieldDefaultItemsPerPage: + return m.AddedDefaultItemsPerPage() } - return false + return nil, false } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *SettingsMutation) ClearEdge(name string) error { +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SettingsMutation) AddField(name string, value ent.Value) error { switch name { - case settings.EdgeTag: - m.ClearTag() + case settings.FieldSMTPPort: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSMTPPort(v) return nil - case settings.EdgeTenant: - m.ClearTenant() + case settings.FieldUserCertYearsValid: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUserCertYearsValid(v) return nil - } - return fmt.Errorf("unknown Settings unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *SettingsMutation) ResetEdge(name string) error { - switch name { - case settings.EdgeTag: - m.ResetTag() + case settings.FieldNatsRequestTimeoutSeconds: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddNatsRequestTimeoutSeconds(v) return nil - case settings.EdgeTenant: - m.ResetTenant() + case settings.FieldRefreshTimeInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRefreshTimeInMinutes(v) + return nil + case settings.FieldSessionLifetimeInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSessionLifetimeInMinutes(v) + return nil + case settings.FieldAgentReportFrequenceInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAgentReportFrequenceInMinutes(v) + return nil + case settings.FieldProfilesApplicationFrequenceInMinutes: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddProfilesApplicationFrequenceInMinutes(v) + return nil + case settings.FieldDefaultItemsPerPage: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDefaultItemsPerPage(v) return nil } - return fmt.Errorf("unknown Settings edge %s", name) -} - -// ShareMutation represents an operation that mutates the Share nodes in the graph. -type ShareMutation struct { - config - op Op - typ string - id *int - name *string - description *string - _path *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Share, error) - predicates []predicate.Share + return fmt.Errorf("unknown Settings numeric field %s", name) } -var _ ent.Mutation = (*ShareMutation)(nil) - -// shareOption allows management of the mutation configuration using functional options. -type shareOption func(*ShareMutation) - -// newShareMutation creates new mutation for the Share entity. -func newShareMutation(c config, op Op, opts ...shareOption) *ShareMutation { - m := &ShareMutation{ - config: c, - op: op, - typ: TypeShare, - clearedFields: make(map[string]struct{}), +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SettingsMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(settings.FieldLanguage) { + fields = append(fields, settings.FieldLanguage) } - for _, opt := range opts { - opt(m) + if m.FieldCleared(settings.FieldOrganization) { + fields = append(fields, settings.FieldOrganization) } - return m -} - -// withShareID sets the ID field of the mutation. -func withShareID(id int) shareOption { - return func(m *ShareMutation) { - var ( - err error - once sync.Once - value *Share - ) - m.oldValue = func(ctx context.Context) (*Share, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Share.Get(ctx, id) - } - }) - return value, err - } - m.id = &id + if m.FieldCleared(settings.FieldPostalAddress) { + fields = append(fields, settings.FieldPostalAddress) } -} - -// withShare sets the old Share of the mutation. -func withShare(node *Share) shareOption { - return func(m *ShareMutation) { - m.oldValue = func(context.Context) (*Share, error) { - return node, nil - } - m.id = &node.ID + if m.FieldCleared(settings.FieldPostalCode) { + fields = append(fields, settings.FieldPostalCode) } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ShareMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ShareMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") + if m.FieldCleared(settings.FieldLocality) { + fields = append(fields, settings.FieldLocality) } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *ShareMutation) ID() (id int, exists bool) { - if m.id == nil { - return + if m.FieldCleared(settings.FieldProvince) { + fields = append(fields, settings.FieldProvince) } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *ShareMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Share.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + if m.FieldCleared(settings.FieldState) { + fields = append(fields, settings.FieldState) } -} - -// SetName sets the "name" field. -func (m *ShareMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *ShareMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return + if m.FieldCleared(settings.FieldCountry) { + fields = append(fields, settings.FieldCountry) } - return *v, true -} - -// OldName returns the old "name" field's value of the Share entity. -// If the Share object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ShareMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + if m.FieldCleared(settings.FieldSMTPServer) { + fields = append(fields, settings.FieldSMTPServer) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + if m.FieldCleared(settings.FieldSMTPPort) { + fields = append(fields, settings.FieldSMTPPort) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + if m.FieldCleared(settings.FieldSMTPUser) { + fields = append(fields, settings.FieldSMTPUser) } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *ShareMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *ShareMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *ShareMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return + if m.FieldCleared(settings.FieldSMTPPassword) { + fields = append(fields, settings.FieldSMTPPassword) } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Share entity. -// If the Share object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ShareMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + if m.FieldCleared(settings.FieldSMTPAuth) { + fields = append(fields, settings.FieldSMTPAuth) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + if m.FieldCleared(settings.FieldSMTPTLS) { + fields = append(fields, settings.FieldSMTPTLS) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + if m.FieldCleared(settings.FieldSMTPStarttls) { + fields = append(fields, settings.FieldSMTPStarttls) } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *ShareMutation) ResetDescription() { - m.description = nil -} - -// SetPath sets the "path" field. -func (m *ShareMutation) SetPath(s string) { - m._path = &s -} - -// Path returns the value of the "path" field in the mutation. -func (m *ShareMutation) Path() (r string, exists bool) { - v := m._path - if v == nil { - return + if m.FieldCleared(settings.FieldNatsServer) { + fields = append(fields, settings.FieldNatsServer) } - return *v, true -} - -// OldPath returns the old "path" field's value of the Share entity. -// If the Share object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ShareMutation) OldPath(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPath is only allowed on UpdateOne operations") + if m.FieldCleared(settings.FieldNatsPort) { + fields = append(fields, settings.FieldNatsPort) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPath requires an ID field in the mutation") + if m.FieldCleared(settings.FieldMessageFrom) { + fields = append(fields, settings.FieldMessageFrom) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPath: %w", err) + if m.FieldCleared(settings.FieldMaxUploadSize) { + fields = append(fields, settings.FieldMaxUploadSize) } - return oldValue.Path, nil -} - -// ClearPath clears the value of the "path" field. -func (m *ShareMutation) ClearPath() { - m._path = nil - m.clearedFields[share.FieldPath] = struct{}{} -} - -// PathCleared returns if the "path" field was cleared in this mutation. -func (m *ShareMutation) PathCleared() bool { - _, ok := m.clearedFields[share.FieldPath] - return ok -} - -// ResetPath resets all changes to the "path" field. -func (m *ShareMutation) ResetPath() { - m._path = nil - delete(m.clearedFields, share.FieldPath) -} - -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *ShareMutation) SetOwnerID(id string) { - m.owner = &id -} - -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *ShareMutation) ClearOwner() { - m.clearedowner = true -} - -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *ShareMutation) OwnerCleared() bool { - return m.clearedowner -} - -// OwnerID returns the "owner" edge ID in the mutation. -func (m *ShareMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true + if m.FieldCleared(settings.FieldUserCertYearsValid) { + fields = append(fields, settings.FieldUserCertYearsValid) } - return -} - -// OwnerIDs returns the "owner" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *ShareMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { - ids = append(ids, *id) + if m.FieldCleared(settings.FieldNatsRequestTimeoutSeconds) { + fields = append(fields, settings.FieldNatsRequestTimeoutSeconds) } - return -} - -// ResetOwner resets all changes to the "owner" edge. -func (m *ShareMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false -} - -// Where appends a list predicates to the ShareMutation builder. -func (m *ShareMutation) Where(ps ...predicate.Share) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ShareMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ShareMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Share, len(ps)) - for i := range ps { - p[i] = ps[i] + if m.FieldCleared(settings.FieldRefreshTimeInMinutes) { + fields = append(fields, settings.FieldRefreshTimeInMinutes) } - m.Where(p...) -} - -// Op returns the operation name. -func (m *ShareMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *ShareMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Share). -func (m *ShareMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *ShareMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.name != nil { - fields = append(fields, share.FieldName) + if m.FieldCleared(settings.FieldSessionLifetimeInMinutes) { + fields = append(fields, settings.FieldSessionLifetimeInMinutes) } - if m.description != nil { - fields = append(fields, share.FieldDescription) + if m.FieldCleared(settings.FieldUpdateChannel) { + fields = append(fields, settings.FieldUpdateChannel) } - if m._path != nil { - fields = append(fields, share.FieldPath) + if m.FieldCleared(settings.FieldCreated) { + fields = append(fields, settings.FieldCreated) } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *ShareMutation) Field(name string) (ent.Value, bool) { - switch name { - case share.FieldName: - return m.Name() - case share.FieldDescription: - return m.Description() - case share.FieldPath: - return m.Path() + if m.FieldCleared(settings.FieldModified) { + fields = append(fields, settings.FieldModified) } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *ShareMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case share.FieldName: - return m.OldName(ctx) - case share.FieldDescription: - return m.OldDescription(ctx) - case share.FieldPath: - return m.OldPath(ctx) + if m.FieldCleared(settings.FieldAgentReportFrequenceInMinutes) { + fields = append(fields, settings.FieldAgentReportFrequenceInMinutes) } - return nil, fmt.Errorf("unknown Share field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ShareMutation) SetField(name string, value ent.Value) error { - switch name { - case share.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case share.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case share.FieldPath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPath(v) - return nil + if m.FieldCleared(settings.FieldRequestVncPin) { + fields = append(fields, settings.FieldRequestVncPin) } - return fmt.Errorf("unknown Share field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *ShareMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *ShareMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ShareMutation) AddField(name string, value ent.Value) error { - switch name { + if m.FieldCleared(settings.FieldProfilesApplicationFrequenceInMinutes) { + fields = append(fields, settings.FieldProfilesApplicationFrequenceInMinutes) } - return fmt.Errorf("unknown Share numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *ShareMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(share.FieldPath) { - fields = append(fields, share.FieldPath) + if m.FieldCleared(settings.FieldUseWinget) { + fields = append(fields, settings.FieldUseWinget) + } + if m.FieldCleared(settings.FieldUseFlatpak) { + fields = append(fields, settings.FieldUseFlatpak) + } + if m.FieldCleared(settings.FieldUseBrew) { + fields = append(fields, settings.FieldUseBrew) + } + if m.FieldCleared(settings.FieldDisableSftp) { + fields = append(fields, settings.FieldDisableSftp) + } + if m.FieldCleared(settings.FieldDisableRemoteAssistance) { + fields = append(fields, settings.FieldDisableRemoteAssistance) + } + if m.FieldCleared(settings.FieldDetectRemoteAgents) { + fields = append(fields, settings.FieldDetectRemoteAgents) + } + if m.FieldCleared(settings.FieldAutoAdmitAgents) { + fields = append(fields, settings.FieldAutoAdmitAgents) + } + if m.FieldCleared(settings.FieldDefaultItemsPerPage) { + fields = append(fields, settings.FieldDefaultItemsPerPage) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ShareMutation) FieldCleared(name string) bool { +func (m *SettingsMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ShareMutation) ClearField(name string) error { +func (m *SettingsMutation) ClearField(name string) error { switch name { - case share.FieldPath: - m.ClearPath() + case settings.FieldLanguage: + m.ClearLanguage() + return nil + case settings.FieldOrganization: + m.ClearOrganization() + return nil + case settings.FieldPostalAddress: + m.ClearPostalAddress() + return nil + case settings.FieldPostalCode: + m.ClearPostalCode() + return nil + case settings.FieldLocality: + m.ClearLocality() + return nil + case settings.FieldProvince: + m.ClearProvince() + return nil + case settings.FieldState: + m.ClearState() + return nil + case settings.FieldCountry: + m.ClearCountry() + return nil + case settings.FieldSMTPServer: + m.ClearSMTPServer() + return nil + case settings.FieldSMTPPort: + m.ClearSMTPPort() + return nil + case settings.FieldSMTPUser: + m.ClearSMTPUser() + return nil + case settings.FieldSMTPPassword: + m.ClearSMTPPassword() + return nil + case settings.FieldSMTPAuth: + m.ClearSMTPAuth() + return nil + case settings.FieldSMTPTLS: + m.ClearSMTPTLS() + return nil + case settings.FieldSMTPStarttls: + m.ClearSMTPStarttls() + return nil + case settings.FieldNatsServer: + m.ClearNatsServer() + return nil + case settings.FieldNatsPort: + m.ClearNatsPort() + return nil + case settings.FieldMessageFrom: + m.ClearMessageFrom() + return nil + case settings.FieldMaxUploadSize: + m.ClearMaxUploadSize() + return nil + case settings.FieldUserCertYearsValid: + m.ClearUserCertYearsValid() + return nil + case settings.FieldNatsRequestTimeoutSeconds: + m.ClearNatsRequestTimeoutSeconds() + return nil + case settings.FieldRefreshTimeInMinutes: + m.ClearRefreshTimeInMinutes() + return nil + case settings.FieldSessionLifetimeInMinutes: + m.ClearSessionLifetimeInMinutes() + return nil + case settings.FieldUpdateChannel: + m.ClearUpdateChannel() + return nil + case settings.FieldCreated: + m.ClearCreated() + return nil + case settings.FieldModified: + m.ClearModified() + return nil + case settings.FieldAgentReportFrequenceInMinutes: + m.ClearAgentReportFrequenceInMinutes() + return nil + case settings.FieldRequestVncPin: + m.ClearRequestVncPin() + return nil + case settings.FieldProfilesApplicationFrequenceInMinutes: + m.ClearProfilesApplicationFrequenceInMinutes() + return nil + case settings.FieldUseWinget: + m.ClearUseWinget() + return nil + case settings.FieldUseFlatpak: + m.ClearUseFlatpak() + return nil + case settings.FieldUseBrew: + m.ClearUseBrew() + return nil + case settings.FieldDisableSftp: + m.ClearDisableSftp() + return nil + case settings.FieldDisableRemoteAssistance: + m.ClearDisableRemoteAssistance() + return nil + case settings.FieldDetectRemoteAgents: + m.ClearDetectRemoteAgents() + return nil + case settings.FieldAutoAdmitAgents: + m.ClearAutoAdmitAgents() + return nil + case settings.FieldDefaultItemsPerPage: + m.ClearDefaultItemsPerPage() return nil } - return fmt.Errorf("unknown Share nullable field %s", name) + return fmt.Errorf("unknown Settings nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ShareMutation) ResetField(name string) error { +func (m *SettingsMutation) ResetField(name string) error { switch name { - case share.FieldName: - m.ResetName() + case settings.FieldLanguage: + m.ResetLanguage() return nil - case share.FieldDescription: - m.ResetDescription() + case settings.FieldOrganization: + m.ResetOrganization() return nil - case share.FieldPath: - m.ResetPath() + case settings.FieldPostalAddress: + m.ResetPostalAddress() return nil - } - return fmt.Errorf("unknown Share field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *ShareMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, share.EdgeOwner) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *ShareMutation) AddedIDs(name string) []ent.Value { - switch name { - case share.EdgeOwner: - if id := m.owner; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *ShareMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges -} - + case settings.FieldPostalCode: + m.ResetPostalCode() + return nil + case settings.FieldLocality: + m.ResetLocality() + return nil + case settings.FieldProvince: + m.ResetProvince() + return nil + case settings.FieldState: + m.ResetState() + return nil + case settings.FieldCountry: + m.ResetCountry() + return nil + case settings.FieldSMTPServer: + m.ResetSMTPServer() + return nil + case settings.FieldSMTPPort: + m.ResetSMTPPort() + return nil + case settings.FieldSMTPUser: + m.ResetSMTPUser() + return nil + case settings.FieldSMTPPassword: + m.ResetSMTPPassword() + return nil + case settings.FieldSMTPAuth: + m.ResetSMTPAuth() + return nil + case settings.FieldSMTPTLS: + m.ResetSMTPTLS() + return nil + case settings.FieldSMTPStarttls: + m.ResetSMTPStarttls() + return nil + case settings.FieldNatsServer: + m.ResetNatsServer() + return nil + case settings.FieldNatsPort: + m.ResetNatsPort() + return nil + case settings.FieldMessageFrom: + m.ResetMessageFrom() + return nil + case settings.FieldMaxUploadSize: + m.ResetMaxUploadSize() + return nil + case settings.FieldUserCertYearsValid: + m.ResetUserCertYearsValid() + return nil + case settings.FieldNatsRequestTimeoutSeconds: + m.ResetNatsRequestTimeoutSeconds() + return nil + case settings.FieldRefreshTimeInMinutes: + m.ResetRefreshTimeInMinutes() + return nil + case settings.FieldSessionLifetimeInMinutes: + m.ResetSessionLifetimeInMinutes() + return nil + case settings.FieldUpdateChannel: + m.ResetUpdateChannel() + return nil + case settings.FieldCreated: + m.ResetCreated() + return nil + case settings.FieldModified: + m.ResetModified() + return nil + case settings.FieldAgentReportFrequenceInMinutes: + m.ResetAgentReportFrequenceInMinutes() + return nil + case settings.FieldRequestVncPin: + m.ResetRequestVncPin() + return nil + case settings.FieldProfilesApplicationFrequenceInMinutes: + m.ResetProfilesApplicationFrequenceInMinutes() + return nil + case settings.FieldUseWinget: + m.ResetUseWinget() + return nil + case settings.FieldUseFlatpak: + m.ResetUseFlatpak() + return nil + case settings.FieldUseBrew: + m.ResetUseBrew() + return nil + case settings.FieldDisableSftp: + m.ResetDisableSftp() + return nil + case settings.FieldDisableRemoteAssistance: + m.ResetDisableRemoteAssistance() + return nil + case settings.FieldDetectRemoteAgents: + m.ResetDetectRemoteAgents() + return nil + case settings.FieldAutoAdmitAgents: + m.ResetAutoAdmitAgents() + return nil + case settings.FieldDefaultItemsPerPage: + m.ResetDefaultItemsPerPage() + return nil + } + return fmt.Errorf("unknown Settings field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SettingsMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.tag != nil { + edges = append(edges, settings.EdgeTag) + } + if m.tenant != nil { + edges = append(edges, settings.EdgeTenant) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SettingsMutation) AddedIDs(name string) []ent.Value { + switch name { + case settings.EdgeTag: + if id := m.tag; id != nil { + return []ent.Value{*id} + } + case settings.EdgeTenant: + if id := m.tenant; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SettingsMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ShareMutation) RemovedIDs(name string) []ent.Value { +func (m *SettingsMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ShareMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, share.EdgeOwner) +func (m *SettingsMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedtag { + edges = append(edges, settings.EdgeTag) + } + if m.clearedtenant { + edges = append(edges, settings.EdgeTenant) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ShareMutation) EdgeCleared(name string) bool { +func (m *SettingsMutation) EdgeCleared(name string) bool { switch name { - case share.EdgeOwner: - return m.clearedowner + case settings.EdgeTag: + return m.clearedtag + case settings.EdgeTenant: + return m.clearedtenant } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ShareMutation) ClearEdge(name string) error { +func (m *SettingsMutation) ClearEdge(name string) error { switch name { - case share.EdgeOwner: - m.ClearOwner() + case settings.EdgeTag: + m.ClearTag() + return nil + case settings.EdgeTenant: + m.ClearTenant() return nil } - return fmt.Errorf("unknown Share unique edge %s", name) + return fmt.Errorf("unknown Settings unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ShareMutation) ResetEdge(name string) error { +func (m *SettingsMutation) ResetEdge(name string) error { switch name { - case share.EdgeOwner: - m.ResetOwner() + case settings.EdgeTag: + m.ResetTag() + return nil + case settings.EdgeTenant: + m.ResetTenant() return nil } - return fmt.Errorf("unknown Share edge %s", name) + return fmt.Errorf("unknown Settings edge %s", name) } -// SiteMutation represents an operation that mutates the Site nodes in the graph. -type SiteMutation struct { +// ShareMutation represents an operation that mutates the Share nodes in the graph. +type ShareMutation struct { config - op Op - typ string - id *int - description *string - is_default *bool - domain *string - created *time.Time - modified *time.Time - clearedFields map[string]struct{} - tenant *int - clearedtenant bool - agents map[string]struct{} - removedagents map[string]struct{} - clearedagents bool - profiles map[int]struct{} - removedprofiles map[int]struct{} - clearedprofiles bool - done bool - oldValue func(context.Context) (*Site, error) - predicates []predicate.Site + op Op + typ string + id *int + name *string + description *string + _path *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Share, error) + predicates []predicate.Share } -var _ ent.Mutation = (*SiteMutation)(nil) +var _ ent.Mutation = (*ShareMutation)(nil) -// siteOption allows management of the mutation configuration using functional options. -type siteOption func(*SiteMutation) +// shareOption allows management of the mutation configuration using functional options. +type shareOption func(*ShareMutation) -// newSiteMutation creates new mutation for the Site entity. -func newSiteMutation(c config, op Op, opts ...siteOption) *SiteMutation { - m := &SiteMutation{ +// newShareMutation creates new mutation for the Share entity. +func newShareMutation(c config, op Op, opts ...shareOption) *ShareMutation { + m := &ShareMutation{ config: c, op: op, - typ: TypeSite, + typ: TypeShare, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -27507,20 +29168,20 @@ func newSiteMutation(c config, op Op, opts ...siteOption) *SiteMutation { return m } -// withSiteID sets the ID field of the mutation. -func withSiteID(id int) siteOption { - return func(m *SiteMutation) { +// withShareID sets the ID field of the mutation. +func withShareID(id int) shareOption { + return func(m *ShareMutation) { var ( err error once sync.Once - value *Site + value *Share ) - m.oldValue = func(ctx context.Context) (*Site, error) { + m.oldValue = func(ctx context.Context) (*Share, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Site.Get(ctx, id) + value, err = m.Client().Share.Get(ctx, id) } }) return value, err @@ -27529,10 +29190,10 @@ func withSiteID(id int) siteOption { } } -// withSite sets the old Site of the mutation. -func withSite(node *Site) siteOption { - return func(m *SiteMutation) { - m.oldValue = func(context.Context) (*Site, error) { +// withShare sets the old Share of the mutation. +func withShare(node *Share) shareOption { + return func(m *ShareMutation) { + m.oldValue = func(context.Context) (*Share, error) { return node, nil } m.id = &node.ID @@ -27541,7 +29202,7 @@ func withSite(node *Site) siteOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m SiteMutation) Client() *Client { +func (m ShareMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -27549,7 +29210,7 @@ func (m SiteMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m SiteMutation) Tx() (*Tx, error) { +func (m ShareMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -27560,7 +29221,7 @@ func (m SiteMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SiteMutation) ID() (id int, exists bool) { +func (m *ShareMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -27571,7 +29232,7 @@ func (m *SiteMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SiteMutation) IDs(ctx context.Context) ([]int, error) { +func (m *ShareMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -27580,453 +29241,215 @@ func (m *SiteMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Site.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Share.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDescription sets the "description" field. -func (m *SiteMutation) SetDescription(s string) { - m.description = &s +// SetName sets the "name" field. +func (m *ShareMutation) SetName(s string) { + m.name = &s } -// Description returns the value of the "description" field in the mutation. -func (m *SiteMutation) Description() (r string, exists bool) { - v := m.description +// Name returns the value of the "name" field in the mutation. +func (m *ShareMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the Site entity. -// If the Site object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the Share entity. +// If the Share object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SiteMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *ShareMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *SiteMutation) ClearDescription() { - m.description = nil - m.clearedFields[site.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *SiteMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[site.FieldDescription] - return ok + return oldValue.Name, nil } -// ResetDescription resets all changes to the "description" field. -func (m *SiteMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, site.FieldDescription) +// ResetName resets all changes to the "name" field. +func (m *ShareMutation) ResetName() { + m.name = nil } -// SetIsDefault sets the "is_default" field. -func (m *SiteMutation) SetIsDefault(b bool) { - m.is_default = &b +// SetDescription sets the "description" field. +func (m *ShareMutation) SetDescription(s string) { + m.description = &s } -// IsDefault returns the value of the "is_default" field in the mutation. -func (m *SiteMutation) IsDefault() (r bool, exists bool) { - v := m.is_default +// Description returns the value of the "description" field in the mutation. +func (m *ShareMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldIsDefault returns the old "is_default" field's value of the Site entity. -// If the Site object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the Share entity. +// If the Share object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SiteMutation) OldIsDefault(ctx context.Context) (v bool, err error) { +func (m *ShareMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsDefault requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.IsDefault, nil -} - -// ClearIsDefault clears the value of the "is_default" field. -func (m *SiteMutation) ClearIsDefault() { - m.is_default = nil - m.clearedFields[site.FieldIsDefault] = struct{}{} -} - -// IsDefaultCleared returns if the "is_default" field was cleared in this mutation. -func (m *SiteMutation) IsDefaultCleared() bool { - _, ok := m.clearedFields[site.FieldIsDefault] - return ok + return oldValue.Description, nil } -// ResetIsDefault resets all changes to the "is_default" field. -func (m *SiteMutation) ResetIsDefault() { - m.is_default = nil - delete(m.clearedFields, site.FieldIsDefault) +// ResetDescription resets all changes to the "description" field. +func (m *ShareMutation) ResetDescription() { + m.description = nil } -// SetDomain sets the "domain" field. -func (m *SiteMutation) SetDomain(s string) { - m.domain = &s +// SetPath sets the "path" field. +func (m *ShareMutation) SetPath(s string) { + m._path = &s } -// Domain returns the value of the "domain" field in the mutation. -func (m *SiteMutation) Domain() (r string, exists bool) { - v := m.domain +// Path returns the value of the "path" field in the mutation. +func (m *ShareMutation) Path() (r string, exists bool) { + v := m._path if v == nil { return } return *v, true } -// OldDomain returns the old "domain" field's value of the Site entity. -// If the Site object wasn't provided to the builder, the object is fetched from the database. +// OldPath returns the old "path" field's value of the Share entity. +// If the Share object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SiteMutation) OldDomain(ctx context.Context) (v string, err error) { +func (m *ShareMutation) OldPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDomain is only allowed on UpdateOne operations") + return v, errors.New("OldPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDomain requires an ID field in the mutation") + return v, errors.New("OldPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDomain: %w", err) + return v, fmt.Errorf("querying old value for OldPath: %w", err) } - return oldValue.Domain, nil + return oldValue.Path, nil } -// ClearDomain clears the value of the "domain" field. -func (m *SiteMutation) ClearDomain() { - m.domain = nil - m.clearedFields[site.FieldDomain] = struct{}{} +// ClearPath clears the value of the "path" field. +func (m *ShareMutation) ClearPath() { + m._path = nil + m.clearedFields[share.FieldPath] = struct{}{} } -// DomainCleared returns if the "domain" field was cleared in this mutation. -func (m *SiteMutation) DomainCleared() bool { - _, ok := m.clearedFields[site.FieldDomain] +// PathCleared returns if the "path" field was cleared in this mutation. +func (m *ShareMutation) PathCleared() bool { + _, ok := m.clearedFields[share.FieldPath] return ok } -// ResetDomain resets all changes to the "domain" field. -func (m *SiteMutation) ResetDomain() { - m.domain = nil - delete(m.clearedFields, site.FieldDomain) -} - -// SetCreated sets the "created" field. -func (m *SiteMutation) SetCreated(t time.Time) { - m.created = &t +// ResetPath resets all changes to the "path" field. +func (m *ShareMutation) ResetPath() { + m._path = nil + delete(m.clearedFields, share.FieldPath) } -// Created returns the value of the "created" field in the mutation. -func (m *SiteMutation) Created() (r time.Time, exists bool) { - v := m.created - if v == nil { - return - } - return *v, true +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *ShareMutation) SetOwnerID(id string) { + m.owner = &id } -// OldCreated returns the old "created" field's value of the Site entity. -// If the Site object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SiteMutation) OldCreated(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreated is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreated requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreated: %w", err) - } - return oldValue.Created, nil +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *ShareMutation) ClearOwner() { + m.clearedowner = true } -// ClearCreated clears the value of the "created" field. -func (m *SiteMutation) ClearCreated() { - m.created = nil - m.clearedFields[site.FieldCreated] = struct{}{} +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *ShareMutation) OwnerCleared() bool { + return m.clearedowner } -// CreatedCleared returns if the "created" field was cleared in this mutation. -func (m *SiteMutation) CreatedCleared() bool { - _, ok := m.clearedFields[site.FieldCreated] - return ok +// OwnerID returns the "owner" edge ID in the mutation. +func (m *ShareMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true + } + return } -// ResetCreated resets all changes to the "created" field. -func (m *SiteMutation) ResetCreated() { - m.created = nil - delete(m.clearedFields, site.FieldCreated) +// OwnerIDs returns the "owner" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *ShareMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { + ids = append(ids, *id) + } + return } -// SetModified sets the "modified" field. -func (m *SiteMutation) SetModified(t time.Time) { - m.modified = &t +// ResetOwner resets all changes to the "owner" edge. +func (m *ShareMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// Modified returns the value of the "modified" field in the mutation. -func (m *SiteMutation) Modified() (r time.Time, exists bool) { - v := m.modified - if v == nil { - return - } - return *v, true +// Where appends a list predicates to the ShareMutation builder. +func (m *ShareMutation) Where(ps ...predicate.Share) { + m.predicates = append(m.predicates, ps...) } -// OldModified returns the old "modified" field's value of the Site entity. -// If the Site object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SiteMutation) OldModified(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModified is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModified requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModified: %w", err) +// WhereP appends storage-level predicates to the ShareMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ShareMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Share, len(ps)) + for i := range ps { + p[i] = ps[i] } - return oldValue.Modified, nil + m.Where(p...) } -// ClearModified clears the value of the "modified" field. -func (m *SiteMutation) ClearModified() { - m.modified = nil - m.clearedFields[site.FieldModified] = struct{}{} +// Op returns the operation name. +func (m *ShareMutation) Op() Op { + return m.op } -// ModifiedCleared returns if the "modified" field was cleared in this mutation. -func (m *SiteMutation) ModifiedCleared() bool { - _, ok := m.clearedFields[site.FieldModified] - return ok +// SetOp allows setting the mutation operation. +func (m *ShareMutation) SetOp(op Op) { + m.op = op } -// ResetModified resets all changes to the "modified" field. -func (m *SiteMutation) ResetModified() { - m.modified = nil - delete(m.clearedFields, site.FieldModified) -} - -// SetTenantID sets the "tenant" edge to the Tenant entity by id. -func (m *SiteMutation) SetTenantID(id int) { - m.tenant = &id -} - -// ClearTenant clears the "tenant" edge to the Tenant entity. -func (m *SiteMutation) ClearTenant() { - m.clearedtenant = true -} - -// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. -func (m *SiteMutation) TenantCleared() bool { - return m.clearedtenant -} - -// TenantID returns the "tenant" edge ID in the mutation. -func (m *SiteMutation) TenantID() (id int, exists bool) { - if m.tenant != nil { - return *m.tenant, true - } - return -} - -// TenantIDs returns the "tenant" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TenantID instead. It exists only for internal usage by the builders. -func (m *SiteMutation) TenantIDs() (ids []int) { - if id := m.tenant; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetTenant resets all changes to the "tenant" edge. -func (m *SiteMutation) ResetTenant() { - m.tenant = nil - m.clearedtenant = false -} - -// AddAgentIDs adds the "agents" edge to the Agent entity by ids. -func (m *SiteMutation) AddAgentIDs(ids ...string) { - if m.agents == nil { - m.agents = make(map[string]struct{}) - } - for i := range ids { - m.agents[ids[i]] = struct{}{} - } -} - -// ClearAgents clears the "agents" edge to the Agent entity. -func (m *SiteMutation) ClearAgents() { - m.clearedagents = true -} - -// AgentsCleared reports if the "agents" edge to the Agent entity was cleared. -func (m *SiteMutation) AgentsCleared() bool { - return m.clearedagents -} - -// RemoveAgentIDs removes the "agents" edge to the Agent entity by IDs. -func (m *SiteMutation) RemoveAgentIDs(ids ...string) { - if m.removedagents == nil { - m.removedagents = make(map[string]struct{}) - } - for i := range ids { - delete(m.agents, ids[i]) - m.removedagents[ids[i]] = struct{}{} - } -} - -// RemovedAgents returns the removed IDs of the "agents" edge to the Agent entity. -func (m *SiteMutation) RemovedAgentsIDs() (ids []string) { - for id := range m.removedagents { - ids = append(ids, id) - } - return -} - -// AgentsIDs returns the "agents" edge IDs in the mutation. -func (m *SiteMutation) AgentsIDs() (ids []string) { - for id := range m.agents { - ids = append(ids, id) - } - return -} - -// ResetAgents resets all changes to the "agents" edge. -func (m *SiteMutation) ResetAgents() { - m.agents = nil - m.clearedagents = false - m.removedagents = nil -} - -// AddProfileIDs adds the "profiles" edge to the Profile entity by ids. -func (m *SiteMutation) AddProfileIDs(ids ...int) { - if m.profiles == nil { - m.profiles = make(map[int]struct{}) - } - for i := range ids { - m.profiles[ids[i]] = struct{}{} - } -} - -// ClearProfiles clears the "profiles" edge to the Profile entity. -func (m *SiteMutation) ClearProfiles() { - m.clearedprofiles = true -} - -// ProfilesCleared reports if the "profiles" edge to the Profile entity was cleared. -func (m *SiteMutation) ProfilesCleared() bool { - return m.clearedprofiles -} - -// RemoveProfileIDs removes the "profiles" edge to the Profile entity by IDs. -func (m *SiteMutation) RemoveProfileIDs(ids ...int) { - if m.removedprofiles == nil { - m.removedprofiles = make(map[int]struct{}) - } - for i := range ids { - delete(m.profiles, ids[i]) - m.removedprofiles[ids[i]] = struct{}{} - } -} - -// RemovedProfiles returns the removed IDs of the "profiles" edge to the Profile entity. -func (m *SiteMutation) RemovedProfilesIDs() (ids []int) { - for id := range m.removedprofiles { - ids = append(ids, id) - } - return -} - -// ProfilesIDs returns the "profiles" edge IDs in the mutation. -func (m *SiteMutation) ProfilesIDs() (ids []int) { - for id := range m.profiles { - ids = append(ids, id) - } - return -} - -// ResetProfiles resets all changes to the "profiles" edge. -func (m *SiteMutation) ResetProfiles() { - m.profiles = nil - m.clearedprofiles = false - m.removedprofiles = nil -} - -// Where appends a list predicates to the SiteMutation builder. -func (m *SiteMutation) Where(ps ...predicate.Site) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the SiteMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SiteMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Site, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *SiteMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *SiteMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Site). -func (m *SiteMutation) Type() string { - return m.typ +// Type returns the node type of this mutation (Share). +func (m *ShareMutation) Type() string { + return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *SiteMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.description != nil { - fields = append(fields, site.FieldDescription) - } - if m.is_default != nil { - fields = append(fields, site.FieldIsDefault) - } - if m.domain != nil { - fields = append(fields, site.FieldDomain) +func (m *ShareMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.name != nil { + fields = append(fields, share.FieldName) } - if m.created != nil { - fields = append(fields, site.FieldCreated) + if m.description != nil { + fields = append(fields, share.FieldDescription) } - if m.modified != nil { - fields = append(fields, site.FieldModified) + if m._path != nil { + fields = append(fields, share.FieldPath) } return fields } @@ -28034,18 +29457,14 @@ func (m *SiteMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *SiteMutation) Field(name string) (ent.Value, bool) { +func (m *ShareMutation) Field(name string) (ent.Value, bool) { switch name { - case site.FieldDescription: + case share.FieldName: + return m.Name() + case share.FieldDescription: return m.Description() - case site.FieldIsDefault: - return m.IsDefault() - case site.FieldDomain: - return m.Domain() - case site.FieldCreated: - return m.Created() - case site.FieldModified: - return m.Modified() + case share.FieldPath: + return m.Path() } return nil, false } @@ -28053,320 +29472,228 @@ func (m *SiteMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *SiteMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ShareMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case site.FieldDescription: + case share.FieldName: + return m.OldName(ctx) + case share.FieldDescription: return m.OldDescription(ctx) - case site.FieldIsDefault: - return m.OldIsDefault(ctx) - case site.FieldDomain: - return m.OldDomain(ctx) - case site.FieldCreated: - return m.OldCreated(ctx) - case site.FieldModified: - return m.OldModified(ctx) + case share.FieldPath: + return m.OldPath(ctx) } - return nil, fmt.Errorf("unknown Site field %s", name) + return nil, fmt.Errorf("unknown Share field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *SiteMutation) SetField(name string, value ent.Value) error { +func (m *ShareMutation) SetField(name string, value ent.Value) error { switch name { - case site.FieldDescription: + case share.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) - return nil - case site.FieldIsDefault: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIsDefault(v) + m.SetName(v) return nil - case site.FieldDomain: + case share.FieldDescription: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDomain(v) - return nil - case site.FieldCreated: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreated(v) + m.SetDescription(v) return nil - case site.FieldModified: - v, ok := value.(time.Time) + case share.FieldPath: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModified(v) + m.SetPath(v) return nil } - return fmt.Errorf("unknown Site field %s", name) + return fmt.Errorf("unknown Share field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *SiteMutation) AddedFields() []string { +func (m *ShareMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *SiteMutation) AddedField(name string) (ent.Value, bool) { +func (m *ShareMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *SiteMutation) AddField(name string, value ent.Value) error { +func (m *ShareMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Site numeric field %s", name) + return fmt.Errorf("unknown Share numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *SiteMutation) ClearedFields() []string { +func (m *ShareMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(site.FieldDescription) { - fields = append(fields, site.FieldDescription) - } - if m.FieldCleared(site.FieldIsDefault) { - fields = append(fields, site.FieldIsDefault) - } - if m.FieldCleared(site.FieldDomain) { - fields = append(fields, site.FieldDomain) - } - if m.FieldCleared(site.FieldCreated) { - fields = append(fields, site.FieldCreated) - } - if m.FieldCleared(site.FieldModified) { - fields = append(fields, site.FieldModified) + if m.FieldCleared(share.FieldPath) { + fields = append(fields, share.FieldPath) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *SiteMutation) FieldCleared(name string) bool { +func (m *ShareMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *SiteMutation) ClearField(name string) error { +func (m *ShareMutation) ClearField(name string) error { switch name { - case site.FieldDescription: - m.ClearDescription() - return nil - case site.FieldIsDefault: - m.ClearIsDefault() - return nil - case site.FieldDomain: - m.ClearDomain() - return nil - case site.FieldCreated: - m.ClearCreated() - return nil - case site.FieldModified: - m.ClearModified() + case share.FieldPath: + m.ClearPath() return nil } - return fmt.Errorf("unknown Site nullable field %s", name) + return fmt.Errorf("unknown Share nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *SiteMutation) ResetField(name string) error { +func (m *ShareMutation) ResetField(name string) error { switch name { - case site.FieldDescription: - m.ResetDescription() - return nil - case site.FieldIsDefault: - m.ResetIsDefault() - return nil - case site.FieldDomain: - m.ResetDomain() + case share.FieldName: + m.ResetName() return nil - case site.FieldCreated: - m.ResetCreated() + case share.FieldDescription: + m.ResetDescription() return nil - case site.FieldModified: - m.ResetModified() + case share.FieldPath: + m.ResetPath() return nil } - return fmt.Errorf("unknown Site field %s", name) + return fmt.Errorf("unknown Share field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *SiteMutation) AddedEdges() []string { - edges := make([]string, 0, 3) - if m.tenant != nil { - edges = append(edges, site.EdgeTenant) - } - if m.agents != nil { - edges = append(edges, site.EdgeAgents) - } - if m.profiles != nil { - edges = append(edges, site.EdgeProfiles) +func (m *ShareMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.owner != nil { + edges = append(edges, share.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *SiteMutation) AddedIDs(name string) []ent.Value { +func (m *ShareMutation) AddedIDs(name string) []ent.Value { switch name { - case site.EdgeTenant: - if id := m.tenant; id != nil { + case share.EdgeOwner: + if id := m.owner; id != nil { return []ent.Value{*id} } - case site.EdgeAgents: - ids := make([]ent.Value, 0, len(m.agents)) - for id := range m.agents { - ids = append(ids, id) - } - return ids - case site.EdgeProfiles: - ids := make([]ent.Value, 0, len(m.profiles)) - for id := range m.profiles { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *SiteMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) - if m.removedagents != nil { - edges = append(edges, site.EdgeAgents) - } - if m.removedprofiles != nil { - edges = append(edges, site.EdgeProfiles) - } +func (m *ShareMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *SiteMutation) RemovedIDs(name string) []ent.Value { - switch name { - case site.EdgeAgents: - ids := make([]ent.Value, 0, len(m.removedagents)) - for id := range m.removedagents { - ids = append(ids, id) - } - return ids - case site.EdgeProfiles: - ids := make([]ent.Value, 0, len(m.removedprofiles)) - for id := range m.removedprofiles { - ids = append(ids, id) - } - return ids - } +func (m *ShareMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SiteMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) - if m.clearedtenant { - edges = append(edges, site.EdgeTenant) - } - if m.clearedagents { - edges = append(edges, site.EdgeAgents) - } - if m.clearedprofiles { - edges = append(edges, site.EdgeProfiles) +func (m *ShareMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedowner { + edges = append(edges, share.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *SiteMutation) EdgeCleared(name string) bool { +func (m *ShareMutation) EdgeCleared(name string) bool { switch name { - case site.EdgeTenant: - return m.clearedtenant - case site.EdgeAgents: - return m.clearedagents - case site.EdgeProfiles: - return m.clearedprofiles + case share.EdgeOwner: + return m.clearedowner } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *SiteMutation) ClearEdge(name string) error { +func (m *ShareMutation) ClearEdge(name string) error { switch name { - case site.EdgeTenant: - m.ClearTenant() + case share.EdgeOwner: + m.ClearOwner() return nil } - return fmt.Errorf("unknown Site unique edge %s", name) + return fmt.Errorf("unknown Share unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *SiteMutation) ResetEdge(name string) error { +func (m *ShareMutation) ResetEdge(name string) error { switch name { - case site.EdgeTenant: - m.ResetTenant() - return nil - case site.EdgeAgents: - m.ResetAgents() - return nil - case site.EdgeProfiles: - m.ResetProfiles() + case share.EdgeOwner: + m.ResetOwner() return nil } - return fmt.Errorf("unknown Site edge %s", name) + return fmt.Errorf("unknown Share edge %s", name) } -// SystemUpdateMutation represents an operation that mutates the SystemUpdate nodes in the graph. -type SystemUpdateMutation struct { +// SiteMutation represents an operation that mutates the Site nodes in the graph. +type SiteMutation struct { config - op Op - typ string - id *int - system_update_status *string - last_install *time.Time - last_search *time.Time - pending_updates *bool - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*SystemUpdate, error) - predicates []predicate.SystemUpdate + op Op + typ string + id *int + description *string + is_default *bool + domain *string + created *time.Time + modified *time.Time + clearedFields map[string]struct{} + tenant *int + clearedtenant bool + agents map[string]struct{} + removedagents map[string]struct{} + clearedagents bool + profiles map[int]struct{} + removedprofiles map[int]struct{} + clearedprofiles bool + enrollment_tokens map[int]struct{} + removedenrollment_tokens map[int]struct{} + clearedenrollment_tokens bool + done bool + oldValue func(context.Context) (*Site, error) + predicates []predicate.Site } -var _ ent.Mutation = (*SystemUpdateMutation)(nil) +var _ ent.Mutation = (*SiteMutation)(nil) -// systemupdateOption allows management of the mutation configuration using functional options. -type systemupdateOption func(*SystemUpdateMutation) +// siteOption allows management of the mutation configuration using functional options. +type siteOption func(*SiteMutation) -// newSystemUpdateMutation creates new mutation for the SystemUpdate entity. -func newSystemUpdateMutation(c config, op Op, opts ...systemupdateOption) *SystemUpdateMutation { - m := &SystemUpdateMutation{ +// newSiteMutation creates new mutation for the Site entity. +func newSiteMutation(c config, op Op, opts ...siteOption) *SiteMutation { + m := &SiteMutation{ config: c, op: op, - typ: TypeSystemUpdate, + typ: TypeSite, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -28375,20 +29702,20 @@ func newSystemUpdateMutation(c config, op Op, opts ...systemupdateOption) *Syste return m } -// withSystemUpdateID sets the ID field of the mutation. -func withSystemUpdateID(id int) systemupdateOption { - return func(m *SystemUpdateMutation) { +// withSiteID sets the ID field of the mutation. +func withSiteID(id int) siteOption { + return func(m *SiteMutation) { var ( err error once sync.Once - value *SystemUpdate + value *Site ) - m.oldValue = func(ctx context.Context) (*SystemUpdate, error) { + m.oldValue = func(ctx context.Context) (*Site, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().SystemUpdate.Get(ctx, id) + value, err = m.Client().Site.Get(ctx, id) } }) return value, err @@ -28397,10 +29724,10 @@ func withSystemUpdateID(id int) systemupdateOption { } } -// withSystemUpdate sets the old SystemUpdate of the mutation. -func withSystemUpdate(node *SystemUpdate) systemupdateOption { - return func(m *SystemUpdateMutation) { - m.oldValue = func(context.Context) (*SystemUpdate, error) { +// withSite sets the old Site of the mutation. +func withSite(node *Site) siteOption { + return func(m *SiteMutation) { + m.oldValue = func(context.Context) (*Site, error) { return node, nil } m.id = &node.ID @@ -28409,7 +29736,7 @@ func withSystemUpdate(node *SystemUpdate) systemupdateOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m SystemUpdateMutation) Client() *Client { +func (m SiteMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -28417,7 +29744,7 @@ func (m SystemUpdateMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m SystemUpdateMutation) Tx() (*Tx, error) { +func (m SiteMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -28428,7 +29755,7 @@ func (m SystemUpdateMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *SystemUpdateMutation) ID() (id int, exists bool) { +func (m *SiteMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -28439,7 +29766,7 @@ func (m *SystemUpdateMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *SystemUpdateMutation) IDs(ctx context.Context) ([]int, error) { +func (m *SiteMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -28448,204 +29775,467 @@ func (m *SystemUpdateMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().SystemUpdate.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Site.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetSystemUpdateStatus sets the "system_update_status" field. -func (m *SystemUpdateMutation) SetSystemUpdateStatus(s string) { - m.system_update_status = &s +// SetDescription sets the "description" field. +func (m *SiteMutation) SetDescription(s string) { + m.description = &s } -// SystemUpdateStatus returns the value of the "system_update_status" field in the mutation. -func (m *SystemUpdateMutation) SystemUpdateStatus() (r string, exists bool) { - v := m.system_update_status +// Description returns the value of the "description" field in the mutation. +func (m *SiteMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldSystemUpdateStatus returns the old "system_update_status" field's value of the SystemUpdate entity. -// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the Site entity. +// If the Site object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SystemUpdateMutation) OldSystemUpdateStatus(ctx context.Context) (v string, err error) { +func (m *SiteMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSystemUpdateStatus is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSystemUpdateStatus requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSystemUpdateStatus: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.SystemUpdateStatus, nil + return oldValue.Description, nil } -// ResetSystemUpdateStatus resets all changes to the "system_update_status" field. -func (m *SystemUpdateMutation) ResetSystemUpdateStatus() { - m.system_update_status = nil +// ClearDescription clears the value of the "description" field. +func (m *SiteMutation) ClearDescription() { + m.description = nil + m.clearedFields[site.FieldDescription] = struct{}{} } -// SetLastInstall sets the "last_install" field. -func (m *SystemUpdateMutation) SetLastInstall(t time.Time) { - m.last_install = &t +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *SiteMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[site.FieldDescription] + return ok } -// LastInstall returns the value of the "last_install" field in the mutation. -func (m *SystemUpdateMutation) LastInstall() (r time.Time, exists bool) { - v := m.last_install +// ResetDescription resets all changes to the "description" field. +func (m *SiteMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, site.FieldDescription) +} + +// SetIsDefault sets the "is_default" field. +func (m *SiteMutation) SetIsDefault(b bool) { + m.is_default = &b +} + +// IsDefault returns the value of the "is_default" field in the mutation. +func (m *SiteMutation) IsDefault() (r bool, exists bool) { + v := m.is_default if v == nil { return } return *v, true } -// OldLastInstall returns the old "last_install" field's value of the SystemUpdate entity. -// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. +// OldIsDefault returns the old "is_default" field's value of the Site entity. +// If the Site object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SystemUpdateMutation) OldLastInstall(ctx context.Context) (v time.Time, err error) { +func (m *SiteMutation) OldIsDefault(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastInstall is only allowed on UpdateOne operations") + return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastInstall requires an ID field in the mutation") + return v, errors.New("OldIsDefault requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLastInstall: %w", err) + return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) } - return oldValue.LastInstall, nil + return oldValue.IsDefault, nil } -// ResetLastInstall resets all changes to the "last_install" field. -func (m *SystemUpdateMutation) ResetLastInstall() { - m.last_install = nil +// ClearIsDefault clears the value of the "is_default" field. +func (m *SiteMutation) ClearIsDefault() { + m.is_default = nil + m.clearedFields[site.FieldIsDefault] = struct{}{} } -// SetLastSearch sets the "last_search" field. -func (m *SystemUpdateMutation) SetLastSearch(t time.Time) { - m.last_search = &t +// IsDefaultCleared returns if the "is_default" field was cleared in this mutation. +func (m *SiteMutation) IsDefaultCleared() bool { + _, ok := m.clearedFields[site.FieldIsDefault] + return ok } -// LastSearch returns the value of the "last_search" field in the mutation. -func (m *SystemUpdateMutation) LastSearch() (r time.Time, exists bool) { - v := m.last_search +// ResetIsDefault resets all changes to the "is_default" field. +func (m *SiteMutation) ResetIsDefault() { + m.is_default = nil + delete(m.clearedFields, site.FieldIsDefault) +} + +// SetDomain sets the "domain" field. +func (m *SiteMutation) SetDomain(s string) { + m.domain = &s +} + +// Domain returns the value of the "domain" field in the mutation. +func (m *SiteMutation) Domain() (r string, exists bool) { + v := m.domain if v == nil { return } return *v, true } -// OldLastSearch returns the old "last_search" field's value of the SystemUpdate entity. -// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. +// OldDomain returns the old "domain" field's value of the Site entity. +// If the Site object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SystemUpdateMutation) OldLastSearch(ctx context.Context) (v time.Time, err error) { +func (m *SiteMutation) OldDomain(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastSearch is only allowed on UpdateOne operations") + return v, errors.New("OldDomain is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastSearch requires an ID field in the mutation") + return v, errors.New("OldDomain requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLastSearch: %w", err) + return v, fmt.Errorf("querying old value for OldDomain: %w", err) } - return oldValue.LastSearch, nil + return oldValue.Domain, nil } -// ResetLastSearch resets all changes to the "last_search" field. -func (m *SystemUpdateMutation) ResetLastSearch() { - m.last_search = nil +// ClearDomain clears the value of the "domain" field. +func (m *SiteMutation) ClearDomain() { + m.domain = nil + m.clearedFields[site.FieldDomain] = struct{}{} } -// SetPendingUpdates sets the "pending_updates" field. -func (m *SystemUpdateMutation) SetPendingUpdates(b bool) { - m.pending_updates = &b +// DomainCleared returns if the "domain" field was cleared in this mutation. +func (m *SiteMutation) DomainCleared() bool { + _, ok := m.clearedFields[site.FieldDomain] + return ok } -// PendingUpdates returns the value of the "pending_updates" field in the mutation. -func (m *SystemUpdateMutation) PendingUpdates() (r bool, exists bool) { - v := m.pending_updates +// ResetDomain resets all changes to the "domain" field. +func (m *SiteMutation) ResetDomain() { + m.domain = nil + delete(m.clearedFields, site.FieldDomain) +} + +// SetCreated sets the "created" field. +func (m *SiteMutation) SetCreated(t time.Time) { + m.created = &t +} + +// Created returns the value of the "created" field in the mutation. +func (m *SiteMutation) Created() (r time.Time, exists bool) { + v := m.created if v == nil { return } return *v, true } -// OldPendingUpdates returns the old "pending_updates" field's value of the SystemUpdate entity. -// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. +// OldCreated returns the old "created" field's value of the Site entity. +// If the Site object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *SystemUpdateMutation) OldPendingUpdates(ctx context.Context) (v bool, err error) { +func (m *SiteMutation) OldCreated(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPendingUpdates is only allowed on UpdateOne operations") + return v, errors.New("OldCreated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPendingUpdates requires an ID field in the mutation") + return v, errors.New("OldCreated requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPendingUpdates: %w", err) + return v, fmt.Errorf("querying old value for OldCreated: %w", err) } - return oldValue.PendingUpdates, nil + return oldValue.Created, nil } -// ResetPendingUpdates resets all changes to the "pending_updates" field. -func (m *SystemUpdateMutation) ResetPendingUpdates() { - m.pending_updates = nil +// ClearCreated clears the value of the "created" field. +func (m *SiteMutation) ClearCreated() { + m.created = nil + m.clearedFields[site.FieldCreated] = struct{}{} } -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *SystemUpdateMutation) SetOwnerID(id string) { - m.owner = &id +// CreatedCleared returns if the "created" field was cleared in this mutation. +func (m *SiteMutation) CreatedCleared() bool { + _, ok := m.clearedFields[site.FieldCreated] + return ok } -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *SystemUpdateMutation) ClearOwner() { - m.clearedowner = true +// ResetCreated resets all changes to the "created" field. +func (m *SiteMutation) ResetCreated() { + m.created = nil + delete(m.clearedFields, site.FieldCreated) } -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *SystemUpdateMutation) OwnerCleared() bool { - return m.clearedowner +// SetModified sets the "modified" field. +func (m *SiteMutation) SetModified(t time.Time) { + m.modified = &t } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *SystemUpdateMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true +// Modified returns the value of the "modified" field in the mutation. +func (m *SiteMutation) Modified() (r time.Time, exists bool) { + v := m.modified + if v == nil { + return + } + return *v, true +} + +// OldModified returns the old "modified" field's value of the Site entity. +// If the Site object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SiteMutation) OldModified(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModified is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModified requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModified: %w", err) + } + return oldValue.Modified, nil +} + +// ClearModified clears the value of the "modified" field. +func (m *SiteMutation) ClearModified() { + m.modified = nil + m.clearedFields[site.FieldModified] = struct{}{} +} + +// ModifiedCleared returns if the "modified" field was cleared in this mutation. +func (m *SiteMutation) ModifiedCleared() bool { + _, ok := m.clearedFields[site.FieldModified] + return ok +} + +// ResetModified resets all changes to the "modified" field. +func (m *SiteMutation) ResetModified() { + m.modified = nil + delete(m.clearedFields, site.FieldModified) +} + +// SetTenantID sets the "tenant" edge to the Tenant entity by id. +func (m *SiteMutation) SetTenantID(id int) { + m.tenant = &id +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *SiteMutation) ClearTenant() { + m.clearedtenant = true +} + +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *SiteMutation) TenantCleared() bool { + return m.clearedtenant +} + +// TenantID returns the "tenant" edge ID in the mutation. +func (m *SiteMutation) TenantID() (id int, exists bool) { + if m.tenant != nil { + return *m.tenant, true } return } -// OwnerIDs returns the "owner" edge IDs in the mutation. +// TenantIDs returns the "tenant" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *SystemUpdateMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { +// TenantID instead. It exists only for internal usage by the builders. +func (m *SiteMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { ids = append(ids, *id) } return } -// ResetOwner resets all changes to the "owner" edge. -func (m *SystemUpdateMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ResetTenant resets all changes to the "tenant" edge. +func (m *SiteMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false } -// Where appends a list predicates to the SystemUpdateMutation builder. -func (m *SystemUpdateMutation) Where(ps ...predicate.SystemUpdate) { +// AddAgentIDs adds the "agents" edge to the Agent entity by ids. +func (m *SiteMutation) AddAgentIDs(ids ...string) { + if m.agents == nil { + m.agents = make(map[string]struct{}) + } + for i := range ids { + m.agents[ids[i]] = struct{}{} + } +} + +// ClearAgents clears the "agents" edge to the Agent entity. +func (m *SiteMutation) ClearAgents() { + m.clearedagents = true +} + +// AgentsCleared reports if the "agents" edge to the Agent entity was cleared. +func (m *SiteMutation) AgentsCleared() bool { + return m.clearedagents +} + +// RemoveAgentIDs removes the "agents" edge to the Agent entity by IDs. +func (m *SiteMutation) RemoveAgentIDs(ids ...string) { + if m.removedagents == nil { + m.removedagents = make(map[string]struct{}) + } + for i := range ids { + delete(m.agents, ids[i]) + m.removedagents[ids[i]] = struct{}{} + } +} + +// RemovedAgents returns the removed IDs of the "agents" edge to the Agent entity. +func (m *SiteMutation) RemovedAgentsIDs() (ids []string) { + for id := range m.removedagents { + ids = append(ids, id) + } + return +} + +// AgentsIDs returns the "agents" edge IDs in the mutation. +func (m *SiteMutation) AgentsIDs() (ids []string) { + for id := range m.agents { + ids = append(ids, id) + } + return +} + +// ResetAgents resets all changes to the "agents" edge. +func (m *SiteMutation) ResetAgents() { + m.agents = nil + m.clearedagents = false + m.removedagents = nil +} + +// AddProfileIDs adds the "profiles" edge to the Profile entity by ids. +func (m *SiteMutation) AddProfileIDs(ids ...int) { + if m.profiles == nil { + m.profiles = make(map[int]struct{}) + } + for i := range ids { + m.profiles[ids[i]] = struct{}{} + } +} + +// ClearProfiles clears the "profiles" edge to the Profile entity. +func (m *SiteMutation) ClearProfiles() { + m.clearedprofiles = true +} + +// ProfilesCleared reports if the "profiles" edge to the Profile entity was cleared. +func (m *SiteMutation) ProfilesCleared() bool { + return m.clearedprofiles +} + +// RemoveProfileIDs removes the "profiles" edge to the Profile entity by IDs. +func (m *SiteMutation) RemoveProfileIDs(ids ...int) { + if m.removedprofiles == nil { + m.removedprofiles = make(map[int]struct{}) + } + for i := range ids { + delete(m.profiles, ids[i]) + m.removedprofiles[ids[i]] = struct{}{} + } +} + +// RemovedProfiles returns the removed IDs of the "profiles" edge to the Profile entity. +func (m *SiteMutation) RemovedProfilesIDs() (ids []int) { + for id := range m.removedprofiles { + ids = append(ids, id) + } + return +} + +// ProfilesIDs returns the "profiles" edge IDs in the mutation. +func (m *SiteMutation) ProfilesIDs() (ids []int) { + for id := range m.profiles { + ids = append(ids, id) + } + return +} + +// ResetProfiles resets all changes to the "profiles" edge. +func (m *SiteMutation) ResetProfiles() { + m.profiles = nil + m.clearedprofiles = false + m.removedprofiles = nil +} + +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by ids. +func (m *SiteMutation) AddEnrollmentTokenIDs(ids ...int) { + if m.enrollment_tokens == nil { + m.enrollment_tokens = make(map[int]struct{}) + } + for i := range ids { + m.enrollment_tokens[ids[i]] = struct{}{} + } +} + +// ClearEnrollmentTokens clears the "enrollment_tokens" edge to the EnrollmentToken entity. +func (m *SiteMutation) ClearEnrollmentTokens() { + m.clearedenrollment_tokens = true +} + +// EnrollmentTokensCleared reports if the "enrollment_tokens" edge to the EnrollmentToken entity was cleared. +func (m *SiteMutation) EnrollmentTokensCleared() bool { + return m.clearedenrollment_tokens +} + +// RemoveEnrollmentTokenIDs removes the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (m *SiteMutation) RemoveEnrollmentTokenIDs(ids ...int) { + if m.removedenrollment_tokens == nil { + m.removedenrollment_tokens = make(map[int]struct{}) + } + for i := range ids { + delete(m.enrollment_tokens, ids[i]) + m.removedenrollment_tokens[ids[i]] = struct{}{} + } +} + +// RemovedEnrollmentTokens returns the removed IDs of the "enrollment_tokens" edge to the EnrollmentToken entity. +func (m *SiteMutation) RemovedEnrollmentTokensIDs() (ids []int) { + for id := range m.removedenrollment_tokens { + ids = append(ids, id) + } + return +} + +// EnrollmentTokensIDs returns the "enrollment_tokens" edge IDs in the mutation. +func (m *SiteMutation) EnrollmentTokensIDs() (ids []int) { + for id := range m.enrollment_tokens { + ids = append(ids, id) + } + return +} + +// ResetEnrollmentTokens resets all changes to the "enrollment_tokens" edge. +func (m *SiteMutation) ResetEnrollmentTokens() { + m.enrollment_tokens = nil + m.clearedenrollment_tokens = false + m.removedenrollment_tokens = nil +} + +// Where appends a list predicates to the SiteMutation builder. +func (m *SiteMutation) Where(ps ...predicate.Site) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the SystemUpdateMutation builder. Using this method, +// WhereP appends storage-level predicates to the SiteMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *SystemUpdateMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.SystemUpdate, len(ps)) +func (m *SiteMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Site, len(ps)) for i := range ps { p[i] = ps[i] } @@ -28653,36 +30243,39 @@ func (m *SystemUpdateMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *SystemUpdateMutation) Op() Op { +func (m *SiteMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *SystemUpdateMutation) SetOp(op Op) { +func (m *SiteMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (SystemUpdate). -func (m *SystemUpdateMutation) Type() string { +// Type returns the node type of this mutation (Site). +func (m *SiteMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *SystemUpdateMutation) Fields() []string { - fields := make([]string, 0, 4) - if m.system_update_status != nil { - fields = append(fields, systemupdate.FieldSystemUpdateStatus) +func (m *SiteMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.description != nil { + fields = append(fields, site.FieldDescription) } - if m.last_install != nil { - fields = append(fields, systemupdate.FieldLastInstall) + if m.is_default != nil { + fields = append(fields, site.FieldIsDefault) } - if m.last_search != nil { - fields = append(fields, systemupdate.FieldLastSearch) + if m.domain != nil { + fields = append(fields, site.FieldDomain) } - if m.pending_updates != nil { - fields = append(fields, systemupdate.FieldPendingUpdates) + if m.created != nil { + fields = append(fields, site.FieldCreated) + } + if m.modified != nil { + fields = append(fields, site.FieldModified) } return fields } @@ -28690,16 +30283,18 @@ func (m *SystemUpdateMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *SystemUpdateMutation) Field(name string) (ent.Value, bool) { +func (m *SiteMutation) Field(name string) (ent.Value, bool) { switch name { - case systemupdate.FieldSystemUpdateStatus: - return m.SystemUpdateStatus() - case systemupdate.FieldLastInstall: - return m.LastInstall() - case systemupdate.FieldLastSearch: - return m.LastSearch() - case systemupdate.FieldPendingUpdates: - return m.PendingUpdates() + case site.FieldDescription: + return m.Description() + case site.FieldIsDefault: + return m.IsDefault() + case site.FieldDomain: + return m.Domain() + case site.FieldCreated: + return m.Created() + case site.FieldModified: + return m.Modified() } return nil, false } @@ -28707,231 +30302,346 @@ func (m *SystemUpdateMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *SystemUpdateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *SiteMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case systemupdate.FieldSystemUpdateStatus: - return m.OldSystemUpdateStatus(ctx) - case systemupdate.FieldLastInstall: - return m.OldLastInstall(ctx) - case systemupdate.FieldLastSearch: - return m.OldLastSearch(ctx) - case systemupdate.FieldPendingUpdates: - return m.OldPendingUpdates(ctx) + case site.FieldDescription: + return m.OldDescription(ctx) + case site.FieldIsDefault: + return m.OldIsDefault(ctx) + case site.FieldDomain: + return m.OldDomain(ctx) + case site.FieldCreated: + return m.OldCreated(ctx) + case site.FieldModified: + return m.OldModified(ctx) } - return nil, fmt.Errorf("unknown SystemUpdate field %s", name) + return nil, fmt.Errorf("unknown Site field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *SystemUpdateMutation) SetField(name string, value ent.Value) error { +func (m *SiteMutation) SetField(name string, value ent.Value) error { switch name { - case systemupdate.FieldSystemUpdateStatus: + case site.FieldDescription: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSystemUpdateStatus(v) + m.SetDescription(v) return nil - case systemupdate.FieldLastInstall: - v, ok := value.(time.Time) + case site.FieldIsDefault: + v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetLastInstall(v) + m.SetIsDefault(v) return nil - case systemupdate.FieldLastSearch: + case site.FieldDomain: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDomain(v) + return nil + case site.FieldCreated: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetLastSearch(v) + m.SetCreated(v) return nil - case systemupdate.FieldPendingUpdates: - v, ok := value.(bool) + case site.FieldModified: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPendingUpdates(v) + m.SetModified(v) return nil } - return fmt.Errorf("unknown SystemUpdate field %s", name) + return fmt.Errorf("unknown Site field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *SystemUpdateMutation) AddedFields() []string { +func (m *SiteMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *SystemUpdateMutation) AddedField(name string) (ent.Value, bool) { +func (m *SiteMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *SystemUpdateMutation) AddField(name string, value ent.Value) error { +func (m *SiteMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown SystemUpdate numeric field %s", name) + return fmt.Errorf("unknown Site numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *SystemUpdateMutation) ClearedFields() []string { - return nil +func (m *SiteMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(site.FieldDescription) { + fields = append(fields, site.FieldDescription) + } + if m.FieldCleared(site.FieldIsDefault) { + fields = append(fields, site.FieldIsDefault) + } + if m.FieldCleared(site.FieldDomain) { + fields = append(fields, site.FieldDomain) + } + if m.FieldCleared(site.FieldCreated) { + fields = append(fields, site.FieldCreated) + } + if m.FieldCleared(site.FieldModified) { + fields = append(fields, site.FieldModified) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *SystemUpdateMutation) FieldCleared(name string) bool { +func (m *SiteMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *SystemUpdateMutation) ClearField(name string) error { - return fmt.Errorf("unknown SystemUpdate nullable field %s", name) +func (m *SiteMutation) ClearField(name string) error { + switch name { + case site.FieldDescription: + m.ClearDescription() + return nil + case site.FieldIsDefault: + m.ClearIsDefault() + return nil + case site.FieldDomain: + m.ClearDomain() + return nil + case site.FieldCreated: + m.ClearCreated() + return nil + case site.FieldModified: + m.ClearModified() + return nil + } + return fmt.Errorf("unknown Site nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *SystemUpdateMutation) ResetField(name string) error { +func (m *SiteMutation) ResetField(name string) error { switch name { - case systemupdate.FieldSystemUpdateStatus: - m.ResetSystemUpdateStatus() + case site.FieldDescription: + m.ResetDescription() return nil - case systemupdate.FieldLastInstall: - m.ResetLastInstall() + case site.FieldIsDefault: + m.ResetIsDefault() return nil - case systemupdate.FieldLastSearch: - m.ResetLastSearch() + case site.FieldDomain: + m.ResetDomain() return nil - case systemupdate.FieldPendingUpdates: - m.ResetPendingUpdates() + case site.FieldCreated: + m.ResetCreated() + return nil + case site.FieldModified: + m.ResetModified() return nil } - return fmt.Errorf("unknown SystemUpdate field %s", name) + return fmt.Errorf("unknown Site field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *SystemUpdateMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, systemupdate.EdgeOwner) +func (m *SiteMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.tenant != nil { + edges = append(edges, site.EdgeTenant) + } + if m.agents != nil { + edges = append(edges, site.EdgeAgents) + } + if m.profiles != nil { + edges = append(edges, site.EdgeProfiles) + } + if m.enrollment_tokens != nil { + edges = append(edges, site.EdgeEnrollmentTokens) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *SystemUpdateMutation) AddedIDs(name string) []ent.Value { +func (m *SiteMutation) AddedIDs(name string) []ent.Value { switch name { - case systemupdate.EdgeOwner: - if id := m.owner; id != nil { + case site.EdgeTenant: + if id := m.tenant; id != nil { return []ent.Value{*id} } + case site.EdgeAgents: + ids := make([]ent.Value, 0, len(m.agents)) + for id := range m.agents { + ids = append(ids, id) + } + return ids + case site.EdgeProfiles: + ids := make([]ent.Value, 0, len(m.profiles)) + for id := range m.profiles { + ids = append(ids, id) + } + return ids + case site.EdgeEnrollmentTokens: + ids := make([]ent.Value, 0, len(m.enrollment_tokens)) + for id := range m.enrollment_tokens { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *SystemUpdateMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) +func (m *SiteMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedagents != nil { + edges = append(edges, site.EdgeAgents) + } + if m.removedprofiles != nil { + edges = append(edges, site.EdgeProfiles) + } + if m.removedenrollment_tokens != nil { + edges = append(edges, site.EdgeEnrollmentTokens) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *SystemUpdateMutation) RemovedIDs(name string) []ent.Value { +func (m *SiteMutation) RemovedIDs(name string) []ent.Value { + switch name { + case site.EdgeAgents: + ids := make([]ent.Value, 0, len(m.removedagents)) + for id := range m.removedagents { + ids = append(ids, id) + } + return ids + case site.EdgeProfiles: + ids := make([]ent.Value, 0, len(m.removedprofiles)) + for id := range m.removedprofiles { + ids = append(ids, id) + } + return ids + case site.EdgeEnrollmentTokens: + ids := make([]ent.Value, 0, len(m.removedenrollment_tokens)) + for id := range m.removedenrollment_tokens { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *SystemUpdateMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, systemupdate.EdgeOwner) +func (m *SiteMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedtenant { + edges = append(edges, site.EdgeTenant) + } + if m.clearedagents { + edges = append(edges, site.EdgeAgents) + } + if m.clearedprofiles { + edges = append(edges, site.EdgeProfiles) + } + if m.clearedenrollment_tokens { + edges = append(edges, site.EdgeEnrollmentTokens) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *SystemUpdateMutation) EdgeCleared(name string) bool { +func (m *SiteMutation) EdgeCleared(name string) bool { switch name { - case systemupdate.EdgeOwner: - return m.clearedowner + case site.EdgeTenant: + return m.clearedtenant + case site.EdgeAgents: + return m.clearedagents + case site.EdgeProfiles: + return m.clearedprofiles + case site.EdgeEnrollmentTokens: + return m.clearedenrollment_tokens } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *SystemUpdateMutation) ClearEdge(name string) error { +func (m *SiteMutation) ClearEdge(name string) error { switch name { - case systemupdate.EdgeOwner: - m.ClearOwner() + case site.EdgeTenant: + m.ClearTenant() return nil } - return fmt.Errorf("unknown SystemUpdate unique edge %s", name) + return fmt.Errorf("unknown Site unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *SystemUpdateMutation) ResetEdge(name string) error { +func (m *SiteMutation) ResetEdge(name string) error { switch name { - case systemupdate.EdgeOwner: - m.ResetOwner() + case site.EdgeTenant: + m.ResetTenant() + return nil + case site.EdgeAgents: + m.ResetAgents() + return nil + case site.EdgeProfiles: + m.ResetProfiles() + return nil + case site.EdgeEnrollmentTokens: + m.ResetEnrollmentTokens() return nil } - return fmt.Errorf("unknown SystemUpdate edge %s", name) + return fmt.Errorf("unknown Site edge %s", name) } -// TagMutation represents an operation that mutates the Tag nodes in the graph. -type TagMutation struct { +// SystemUpdateMutation represents an operation that mutates the SystemUpdate nodes in the graph. +type SystemUpdateMutation struct { config - op Op - typ string - id *int - tag *string - description *string - color *string - clearedFields map[string]struct{} - owner map[string]struct{} - removedowner map[string]struct{} - clearedowner bool - parent *int - clearedparent bool - children map[int]struct{} - removedchildren map[int]struct{} - clearedchildren bool - profile map[int]struct{} - removedprofile map[int]struct{} - clearedprofile bool - tenant *int - clearedtenant bool - done bool - oldValue func(context.Context) (*Tag, error) - predicates []predicate.Tag + op Op + typ string + id *int + system_update_status *string + last_install *time.Time + last_search *time.Time + pending_updates *bool + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*SystemUpdate, error) + predicates []predicate.SystemUpdate } -var _ ent.Mutation = (*TagMutation)(nil) +var _ ent.Mutation = (*SystemUpdateMutation)(nil) -// tagOption allows management of the mutation configuration using functional options. -type tagOption func(*TagMutation) +// systemupdateOption allows management of the mutation configuration using functional options. +type systemupdateOption func(*SystemUpdateMutation) -// newTagMutation creates new mutation for the Tag entity. -func newTagMutation(c config, op Op, opts ...tagOption) *TagMutation { - m := &TagMutation{ +// newSystemUpdateMutation creates new mutation for the SystemUpdate entity. +func newSystemUpdateMutation(c config, op Op, opts ...systemupdateOption) *SystemUpdateMutation { + m := &SystemUpdateMutation{ config: c, op: op, - typ: TypeTag, + typ: TypeSystemUpdate, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -28940,20 +30650,20 @@ func newTagMutation(c config, op Op, opts ...tagOption) *TagMutation { return m } -// withTagID sets the ID field of the mutation. -func withTagID(id int) tagOption { - return func(m *TagMutation) { +// withSystemUpdateID sets the ID field of the mutation. +func withSystemUpdateID(id int) systemupdateOption { + return func(m *SystemUpdateMutation) { var ( err error once sync.Once - value *Tag + value *SystemUpdate ) - m.oldValue = func(ctx context.Context) (*Tag, error) { + m.oldValue = func(ctx context.Context) (*SystemUpdate, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Tag.Get(ctx, id) + value, err = m.Client().SystemUpdate.Get(ctx, id) } }) return value, err @@ -28962,10 +30672,10 @@ func withTagID(id int) tagOption { } } -// withTag sets the old Tag of the mutation. -func withTag(node *Tag) tagOption { - return func(m *TagMutation) { - m.oldValue = func(context.Context) (*Tag, error) { +// withSystemUpdate sets the old SystemUpdate of the mutation. +func withSystemUpdate(node *SystemUpdate) systemupdateOption { + return func(m *SystemUpdateMutation) { + m.oldValue = func(context.Context) (*SystemUpdate, error) { return node, nil } m.id = &node.ID @@ -28974,7 +30684,7 @@ func withTag(node *Tag) tagOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m TagMutation) Client() *Client { +func (m SystemUpdateMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -28982,7 +30692,7 @@ func (m TagMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m TagMutation) Tx() (*Tx, error) { +func (m SystemUpdateMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -28993,7 +30703,7 @@ func (m TagMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *TagMutation) ID() (id int, exists bool) { +func (m *SystemUpdateMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -29004,7 +30714,7 @@ func (m *TagMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *TagMutation) IDs(ctx context.Context) ([]int, error) { +func (m *SystemUpdateMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -29013,416 +30723,241 @@ func (m *TagMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Tag.Query().Where(m.predicates...).IDs(ctx) + return m.Client().SystemUpdate.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetTag sets the "tag" field. -func (m *TagMutation) SetTag(s string) { - m.tag = &s +// SetSystemUpdateStatus sets the "system_update_status" field. +func (m *SystemUpdateMutation) SetSystemUpdateStatus(s string) { + m.system_update_status = &s } -// Tag returns the value of the "tag" field in the mutation. -func (m *TagMutation) Tag() (r string, exists bool) { - v := m.tag +// SystemUpdateStatus returns the value of the "system_update_status" field in the mutation. +func (m *SystemUpdateMutation) SystemUpdateStatus() (r string, exists bool) { + v := m.system_update_status if v == nil { return } return *v, true } -// OldTag returns the old "tag" field's value of the Tag entity. -// If the Tag object wasn't provided to the builder, the object is fetched from the database. +// OldSystemUpdateStatus returns the old "system_update_status" field's value of the SystemUpdate entity. +// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TagMutation) OldTag(ctx context.Context) (v string, err error) { +func (m *SystemUpdateMutation) OldSystemUpdateStatus(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTag is only allowed on UpdateOne operations") + return v, errors.New("OldSystemUpdateStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTag requires an ID field in the mutation") + return v, errors.New("OldSystemUpdateStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTag: %w", err) + return v, fmt.Errorf("querying old value for OldSystemUpdateStatus: %w", err) } - return oldValue.Tag, nil + return oldValue.SystemUpdateStatus, nil } -// ResetTag resets all changes to the "tag" field. -func (m *TagMutation) ResetTag() { - m.tag = nil +// ResetSystemUpdateStatus resets all changes to the "system_update_status" field. +func (m *SystemUpdateMutation) ResetSystemUpdateStatus() { + m.system_update_status = nil } -// SetDescription sets the "description" field. -func (m *TagMutation) SetDescription(s string) { - m.description = &s +// SetLastInstall sets the "last_install" field. +func (m *SystemUpdateMutation) SetLastInstall(t time.Time) { + m.last_install = &t } -// Description returns the value of the "description" field in the mutation. -func (m *TagMutation) Description() (r string, exists bool) { - v := m.description +// LastInstall returns the value of the "last_install" field in the mutation. +func (m *SystemUpdateMutation) LastInstall() (r time.Time, exists bool) { + v := m.last_install if v == nil { return } return *v, true } -// OldDescription returns the old "description" field's value of the Tag entity. -// If the Tag object wasn't provided to the builder, the object is fetched from the database. +// OldLastInstall returns the old "last_install" field's value of the SystemUpdate entity. +// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TagMutation) OldDescription(ctx context.Context) (v string, err error) { +func (m *SystemUpdateMutation) OldLastInstall(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + return v, errors.New("OldLastInstall is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + return v, errors.New("OldLastInstall requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + return v, fmt.Errorf("querying old value for OldLastInstall: %w", err) } - return oldValue.Description, nil + return oldValue.LastInstall, nil } -// ClearDescription clears the value of the "description" field. -func (m *TagMutation) ClearDescription() { - m.description = nil - m.clearedFields[tag.FieldDescription] = struct{}{} +// ResetLastInstall resets all changes to the "last_install" field. +func (m *SystemUpdateMutation) ResetLastInstall() { + m.last_install = nil } -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *TagMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[tag.FieldDescription] - return ok +// SetLastSearch sets the "last_search" field. +func (m *SystemUpdateMutation) SetLastSearch(t time.Time) { + m.last_search = &t } -// ResetDescription resets all changes to the "description" field. -func (m *TagMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, tag.FieldDescription) +// LastSearch returns the value of the "last_search" field in the mutation. +func (m *SystemUpdateMutation) LastSearch() (r time.Time, exists bool) { + v := m.last_search + if v == nil { + return + } + return *v, true } -// SetColor sets the "color" field. -func (m *TagMutation) SetColor(s string) { - m.color = &s +// OldLastSearch returns the old "last_search" field's value of the SystemUpdate entity. +// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SystemUpdateMutation) OldLastSearch(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastSearch is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastSearch requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastSearch: %w", err) + } + return oldValue.LastSearch, nil } -// Color returns the value of the "color" field in the mutation. -func (m *TagMutation) Color() (r string, exists bool) { - v := m.color +// ResetLastSearch resets all changes to the "last_search" field. +func (m *SystemUpdateMutation) ResetLastSearch() { + m.last_search = nil +} + +// SetPendingUpdates sets the "pending_updates" field. +func (m *SystemUpdateMutation) SetPendingUpdates(b bool) { + m.pending_updates = &b +} + +// PendingUpdates returns the value of the "pending_updates" field in the mutation. +func (m *SystemUpdateMutation) PendingUpdates() (r bool, exists bool) { + v := m.pending_updates if v == nil { return } return *v, true } -// OldColor returns the old "color" field's value of the Tag entity. -// If the Tag object wasn't provided to the builder, the object is fetched from the database. +// OldPendingUpdates returns the old "pending_updates" field's value of the SystemUpdate entity. +// If the SystemUpdate object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TagMutation) OldColor(ctx context.Context) (v string, err error) { +func (m *SystemUpdateMutation) OldPendingUpdates(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldColor is only allowed on UpdateOne operations") + return v, errors.New("OldPendingUpdates is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldColor requires an ID field in the mutation") + return v, errors.New("OldPendingUpdates requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldColor: %w", err) + return v, fmt.Errorf("querying old value for OldPendingUpdates: %w", err) } - return oldValue.Color, nil + return oldValue.PendingUpdates, nil } -// ResetColor resets all changes to the "color" field. -func (m *TagMutation) ResetColor() { - m.color = nil +// ResetPendingUpdates resets all changes to the "pending_updates" field. +func (m *SystemUpdateMutation) ResetPendingUpdates() { + m.pending_updates = nil } -// AddOwnerIDs adds the "owner" edge to the Agent entity by ids. -func (m *TagMutation) AddOwnerIDs(ids ...string) { - if m.owner == nil { - m.owner = make(map[string]struct{}) - } - for i := range ids { - m.owner[ids[i]] = struct{}{} - } +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *SystemUpdateMutation) SetOwnerID(id string) { + m.owner = &id } // ClearOwner clears the "owner" edge to the Agent entity. -func (m *TagMutation) ClearOwner() { +func (m *SystemUpdateMutation) ClearOwner() { m.clearedowner = true } // OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *TagMutation) OwnerCleared() bool { +func (m *SystemUpdateMutation) OwnerCleared() bool { return m.clearedowner } -// RemoveOwnerIDs removes the "owner" edge to the Agent entity by IDs. -func (m *TagMutation) RemoveOwnerIDs(ids ...string) { - if m.removedowner == nil { - m.removedowner = make(map[string]struct{}) - } - for i := range ids { - delete(m.owner, ids[i]) - m.removedowner[ids[i]] = struct{}{} - } -} - -// RemovedOwner returns the removed IDs of the "owner" edge to the Agent entity. -func (m *TagMutation) RemovedOwnerIDs() (ids []string) { - for id := range m.removedowner { - ids = append(ids, id) +// OwnerID returns the "owner" edge ID in the mutation. +func (m *SystemUpdateMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true } return } // OwnerIDs returns the "owner" edge IDs in the mutation. -func (m *TagMutation) OwnerIDs() (ids []string) { - for id := range m.owner { - ids = append(ids, id) +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OwnerID instead. It exists only for internal usage by the builders. +func (m *SystemUpdateMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { + ids = append(ids, *id) } return } // ResetOwner resets all changes to the "owner" edge. -func (m *TagMutation) ResetOwner() { +func (m *SystemUpdateMutation) ResetOwner() { m.owner = nil m.clearedowner = false - m.removedowner = nil -} - -// SetParentID sets the "parent" edge to the Tag entity by id. -func (m *TagMutation) SetParentID(id int) { - m.parent = &id -} - -// ClearParent clears the "parent" edge to the Tag entity. -func (m *TagMutation) ClearParent() { - m.clearedparent = true } -// ParentCleared reports if the "parent" edge to the Tag entity was cleared. -func (m *TagMutation) ParentCleared() bool { - return m.clearedparent +// Where appends a list predicates to the SystemUpdateMutation builder. +func (m *SystemUpdateMutation) Where(ps ...predicate.SystemUpdate) { + m.predicates = append(m.predicates, ps...) } -// ParentID returns the "parent" edge ID in the mutation. -func (m *TagMutation) ParentID() (id int, exists bool) { - if m.parent != nil { - return *m.parent, true +// WhereP appends storage-level predicates to the SystemUpdateMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *SystemUpdateMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.SystemUpdate, len(ps)) + for i := range ps { + p[i] = ps[i] } - return + m.Where(p...) } -// ParentIDs returns the "parent" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ParentID instead. It exists only for internal usage by the builders. -func (m *TagMutation) ParentIDs() (ids []int) { - if id := m.parent; id != nil { - ids = append(ids, *id) - } - return +// Op returns the operation name. +func (m *SystemUpdateMutation) Op() Op { + return m.op } -// ResetParent resets all changes to the "parent" edge. -func (m *TagMutation) ResetParent() { - m.parent = nil - m.clearedparent = false +// SetOp allows setting the mutation operation. +func (m *SystemUpdateMutation) SetOp(op Op) { + m.op = op } -// AddChildIDs adds the "children" edge to the Tag entity by ids. -func (m *TagMutation) AddChildIDs(ids ...int) { - if m.children == nil { - m.children = make(map[int]struct{}) - } - for i := range ids { - m.children[ids[i]] = struct{}{} - } -} - -// ClearChildren clears the "children" edge to the Tag entity. -func (m *TagMutation) ClearChildren() { - m.clearedchildren = true -} - -// ChildrenCleared reports if the "children" edge to the Tag entity was cleared. -func (m *TagMutation) ChildrenCleared() bool { - return m.clearedchildren -} - -// RemoveChildIDs removes the "children" edge to the Tag entity by IDs. -func (m *TagMutation) RemoveChildIDs(ids ...int) { - if m.removedchildren == nil { - m.removedchildren = make(map[int]struct{}) - } - for i := range ids { - delete(m.children, ids[i]) - m.removedchildren[ids[i]] = struct{}{} - } -} - -// RemovedChildren returns the removed IDs of the "children" edge to the Tag entity. -func (m *TagMutation) RemovedChildrenIDs() (ids []int) { - for id := range m.removedchildren { - ids = append(ids, id) - } - return -} - -// ChildrenIDs returns the "children" edge IDs in the mutation. -func (m *TagMutation) ChildrenIDs() (ids []int) { - for id := range m.children { - ids = append(ids, id) - } - return -} - -// ResetChildren resets all changes to the "children" edge. -func (m *TagMutation) ResetChildren() { - m.children = nil - m.clearedchildren = false - m.removedchildren = nil -} - -// AddProfileIDs adds the "profile" edge to the Profile entity by ids. -func (m *TagMutation) AddProfileIDs(ids ...int) { - if m.profile == nil { - m.profile = make(map[int]struct{}) - } - for i := range ids { - m.profile[ids[i]] = struct{}{} - } -} - -// ClearProfile clears the "profile" edge to the Profile entity. -func (m *TagMutation) ClearProfile() { - m.clearedprofile = true -} - -// ProfileCleared reports if the "profile" edge to the Profile entity was cleared. -func (m *TagMutation) ProfileCleared() bool { - return m.clearedprofile -} - -// RemoveProfileIDs removes the "profile" edge to the Profile entity by IDs. -func (m *TagMutation) RemoveProfileIDs(ids ...int) { - if m.removedprofile == nil { - m.removedprofile = make(map[int]struct{}) - } - for i := range ids { - delete(m.profile, ids[i]) - m.removedprofile[ids[i]] = struct{}{} - } -} - -// RemovedProfile returns the removed IDs of the "profile" edge to the Profile entity. -func (m *TagMutation) RemovedProfileIDs() (ids []int) { - for id := range m.removedprofile { - ids = append(ids, id) - } - return -} - -// ProfileIDs returns the "profile" edge IDs in the mutation. -func (m *TagMutation) ProfileIDs() (ids []int) { - for id := range m.profile { - ids = append(ids, id) - } - return -} - -// ResetProfile resets all changes to the "profile" edge. -func (m *TagMutation) ResetProfile() { - m.profile = nil - m.clearedprofile = false - m.removedprofile = nil -} - -// SetTenantID sets the "tenant" edge to the Tenant entity by id. -func (m *TagMutation) SetTenantID(id int) { - m.tenant = &id -} - -// ClearTenant clears the "tenant" edge to the Tenant entity. -func (m *TagMutation) ClearTenant() { - m.clearedtenant = true -} - -// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. -func (m *TagMutation) TenantCleared() bool { - return m.clearedtenant -} - -// TenantID returns the "tenant" edge ID in the mutation. -func (m *TagMutation) TenantID() (id int, exists bool) { - if m.tenant != nil { - return *m.tenant, true - } - return -} - -// TenantIDs returns the "tenant" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// TenantID instead. It exists only for internal usage by the builders. -func (m *TagMutation) TenantIDs() (ids []int) { - if id := m.tenant; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetTenant resets all changes to the "tenant" edge. -func (m *TagMutation) ResetTenant() { - m.tenant = nil - m.clearedtenant = false -} - -// Where appends a list predicates to the TagMutation builder. -func (m *TagMutation) Where(ps ...predicate.Tag) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the TagMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *TagMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Tag, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *TagMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *TagMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Tag). -func (m *TagMutation) Type() string { - return m.typ +// Type returns the node type of this mutation (SystemUpdate). +func (m *SystemUpdateMutation) Type() string { + return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *TagMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.tag != nil { - fields = append(fields, tag.FieldTag) +func (m *SystemUpdateMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.system_update_status != nil { + fields = append(fields, systemupdate.FieldSystemUpdateStatus) } - if m.description != nil { - fields = append(fields, tag.FieldDescription) + if m.last_install != nil { + fields = append(fields, systemupdate.FieldLastInstall) } - if m.color != nil { - fields = append(fields, tag.FieldColor) + if m.last_search != nil { + fields = append(fields, systemupdate.FieldLastSearch) + } + if m.pending_updates != nil { + fields = append(fields, systemupdate.FieldPendingUpdates) } return fields } @@ -29430,14 +30965,16 @@ func (m *TagMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *TagMutation) Field(name string) (ent.Value, bool) { +func (m *SystemUpdateMutation) Field(name string) (ent.Value, bool) { switch name { - case tag.FieldTag: - return m.Tag() - case tag.FieldDescription: - return m.Description() - case tag.FieldColor: - return m.Color() + case systemupdate.FieldSystemUpdateStatus: + return m.SystemUpdateStatus() + case systemupdate.FieldLastInstall: + return m.LastInstall() + case systemupdate.FieldLastSearch: + return m.LastSearch() + case systemupdate.FieldPendingUpdates: + return m.PendingUpdates() } return nil, false } @@ -29445,164 +30982,133 @@ func (m *TagMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *TagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *SystemUpdateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case tag.FieldTag: - return m.OldTag(ctx) - case tag.FieldDescription: - return m.OldDescription(ctx) - case tag.FieldColor: - return m.OldColor(ctx) + case systemupdate.FieldSystemUpdateStatus: + return m.OldSystemUpdateStatus(ctx) + case systemupdate.FieldLastInstall: + return m.OldLastInstall(ctx) + case systemupdate.FieldLastSearch: + return m.OldLastSearch(ctx) + case systemupdate.FieldPendingUpdates: + return m.OldPendingUpdates(ctx) } - return nil, fmt.Errorf("unknown Tag field %s", name) + return nil, fmt.Errorf("unknown SystemUpdate field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *TagMutation) SetField(name string, value ent.Value) error { +func (m *SystemUpdateMutation) SetField(name string, value ent.Value) error { switch name { - case tag.FieldTag: + case systemupdate.FieldSystemUpdateStatus: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTag(v) + m.SetSystemUpdateStatus(v) return nil - case tag.FieldDescription: - v, ok := value.(string) + case systemupdate.FieldLastInstall: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) + m.SetLastInstall(v) return nil - case tag.FieldColor: - v, ok := value.(string) + case systemupdate.FieldLastSearch: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetColor(v) + m.SetLastSearch(v) + return nil + case systemupdate.FieldPendingUpdates: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPendingUpdates(v) return nil } - return fmt.Errorf("unknown Tag field %s", name) + return fmt.Errorf("unknown SystemUpdate field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *TagMutation) AddedFields() []string { +func (m *SystemUpdateMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *TagMutation) AddedField(name string) (ent.Value, bool) { +func (m *SystemUpdateMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *TagMutation) AddField(name string, value ent.Value) error { +func (m *SystemUpdateMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Tag numeric field %s", name) + return fmt.Errorf("unknown SystemUpdate numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *TagMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(tag.FieldDescription) { - fields = append(fields, tag.FieldDescription) - } - return fields +func (m *SystemUpdateMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *TagMutation) FieldCleared(name string) bool { +func (m *SystemUpdateMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *TagMutation) ClearField(name string) error { - switch name { - case tag.FieldDescription: - m.ClearDescription() - return nil - } - return fmt.Errorf("unknown Tag nullable field %s", name) +func (m *SystemUpdateMutation) ClearField(name string) error { + return fmt.Errorf("unknown SystemUpdate nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *TagMutation) ResetField(name string) error { +func (m *SystemUpdateMutation) ResetField(name string) error { switch name { - case tag.FieldTag: - m.ResetTag() + case systemupdate.FieldSystemUpdateStatus: + m.ResetSystemUpdateStatus() return nil - case tag.FieldDescription: - m.ResetDescription() + case systemupdate.FieldLastInstall: + m.ResetLastInstall() return nil - case tag.FieldColor: - m.ResetColor() + case systemupdate.FieldLastSearch: + m.ResetLastSearch() + return nil + case systemupdate.FieldPendingUpdates: + m.ResetPendingUpdates() return nil } - return fmt.Errorf("unknown Tag field %s", name) + return fmt.Errorf("unknown SystemUpdate field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *TagMutation) AddedEdges() []string { - edges := make([]string, 0, 5) +func (m *SystemUpdateMutation) AddedEdges() []string { + edges := make([]string, 0, 1) if m.owner != nil { - edges = append(edges, tag.EdgeOwner) - } - if m.parent != nil { - edges = append(edges, tag.EdgeParent) - } - if m.children != nil { - edges = append(edges, tag.EdgeChildren) - } - if m.profile != nil { - edges = append(edges, tag.EdgeProfile) - } - if m.tenant != nil { - edges = append(edges, tag.EdgeTenant) + edges = append(edges, systemupdate.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *TagMutation) AddedIDs(name string) []ent.Value { +func (m *SystemUpdateMutation) AddedIDs(name string) []ent.Value { switch name { - case tag.EdgeOwner: - ids := make([]ent.Value, 0, len(m.owner)) - for id := range m.owner { - ids = append(ids, id) - } - return ids - case tag.EdgeParent: - if id := m.parent; id != nil { - return []ent.Value{*id} - } - case tag.EdgeChildren: - ids := make([]ent.Value, 0, len(m.children)) - for id := range m.children { - ids = append(ids, id) - } - return ids - case tag.EdgeProfile: - ids := make([]ent.Value, 0, len(m.profile)) - for id := range m.profile { - ids = append(ids, id) - } - return ids - case tag.EdgeTenant: - if id := m.tenant; id != nil { + case systemupdate.EdgeOwner: + if id := m.owner; id != nil { return []ent.Value{*id} } } @@ -29610,240 +31116,97 @@ func (m *TagMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *TagMutation) RemovedEdges() []string { - edges := make([]string, 0, 5) - if m.removedowner != nil { - edges = append(edges, tag.EdgeOwner) - } - if m.removedchildren != nil { - edges = append(edges, tag.EdgeChildren) - } - if m.removedprofile != nil { - edges = append(edges, tag.EdgeProfile) - } +func (m *SystemUpdateMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *TagMutation) RemovedIDs(name string) []ent.Value { - switch name { - case tag.EdgeOwner: - ids := make([]ent.Value, 0, len(m.removedowner)) - for id := range m.removedowner { - ids = append(ids, id) - } - return ids - case tag.EdgeChildren: - ids := make([]ent.Value, 0, len(m.removedchildren)) - for id := range m.removedchildren { - ids = append(ids, id) - } - return ids - case tag.EdgeProfile: - ids := make([]ent.Value, 0, len(m.removedprofile)) - for id := range m.removedprofile { - ids = append(ids, id) - } - return ids - } +func (m *SystemUpdateMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *TagMutation) ClearedEdges() []string { - edges := make([]string, 0, 5) +func (m *SystemUpdateMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) if m.clearedowner { - edges = append(edges, tag.EdgeOwner) - } - if m.clearedparent { - edges = append(edges, tag.EdgeParent) - } - if m.clearedchildren { - edges = append(edges, tag.EdgeChildren) - } - if m.clearedprofile { - edges = append(edges, tag.EdgeProfile) - } - if m.clearedtenant { - edges = append(edges, tag.EdgeTenant) + edges = append(edges, systemupdate.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *TagMutation) EdgeCleared(name string) bool { +func (m *SystemUpdateMutation) EdgeCleared(name string) bool { switch name { - case tag.EdgeOwner: + case systemupdate.EdgeOwner: return m.clearedowner - case tag.EdgeParent: - return m.clearedparent - case tag.EdgeChildren: - return m.clearedchildren - case tag.EdgeProfile: - return m.clearedprofile - case tag.EdgeTenant: - return m.clearedtenant } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *TagMutation) ClearEdge(name string) error { +func (m *SystemUpdateMutation) ClearEdge(name string) error { switch name { - case tag.EdgeParent: - m.ClearParent() - return nil - case tag.EdgeTenant: - m.ClearTenant() + case systemupdate.EdgeOwner: + m.ClearOwner() return nil } - return fmt.Errorf("unknown Tag unique edge %s", name) + return fmt.Errorf("unknown SystemUpdate unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *TagMutation) ResetEdge(name string) error { +func (m *SystemUpdateMutation) ResetEdge(name string) error { switch name { - case tag.EdgeOwner: + case systemupdate.EdgeOwner: m.ResetOwner() return nil - case tag.EdgeParent: - m.ResetParent() - return nil - case tag.EdgeChildren: - m.ResetChildren() - return nil - case tag.EdgeProfile: - m.ResetProfile() - return nil - case tag.EdgeTenant: - m.ResetTenant() - return nil } - return fmt.Errorf("unknown Tag edge %s", name) + return fmt.Errorf("unknown SystemUpdate edge %s", name) } -// TaskMutation represents an operation that mutates the Task nodes in the graph. -type TaskMutation struct { +// TagMutation represents an operation that mutates the Tag nodes in the graph. +type TagMutation struct { config - op Op - typ string - id *int - name *string - _type *task.Type - package_id *string - package_name *string - package_latest *bool - registry_key *string - registry_key_value_name *string - registry_key_value_type *task.RegistryKeyValueType - registry_key_value_data *string - registry_hex *bool - registry_force *bool - local_user_username *string - local_user_description *string - local_user_disable *bool - local_user_fullname *string - local_user_password *string - local_user_password_change_not_allowed *bool - local_user_password_change_required *bool - local_user_password_never_expires *bool - local_user_append *bool - local_user_create_home *bool - local_user_expires *string - local_user_force *bool - local_user_generate_ssh_key *bool - local_user_group *string - local_user_groups *string - local_user_home *string - local_user_move_home *bool - local_user_nonunique *bool - local_user_password_expire_account_disable *string - local_user_password_expire_max *string - local_user_password_expire_min *string - local_user_password_expire_warn *string - local_user_password_lock *bool - local_user_seuser *string - local_user_shell *string - local_user_skeleton *string - local_user_system *bool - local_user_id *string - local_user_id_max *string - local_user_id_min *string - local_user_ssh_key_bits *string - local_user_ssh_key_comment *string - local_user_ssh_key_file *string - local_user_ssh_key_passphrase *string - local_user_ssh_key_type *string - local_user_umask *string - local_group_id *string - local_group_name *string - local_group_description *string - local_group_system *bool - local_group_force *bool - local_group_members *string - local_group_members_to_include *string - local_group_members_to_exclude *string - msi_productid *string - msi_path *string - msi_arguments *string - msi_file_hash *string - msi_file_hash_alg *task.MsiFileHashAlg - msi_log_path *string - script *string - script_executable *string - script_creates *string - script_run *task.ScriptRun - agent_type *task.AgentType - when *time.Time - brew_update *bool - brew_upgrade_all *bool - brew_upgrade_options *string - brew_install_options *string - brew_greedy *bool - package_version *string - apt_allow_downgrade *bool - apt_deb *string - apt_dpkg_options *string - apt_fail_on_autoremove *bool - apt_force *bool - apt_install_recommends *bool - apt_name *string - apt_only_upgrade *bool - apt_purge *bool - apt_update_cache *bool - apt_upgrade_type *task.AptUpgradeType - version *int - addversion *int - tenant *int - addtenant *int - netbird_groups *string - netbird_allow_extra_dns_labels *bool - clearedFields map[string]struct{} - tags map[int]struct{} - removedtags map[int]struct{} - clearedtags bool - profile *int - clearedprofile bool - done bool - oldValue func(context.Context) (*Task, error) - predicates []predicate.Task + op Op + typ string + id *int + tag *string + description *string + color *string + clearedFields map[string]struct{} + owner map[string]struct{} + removedowner map[string]struct{} + clearedowner bool + parent *int + clearedparent bool + children map[int]struct{} + removedchildren map[int]struct{} + clearedchildren bool + profile map[int]struct{} + removedprofile map[int]struct{} + clearedprofile bool + tenant *int + clearedtenant bool + done bool + oldValue func(context.Context) (*Tag, error) + predicates []predicate.Tag } -var _ ent.Mutation = (*TaskMutation)(nil) +var _ ent.Mutation = (*TagMutation)(nil) -// taskOption allows management of the mutation configuration using functional options. -type taskOption func(*TaskMutation) +// tagOption allows management of the mutation configuration using functional options. +type tagOption func(*TagMutation) -// newTaskMutation creates new mutation for the Task entity. -func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation { - m := &TaskMutation{ +// newTagMutation creates new mutation for the Tag entity. +func newTagMutation(c config, op Op, opts ...tagOption) *TagMutation { + m := &TagMutation{ config: c, op: op, - typ: TypeTask, + typ: TypeTag, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -29852,20 +31215,20 @@ func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation { return m } -// withTaskID sets the ID field of the mutation. -func withTaskID(id int) taskOption { - return func(m *TaskMutation) { +// withTagID sets the ID field of the mutation. +func withTagID(id int) tagOption { + return func(m *TagMutation) { var ( err error once sync.Once - value *Task + value *Tag ) - m.oldValue = func(ctx context.Context) (*Task, error) { + m.oldValue = func(ctx context.Context) (*Tag, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Task.Get(ctx, id) + value, err = m.Client().Tag.Get(ctx, id) } }) return value, err @@ -29874,10 +31237,10 @@ func withTaskID(id int) taskOption { } } -// withTask sets the old Task of the mutation. -func withTask(node *Task) taskOption { - return func(m *TaskMutation) { - m.oldValue = func(context.Context) (*Task, error) { +// withTag sets the old Tag of the mutation. +func withTag(node *Tag) tagOption { + return func(m *TagMutation) { + m.oldValue = func(context.Context) (*Tag, error) { return node, nil } m.id = &node.ID @@ -29886,7 +31249,7 @@ func withTask(node *Task) taskOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m TaskMutation) Client() *Client { +func (m TagMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -29894,7 +31257,7 @@ func (m TaskMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m TaskMutation) Tx() (*Tx, error) { +func (m TagMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -29905,7 +31268,7 @@ func (m TaskMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *TaskMutation) ID() (id int, exists bool) { +func (m *TagMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -29916,7 +31279,7 @@ func (m *TaskMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *TaskMutation) IDs(ctx context.Context) ([]int, error) { +func (m *TagMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -29925,6734 +31288,8970 @@ func (m *TaskMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Task.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Tag.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetName sets the "name" field. -func (m *TaskMutation) SetName(s string) { - m.name = &s +// SetTag sets the "tag" field. +func (m *TagMutation) SetTag(s string) { + m.tag = &s } -// Name returns the value of the "name" field in the mutation. -func (m *TaskMutation) Name() (r string, exists bool) { - v := m.name +// Tag returns the value of the "tag" field in the mutation. +func (m *TagMutation) Tag() (r string, exists bool) { + v := m.tag if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. +// OldTag returns the old "tag" field's value of the Tag entity. +// If the Tag object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldName(ctx context.Context) (v string, err error) { +func (m *TagMutation) OldTag(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldTag is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldTag requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldTag: %w", err) } - return oldValue.Name, nil + return oldValue.Tag, nil } -// ResetName resets all changes to the "name" field. -func (m *TaskMutation) ResetName() { - m.name = nil +// ResetTag resets all changes to the "tag" field. +func (m *TagMutation) ResetTag() { + m.tag = nil } -// SetType sets the "type" field. -func (m *TaskMutation) SetType(t task.Type) { - m._type = &t +// SetDescription sets the "description" field. +func (m *TagMutation) SetDescription(s string) { + m.description = &s } -// GetType returns the value of the "type" field in the mutation. -func (m *TaskMutation) GetType() (r task.Type, exists bool) { - v := m._type +// Description returns the value of the "description" field in the mutation. +func (m *TagMutation) Description() (r string, exists bool) { + v := m.description if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. +// OldDescription returns the old "description" field's value of the Tag entity. +// If the Tag object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldType(ctx context.Context) (v task.Type, err error) { +func (m *TagMutation) OldDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - return oldValue.Type, nil + return oldValue.Description, nil } -// ResetType resets all changes to the "type" field. -func (m *TaskMutation) ResetType() { - m._type = nil +// ClearDescription clears the value of the "description" field. +func (m *TagMutation) ClearDescription() { + m.description = nil + m.clearedFields[tag.FieldDescription] = struct{}{} } -// SetPackageID sets the "package_id" field. -func (m *TaskMutation) SetPackageID(s string) { - m.package_id = &s +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *TagMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[tag.FieldDescription] + return ok } -// PackageID returns the value of the "package_id" field in the mutation. -func (m *TaskMutation) PackageID() (r string, exists bool) { - v := m.package_id +// ResetDescription resets all changes to the "description" field. +func (m *TagMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, tag.FieldDescription) +} + +// SetColor sets the "color" field. +func (m *TagMutation) SetColor(s string) { + m.color = &s +} + +// Color returns the value of the "color" field in the mutation. +func (m *TagMutation) Color() (r string, exists bool) { + v := m.color if v == nil { return } return *v, true } -// OldPackageID returns the old "package_id" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. +// OldColor returns the old "color" field's value of the Tag entity. +// If the Tag object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldPackageID(ctx context.Context) (v string, err error) { +func (m *TagMutation) OldColor(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageID is only allowed on UpdateOne operations") + return v, errors.New("OldColor is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageID requires an ID field in the mutation") + return v, errors.New("OldColor requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPackageID: %w", err) + return v, fmt.Errorf("querying old value for OldColor: %w", err) } - return oldValue.PackageID, nil + return oldValue.Color, nil } -// ClearPackageID clears the value of the "package_id" field. -func (m *TaskMutation) ClearPackageID() { - m.package_id = nil - m.clearedFields[task.FieldPackageID] = struct{}{} +// ResetColor resets all changes to the "color" field. +func (m *TagMutation) ResetColor() { + m.color = nil } -// PackageIDCleared returns if the "package_id" field was cleared in this mutation. -func (m *TaskMutation) PackageIDCleared() bool { - _, ok := m.clearedFields[task.FieldPackageID] - return ok +// AddOwnerIDs adds the "owner" edge to the Agent entity by ids. +func (m *TagMutation) AddOwnerIDs(ids ...string) { + if m.owner == nil { + m.owner = make(map[string]struct{}) + } + for i := range ids { + m.owner[ids[i]] = struct{}{} + } } -// ResetPackageID resets all changes to the "package_id" field. -func (m *TaskMutation) ResetPackageID() { - m.package_id = nil - delete(m.clearedFields, task.FieldPackageID) +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *TagMutation) ClearOwner() { + m.clearedowner = true } -// SetPackageName sets the "package_name" field. -func (m *TaskMutation) SetPackageName(s string) { - m.package_name = &s +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *TagMutation) OwnerCleared() bool { + return m.clearedowner } -// PackageName returns the value of the "package_name" field in the mutation. -func (m *TaskMutation) PackageName() (r string, exists bool) { - v := m.package_name - if v == nil { - return +// RemoveOwnerIDs removes the "owner" edge to the Agent entity by IDs. +func (m *TagMutation) RemoveOwnerIDs(ids ...string) { + if m.removedowner == nil { + m.removedowner = make(map[string]struct{}) + } + for i := range ids { + delete(m.owner, ids[i]) + m.removedowner[ids[i]] = struct{}{} } - return *v, true } -// OldPackageName returns the old "package_name" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldPackageName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageName requires an ID field in the mutation") +// RemovedOwner returns the removed IDs of the "owner" edge to the Agent entity. +func (m *TagMutation) RemovedOwnerIDs() (ids []string) { + for id := range m.removedowner { + ids = append(ids, id) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPackageName: %w", err) + return +} + +// OwnerIDs returns the "owner" edge IDs in the mutation. +func (m *TagMutation) OwnerIDs() (ids []string) { + for id := range m.owner { + ids = append(ids, id) } - return oldValue.PackageName, nil + return } -// ClearPackageName clears the value of the "package_name" field. -func (m *TaskMutation) ClearPackageName() { - m.package_name = nil - m.clearedFields[task.FieldPackageName] = struct{}{} +// ResetOwner resets all changes to the "owner" edge. +func (m *TagMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false + m.removedowner = nil } -// PackageNameCleared returns if the "package_name" field was cleared in this mutation. -func (m *TaskMutation) PackageNameCleared() bool { - _, ok := m.clearedFields[task.FieldPackageName] - return ok +// SetParentID sets the "parent" edge to the Tag entity by id. +func (m *TagMutation) SetParentID(id int) { + m.parent = &id } -// ResetPackageName resets all changes to the "package_name" field. -func (m *TaskMutation) ResetPackageName() { - m.package_name = nil - delete(m.clearedFields, task.FieldPackageName) +// ClearParent clears the "parent" edge to the Tag entity. +func (m *TagMutation) ClearParent() { + m.clearedparent = true } -// SetPackageLatest sets the "package_latest" field. -func (m *TaskMutation) SetPackageLatest(b bool) { - m.package_latest = &b +// ParentCleared reports if the "parent" edge to the Tag entity was cleared. +func (m *TagMutation) ParentCleared() bool { + return m.clearedparent } -// PackageLatest returns the value of the "package_latest" field in the mutation. -func (m *TaskMutation) PackageLatest() (r bool, exists bool) { - v := m.package_latest - if v == nil { - return +// ParentID returns the "parent" edge ID in the mutation. +func (m *TagMutation) ParentID() (id int, exists bool) { + if m.parent != nil { + return *m.parent, true } - return *v, true + return } -// OldPackageLatest returns the old "package_latest" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldPackageLatest(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageLatest is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageLatest requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPackageLatest: %w", err) +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *TagMutation) ParentIDs() (ids []int) { + if id := m.parent; id != nil { + ids = append(ids, *id) } - return oldValue.PackageLatest, nil + return } -// ClearPackageLatest clears the value of the "package_latest" field. -func (m *TaskMutation) ClearPackageLatest() { - m.package_latest = nil - m.clearedFields[task.FieldPackageLatest] = struct{}{} +// ResetParent resets all changes to the "parent" edge. +func (m *TagMutation) ResetParent() { + m.parent = nil + m.clearedparent = false } -// PackageLatestCleared returns if the "package_latest" field was cleared in this mutation. -func (m *TaskMutation) PackageLatestCleared() bool { - _, ok := m.clearedFields[task.FieldPackageLatest] - return ok +// AddChildIDs adds the "children" edge to the Tag entity by ids. +func (m *TagMutation) AddChildIDs(ids ...int) { + if m.children == nil { + m.children = make(map[int]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} + } } -// ResetPackageLatest resets all changes to the "package_latest" field. -func (m *TaskMutation) ResetPackageLatest() { - m.package_latest = nil - delete(m.clearedFields, task.FieldPackageLatest) +// ClearChildren clears the "children" edge to the Tag entity. +func (m *TagMutation) ClearChildren() { + m.clearedchildren = true } -// SetRegistryKey sets the "registry_key" field. -func (m *TaskMutation) SetRegistryKey(s string) { - m.registry_key = &s +// ChildrenCleared reports if the "children" edge to the Tag entity was cleared. +func (m *TagMutation) ChildrenCleared() bool { + return m.clearedchildren } -// RegistryKey returns the value of the "registry_key" field in the mutation. -func (m *TaskMutation) RegistryKey() (r string, exists bool) { - v := m.registry_key - if v == nil { - return +// RemoveChildIDs removes the "children" edge to the Tag entity by IDs. +func (m *TagMutation) RemoveChildIDs(ids ...int) { + if m.removedchildren == nil { + m.removedchildren = make(map[int]struct{}) + } + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} } - return *v, true } -// OldRegistryKey returns the old "registry_key" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldRegistryKey(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistryKey is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistryKey requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegistryKey: %w", err) +// RemovedChildren returns the removed IDs of the "children" edge to the Tag entity. +func (m *TagMutation) RemovedChildrenIDs() (ids []int) { + for id := range m.removedchildren { + ids = append(ids, id) } - return oldValue.RegistryKey, nil + return } -// ClearRegistryKey clears the value of the "registry_key" field. -func (m *TaskMutation) ClearRegistryKey() { - m.registry_key = nil - m.clearedFields[task.FieldRegistryKey] = struct{}{} +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *TagMutation) ChildrenIDs() (ids []int) { + for id := range m.children { + ids = append(ids, id) + } + return } -// RegistryKeyCleared returns if the "registry_key" field was cleared in this mutation. -func (m *TaskMutation) RegistryKeyCleared() bool { - _, ok := m.clearedFields[task.FieldRegistryKey] - return ok +// ResetChildren resets all changes to the "children" edge. +func (m *TagMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil } -// ResetRegistryKey resets all changes to the "registry_key" field. -func (m *TaskMutation) ResetRegistryKey() { - m.registry_key = nil - delete(m.clearedFields, task.FieldRegistryKey) +// AddProfileIDs adds the "profile" edge to the Profile entity by ids. +func (m *TagMutation) AddProfileIDs(ids ...int) { + if m.profile == nil { + m.profile = make(map[int]struct{}) + } + for i := range ids { + m.profile[ids[i]] = struct{}{} + } } -// SetRegistryKeyValueName sets the "registry_key_value_name" field. -func (m *TaskMutation) SetRegistryKeyValueName(s string) { - m.registry_key_value_name = &s +// ClearProfile clears the "profile" edge to the Profile entity. +func (m *TagMutation) ClearProfile() { + m.clearedprofile = true } -// RegistryKeyValueName returns the value of the "registry_key_value_name" field in the mutation. -func (m *TaskMutation) RegistryKeyValueName() (r string, exists bool) { - v := m.registry_key_value_name - if v == nil { - return - } - return *v, true +// ProfileCleared reports if the "profile" edge to the Profile entity was cleared. +func (m *TagMutation) ProfileCleared() bool { + return m.clearedprofile } -// OldRegistryKeyValueName returns the old "registry_key_value_name" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldRegistryKeyValueName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistryKeyValueName is only allowed on UpdateOne operations") +// RemoveProfileIDs removes the "profile" edge to the Profile entity by IDs. +func (m *TagMutation) RemoveProfileIDs(ids ...int) { + if m.removedprofile == nil { + m.removedprofile = make(map[int]struct{}) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistryKeyValueName requires an ID field in the mutation") + for i := range ids { + delete(m.profile, ids[i]) + m.removedprofile[ids[i]] = struct{}{} } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegistryKeyValueName: %w", err) +} + +// RemovedProfile returns the removed IDs of the "profile" edge to the Profile entity. +func (m *TagMutation) RemovedProfileIDs() (ids []int) { + for id := range m.removedprofile { + ids = append(ids, id) } - return oldValue.RegistryKeyValueName, nil + return } -// ClearRegistryKeyValueName clears the value of the "registry_key_value_name" field. -func (m *TaskMutation) ClearRegistryKeyValueName() { - m.registry_key_value_name = nil - m.clearedFields[task.FieldRegistryKeyValueName] = struct{}{} +// ProfileIDs returns the "profile" edge IDs in the mutation. +func (m *TagMutation) ProfileIDs() (ids []int) { + for id := range m.profile { + ids = append(ids, id) + } + return } -// RegistryKeyValueNameCleared returns if the "registry_key_value_name" field was cleared in this mutation. -func (m *TaskMutation) RegistryKeyValueNameCleared() bool { - _, ok := m.clearedFields[task.FieldRegistryKeyValueName] - return ok +// ResetProfile resets all changes to the "profile" edge. +func (m *TagMutation) ResetProfile() { + m.profile = nil + m.clearedprofile = false + m.removedprofile = nil } -// ResetRegistryKeyValueName resets all changes to the "registry_key_value_name" field. -func (m *TaskMutation) ResetRegistryKeyValueName() { - m.registry_key_value_name = nil - delete(m.clearedFields, task.FieldRegistryKeyValueName) +// SetTenantID sets the "tenant" edge to the Tenant entity by id. +func (m *TagMutation) SetTenantID(id int) { + m.tenant = &id } -// SetRegistryKeyValueType sets the "registry_key_value_type" field. -func (m *TaskMutation) SetRegistryKeyValueType(tkvt task.RegistryKeyValueType) { - m.registry_key_value_type = &tkvt +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *TagMutation) ClearTenant() { + m.clearedtenant = true } -// RegistryKeyValueType returns the value of the "registry_key_value_type" field in the mutation. -func (m *TaskMutation) RegistryKeyValueType() (r task.RegistryKeyValueType, exists bool) { - v := m.registry_key_value_type - if v == nil { - return - } - return *v, true +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *TagMutation) TenantCleared() bool { + return m.clearedtenant } -// OldRegistryKeyValueType returns the old "registry_key_value_type" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldRegistryKeyValueType(ctx context.Context) (v task.RegistryKeyValueType, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistryKeyValueType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistryKeyValueType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegistryKeyValueType: %w", err) +// TenantID returns the "tenant" edge ID in the mutation. +func (m *TagMutation) TenantID() (id int, exists bool) { + if m.tenant != nil { + return *m.tenant, true } - return oldValue.RegistryKeyValueType, nil -} - -// ClearRegistryKeyValueType clears the value of the "registry_key_value_type" field. -func (m *TaskMutation) ClearRegistryKeyValueType() { - m.registry_key_value_type = nil - m.clearedFields[task.FieldRegistryKeyValueType] = struct{}{} -} - -// RegistryKeyValueTypeCleared returns if the "registry_key_value_type" field was cleared in this mutation. -func (m *TaskMutation) RegistryKeyValueTypeCleared() bool { - _, ok := m.clearedFields[task.FieldRegistryKeyValueType] - return ok -} - -// ResetRegistryKeyValueType resets all changes to the "registry_key_value_type" field. -func (m *TaskMutation) ResetRegistryKeyValueType() { - m.registry_key_value_type = nil - delete(m.clearedFields, task.FieldRegistryKeyValueType) -} - -// SetRegistryKeyValueData sets the "registry_key_value_data" field. -func (m *TaskMutation) SetRegistryKeyValueData(s string) { - m.registry_key_value_data = &s + return } -// RegistryKeyValueData returns the value of the "registry_key_value_data" field in the mutation. -func (m *TaskMutation) RegistryKeyValueData() (r string, exists bool) { - v := m.registry_key_value_data - if v == nil { - return +// TenantIDs returns the "tenant" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TenantID instead. It exists only for internal usage by the builders. +func (m *TagMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { + ids = append(ids, *id) } - return *v, true + return } -// OldRegistryKeyValueData returns the old "registry_key_value_data" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldRegistryKeyValueData(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistryKeyValueData is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistryKeyValueData requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegistryKeyValueData: %w", err) - } - return oldValue.RegistryKeyValueData, nil +// ResetTenant resets all changes to the "tenant" edge. +func (m *TagMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false } -// ClearRegistryKeyValueData clears the value of the "registry_key_value_data" field. -func (m *TaskMutation) ClearRegistryKeyValueData() { - m.registry_key_value_data = nil - m.clearedFields[task.FieldRegistryKeyValueData] = struct{}{} +// Where appends a list predicates to the TagMutation builder. +func (m *TagMutation) Where(ps ...predicate.Tag) { + m.predicates = append(m.predicates, ps...) } -// RegistryKeyValueDataCleared returns if the "registry_key_value_data" field was cleared in this mutation. -func (m *TaskMutation) RegistryKeyValueDataCleared() bool { - _, ok := m.clearedFields[task.FieldRegistryKeyValueData] - return ok +// WhereP appends storage-level predicates to the TagMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TagMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Tag, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) } -// ResetRegistryKeyValueData resets all changes to the "registry_key_value_data" field. -func (m *TaskMutation) ResetRegistryKeyValueData() { - m.registry_key_value_data = nil - delete(m.clearedFields, task.FieldRegistryKeyValueData) +// Op returns the operation name. +func (m *TagMutation) Op() Op { + return m.op } -// SetRegistryHex sets the "registry_hex" field. -func (m *TaskMutation) SetRegistryHex(b bool) { - m.registry_hex = &b +// SetOp allows setting the mutation operation. +func (m *TagMutation) SetOp(op Op) { + m.op = op } -// RegistryHex returns the value of the "registry_hex" field in the mutation. -func (m *TaskMutation) RegistryHex() (r bool, exists bool) { - v := m.registry_hex - if v == nil { - return - } - return *v, true +// Type returns the node type of this mutation (Tag). +func (m *TagMutation) Type() string { + return m.typ } -// OldRegistryHex returns the old "registry_hex" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldRegistryHex(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistryHex is only allowed on UpdateOne operations") +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *TagMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.tag != nil { + fields = append(fields, tag.FieldTag) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistryHex requires an ID field in the mutation") + if m.description != nil { + fields = append(fields, tag.FieldDescription) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegistryHex: %w", err) + if m.color != nil { + fields = append(fields, tag.FieldColor) } - return oldValue.RegistryHex, nil + return fields } -// ClearRegistryHex clears the value of the "registry_hex" field. -func (m *TaskMutation) ClearRegistryHex() { - m.registry_hex = nil - m.clearedFields[task.FieldRegistryHex] = struct{}{} +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *TagMutation) Field(name string) (ent.Value, bool) { + switch name { + case tag.FieldTag: + return m.Tag() + case tag.FieldDescription: + return m.Description() + case tag.FieldColor: + return m.Color() + } + return nil, false } -// RegistryHexCleared returns if the "registry_hex" field was cleared in this mutation. -func (m *TaskMutation) RegistryHexCleared() bool { - _, ok := m.clearedFields[task.FieldRegistryHex] - return ok +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *TagMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case tag.FieldTag: + return m.OldTag(ctx) + case tag.FieldDescription: + return m.OldDescription(ctx) + case tag.FieldColor: + return m.OldColor(ctx) + } + return nil, fmt.Errorf("unknown Tag field %s", name) } -// ResetRegistryHex resets all changes to the "registry_hex" field. -func (m *TaskMutation) ResetRegistryHex() { - m.registry_hex = nil - delete(m.clearedFields, task.FieldRegistryHex) +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TagMutation) SetField(name string, value ent.Value) error { + switch name { + case tag.FieldTag: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTag(v) + return nil + case tag.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case tag.FieldColor: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetColor(v) + return nil + } + return fmt.Errorf("unknown Tag field %s", name) } -// SetRegistryForce sets the "registry_force" field. -func (m *TaskMutation) SetRegistryForce(b bool) { - m.registry_force = &b +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *TagMutation) AddedFields() []string { + return nil } -// RegistryForce returns the value of the "registry_force" field in the mutation. -func (m *TaskMutation) RegistryForce() (r bool, exists bool) { - v := m.registry_force - if v == nil { - return - } - return *v, true +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *TagMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// OldRegistryForce returns the old "registry_force" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldRegistryForce(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegistryForce is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegistryForce requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegistryForce: %w", err) +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TagMutation) AddField(name string, value ent.Value) error { + switch name { } - return oldValue.RegistryForce, nil + return fmt.Errorf("unknown Tag numeric field %s", name) } -// ClearRegistryForce clears the value of the "registry_force" field. -func (m *TaskMutation) ClearRegistryForce() { - m.registry_force = nil - m.clearedFields[task.FieldRegistryForce] = struct{}{} +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *TagMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(tag.FieldDescription) { + fields = append(fields, tag.FieldDescription) + } + return fields } -// RegistryForceCleared returns if the "registry_force" field was cleared in this mutation. -func (m *TaskMutation) RegistryForceCleared() bool { - _, ok := m.clearedFields[task.FieldRegistryForce] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *TagMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetRegistryForce resets all changes to the "registry_force" field. -func (m *TaskMutation) ResetRegistryForce() { - m.registry_force = nil - delete(m.clearedFields, task.FieldRegistryForce) -} - -// SetLocalUserUsername sets the "local_user_username" field. -func (m *TaskMutation) SetLocalUserUsername(s string) { - m.local_user_username = &s +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *TagMutation) ClearField(name string) error { + switch name { + case tag.FieldDescription: + m.ClearDescription() + return nil + } + return fmt.Errorf("unknown Tag nullable field %s", name) } -// LocalUserUsername returns the value of the "local_user_username" field in the mutation. -func (m *TaskMutation) LocalUserUsername() (r string, exists bool) { - v := m.local_user_username - if v == nil { - return +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *TagMutation) ResetField(name string) error { + switch name { + case tag.FieldTag: + m.ResetTag() + return nil + case tag.FieldDescription: + m.ResetDescription() + return nil + case tag.FieldColor: + m.ResetColor() + return nil } - return *v, true + return fmt.Errorf("unknown Tag field %s", name) } -// OldLocalUserUsername returns the old "local_user_username" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserUsername(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserUsername is only allowed on UpdateOne operations") +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *TagMutation) AddedEdges() []string { + edges := make([]string, 0, 5) + if m.owner != nil { + edges = append(edges, tag.EdgeOwner) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserUsername requires an ID field in the mutation") + if m.parent != nil { + edges = append(edges, tag.EdgeParent) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserUsername: %w", err) + if m.children != nil { + edges = append(edges, tag.EdgeChildren) } - return oldValue.LocalUserUsername, nil -} - -// ClearLocalUserUsername clears the value of the "local_user_username" field. -func (m *TaskMutation) ClearLocalUserUsername() { - m.local_user_username = nil - m.clearedFields[task.FieldLocalUserUsername] = struct{}{} -} - -// LocalUserUsernameCleared returns if the "local_user_username" field was cleared in this mutation. -func (m *TaskMutation) LocalUserUsernameCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserUsername] - return ok -} - -// ResetLocalUserUsername resets all changes to the "local_user_username" field. -func (m *TaskMutation) ResetLocalUserUsername() { - m.local_user_username = nil - delete(m.clearedFields, task.FieldLocalUserUsername) -} - -// SetLocalUserDescription sets the "local_user_description" field. -func (m *TaskMutation) SetLocalUserDescription(s string) { - m.local_user_description = &s + if m.profile != nil { + edges = append(edges, tag.EdgeProfile) + } + if m.tenant != nil { + edges = append(edges, tag.EdgeTenant) + } + return edges } -// LocalUserDescription returns the value of the "local_user_description" field in the mutation. -func (m *TaskMutation) LocalUserDescription() (r string, exists bool) { - v := m.local_user_description - if v == nil { - return +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *TagMutation) AddedIDs(name string) []ent.Value { + switch name { + case tag.EdgeOwner: + ids := make([]ent.Value, 0, len(m.owner)) + for id := range m.owner { + ids = append(ids, id) + } + return ids + case tag.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case tag.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids + case tag.EdgeProfile: + ids := make([]ent.Value, 0, len(m.profile)) + for id := range m.profile { + ids = append(ids, id) + } + return ids + case tag.EdgeTenant: + if id := m.tenant; id != nil { + return []ent.Value{*id} + } } - return *v, true + return nil } -// OldLocalUserDescription returns the old "local_user_description" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserDescription is only allowed on UpdateOne operations") +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *TagMutation) RemovedEdges() []string { + edges := make([]string, 0, 5) + if m.removedowner != nil { + edges = append(edges, tag.EdgeOwner) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserDescription requires an ID field in the mutation") + if m.removedchildren != nil { + edges = append(edges, tag.EdgeChildren) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserDescription: %w", err) + if m.removedprofile != nil { + edges = append(edges, tag.EdgeProfile) } - return oldValue.LocalUserDescription, nil -} - -// ClearLocalUserDescription clears the value of the "local_user_description" field. -func (m *TaskMutation) ClearLocalUserDescription() { - m.local_user_description = nil - m.clearedFields[task.FieldLocalUserDescription] = struct{}{} -} - -// LocalUserDescriptionCleared returns if the "local_user_description" field was cleared in this mutation. -func (m *TaskMutation) LocalUserDescriptionCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserDescription] - return ok -} - -// ResetLocalUserDescription resets all changes to the "local_user_description" field. -func (m *TaskMutation) ResetLocalUserDescription() { - m.local_user_description = nil - delete(m.clearedFields, task.FieldLocalUserDescription) -} - -// SetLocalUserDisable sets the "local_user_disable" field. -func (m *TaskMutation) SetLocalUserDisable(b bool) { - m.local_user_disable = &b + return edges } -// LocalUserDisable returns the value of the "local_user_disable" field in the mutation. -func (m *TaskMutation) LocalUserDisable() (r bool, exists bool) { - v := m.local_user_disable - if v == nil { - return +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *TagMutation) RemovedIDs(name string) []ent.Value { + switch name { + case tag.EdgeOwner: + ids := make([]ent.Value, 0, len(m.removedowner)) + for id := range m.removedowner { + ids = append(ids, id) + } + return ids + case tag.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case tag.EdgeProfile: + ids := make([]ent.Value, 0, len(m.removedprofile)) + for id := range m.removedprofile { + ids = append(ids, id) + } + return ids } - return *v, true + return nil } -// OldLocalUserDisable returns the old "local_user_disable" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserDisable(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserDisable is only allowed on UpdateOne operations") +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *TagMutation) ClearedEdges() []string { + edges := make([]string, 0, 5) + if m.clearedowner { + edges = append(edges, tag.EdgeOwner) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserDisable requires an ID field in the mutation") + if m.clearedparent { + edges = append(edges, tag.EdgeParent) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserDisable: %w", err) + if m.clearedchildren { + edges = append(edges, tag.EdgeChildren) } - return oldValue.LocalUserDisable, nil + if m.clearedprofile { + edges = append(edges, tag.EdgeProfile) + } + if m.clearedtenant { + edges = append(edges, tag.EdgeTenant) + } + return edges } -// ClearLocalUserDisable clears the value of the "local_user_disable" field. -func (m *TaskMutation) ClearLocalUserDisable() { - m.local_user_disable = nil - m.clearedFields[task.FieldLocalUserDisable] = struct{}{} +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *TagMutation) EdgeCleared(name string) bool { + switch name { + case tag.EdgeOwner: + return m.clearedowner + case tag.EdgeParent: + return m.clearedparent + case tag.EdgeChildren: + return m.clearedchildren + case tag.EdgeProfile: + return m.clearedprofile + case tag.EdgeTenant: + return m.clearedtenant + } + return false } -// LocalUserDisableCleared returns if the "local_user_disable" field was cleared in this mutation. -func (m *TaskMutation) LocalUserDisableCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserDisable] - return ok +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *TagMutation) ClearEdge(name string) error { + switch name { + case tag.EdgeParent: + m.ClearParent() + return nil + case tag.EdgeTenant: + m.ClearTenant() + return nil + } + return fmt.Errorf("unknown Tag unique edge %s", name) } -// ResetLocalUserDisable resets all changes to the "local_user_disable" field. -func (m *TaskMutation) ResetLocalUserDisable() { - m.local_user_disable = nil - delete(m.clearedFields, task.FieldLocalUserDisable) +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *TagMutation) ResetEdge(name string) error { + switch name { + case tag.EdgeOwner: + m.ResetOwner() + return nil + case tag.EdgeParent: + m.ResetParent() + return nil + case tag.EdgeChildren: + m.ResetChildren() + return nil + case tag.EdgeProfile: + m.ResetProfile() + return nil + case tag.EdgeTenant: + m.ResetTenant() + return nil + } + return fmt.Errorf("unknown Tag edge %s", name) } -// SetLocalUserFullname sets the "local_user_fullname" field. -func (m *TaskMutation) SetLocalUserFullname(s string) { - m.local_user_fullname = &s +// TaskMutation represents an operation that mutates the Task nodes in the graph. +type TaskMutation struct { + config + op Op + typ string + id *int + name *string + _type *task.Type + package_id *string + package_name *string + package_latest *bool + registry_key *string + registry_key_value_name *string + registry_key_value_type *task.RegistryKeyValueType + registry_key_value_data *string + registry_hex *bool + registry_force *bool + local_user_username *string + local_user_description *string + local_user_disable *bool + local_user_fullname *string + local_user_password *string + local_user_password_change_not_allowed *bool + local_user_password_change_required *bool + local_user_password_never_expires *bool + local_user_append *bool + local_user_create_home *bool + local_user_expires *string + local_user_force *bool + local_user_generate_ssh_key *bool + local_user_group *string + local_user_groups *string + local_user_home *string + local_user_move_home *bool + local_user_nonunique *bool + local_user_password_expire_account_disable *string + local_user_password_expire_max *string + local_user_password_expire_min *string + local_user_password_expire_warn *string + local_user_password_lock *bool + local_user_seuser *string + local_user_shell *string + local_user_skeleton *string + local_user_system *bool + local_user_id *string + local_user_id_max *string + local_user_id_min *string + local_user_ssh_key_bits *string + local_user_ssh_key_comment *string + local_user_ssh_key_file *string + local_user_ssh_key_passphrase *string + local_user_ssh_key_type *string + local_user_umask *string + local_group_id *string + local_group_name *string + local_group_description *string + local_group_system *bool + local_group_force *bool + local_group_members *string + local_group_members_to_include *string + local_group_members_to_exclude *string + msi_productid *string + msi_path *string + msi_arguments *string + msi_file_hash *string + msi_file_hash_alg *task.MsiFileHashAlg + msi_log_path *string + script *string + script_executable *string + script_creates *string + script_run *task.ScriptRun + agent_type *task.AgentType + when *time.Time + brew_update *bool + brew_upgrade_all *bool + brew_upgrade_options *string + brew_install_options *string + brew_greedy *bool + package_version *string + apt_allow_downgrade *bool + apt_deb *string + apt_dpkg_options *string + apt_fail_on_autoremove *bool + apt_force *bool + apt_install_recommends *bool + apt_name *string + apt_only_upgrade *bool + apt_purge *bool + apt_update_cache *bool + apt_upgrade_type *task.AptUpgradeType + version *int + addversion *int + tenant *int + addtenant *int + netbird_groups *string + netbird_allow_extra_dns_labels *bool + clearedFields map[string]struct{} + tags map[int]struct{} + removedtags map[int]struct{} + clearedtags bool + profile *int + clearedprofile bool + done bool + oldValue func(context.Context) (*Task, error) + predicates []predicate.Task } -// LocalUserFullname returns the value of the "local_user_fullname" field in the mutation. -func (m *TaskMutation) LocalUserFullname() (r string, exists bool) { - v := m.local_user_fullname - if v == nil { - return +var _ ent.Mutation = (*TaskMutation)(nil) + +// taskOption allows management of the mutation configuration using functional options. +type taskOption func(*TaskMutation) + +// newTaskMutation creates new mutation for the Task entity. +func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation { + m := &TaskMutation{ + config: c, + op: op, + typ: TypeTask, + clearedFields: make(map[string]struct{}), } - return *v, true + for _, opt := range opts { + opt(m) + } + return m } -// OldLocalUserFullname returns the old "local_user_fullname" field's value of the Task entity. -// If the Task object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserFullname(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserFullname is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserFullname requires an ID field in the mutation") +// withTaskID sets the ID field of the mutation. +func withTaskID(id int) taskOption { + return func(m *TaskMutation) { + var ( + err error + once sync.Once + value *Task + ) + m.oldValue = func(ctx context.Context) (*Task, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Task.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserFullname: %w", err) +} + +// withTask sets the old Task of the mutation. +func withTask(node *Task) taskOption { + return func(m *TaskMutation) { + m.oldValue = func(context.Context) (*Task, error) { + return node, nil + } + m.id = &node.ID } - return oldValue.LocalUserFullname, nil } -// ClearLocalUserFullname clears the value of the "local_user_fullname" field. -func (m *TaskMutation) ClearLocalUserFullname() { - m.local_user_fullname = nil - m.clearedFields[task.FieldLocalUserFullname] = struct{}{} +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m TaskMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// LocalUserFullnameCleared returns if the "local_user_fullname" field was cleared in this mutation. -func (m *TaskMutation) LocalUserFullnameCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserFullname] - return ok +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m TaskMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetLocalUserFullname resets all changes to the "local_user_fullname" field. -func (m *TaskMutation) ResetLocalUserFullname() { - m.local_user_fullname = nil - delete(m.clearedFields, task.FieldLocalUserFullname) +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *TaskMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// SetLocalUserPassword sets the "local_user_password" field. -func (m *TaskMutation) SetLocalUserPassword(s string) { - m.local_user_password = &s +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *TaskMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Task.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// LocalUserPassword returns the value of the "local_user_password" field in the mutation. -func (m *TaskMutation) LocalUserPassword() (r string, exists bool) { - v := m.local_user_password +// SetName sets the "name" field. +func (m *TaskMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *TaskMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldLocalUserPassword returns the old "local_user_password" field's value of the Task entity. +// OldName returns the old "name" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPassword(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPassword is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPassword requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPassword: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.LocalUserPassword, nil -} - -// ClearLocalUserPassword clears the value of the "local_user_password" field. -func (m *TaskMutation) ClearLocalUserPassword() { - m.local_user_password = nil - m.clearedFields[task.FieldLocalUserPassword] = struct{}{} -} - -// LocalUserPasswordCleared returns if the "local_user_password" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPassword] - return ok + return oldValue.Name, nil } -// ResetLocalUserPassword resets all changes to the "local_user_password" field. -func (m *TaskMutation) ResetLocalUserPassword() { - m.local_user_password = nil - delete(m.clearedFields, task.FieldLocalUserPassword) +// ResetName resets all changes to the "name" field. +func (m *TaskMutation) ResetName() { + m.name = nil } -// SetLocalUserPasswordChangeNotAllowed sets the "local_user_password_change_not_allowed" field. -func (m *TaskMutation) SetLocalUserPasswordChangeNotAllowed(b bool) { - m.local_user_password_change_not_allowed = &b +// SetType sets the "type" field. +func (m *TaskMutation) SetType(t task.Type) { + m._type = &t } -// LocalUserPasswordChangeNotAllowed returns the value of the "local_user_password_change_not_allowed" field in the mutation. -func (m *TaskMutation) LocalUserPasswordChangeNotAllowed() (r bool, exists bool) { - v := m.local_user_password_change_not_allowed +// GetType returns the value of the "type" field in the mutation. +func (m *TaskMutation) GetType() (r task.Type, exists bool) { + v := m._type if v == nil { return } return *v, true } -// OldLocalUserPasswordChangeNotAllowed returns the old "local_user_password_change_not_allowed" field's value of the Task entity. +// OldType returns the old "type" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordChangeNotAllowed(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldType(ctx context.Context) (v task.Type, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordChangeNotAllowed is only allowed on UpdateOne operations") + return v, errors.New("OldType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordChangeNotAllowed requires an ID field in the mutation") + return v, errors.New("OldType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordChangeNotAllowed: %w", err) + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return oldValue.LocalUserPasswordChangeNotAllowed, nil -} - -// ClearLocalUserPasswordChangeNotAllowed clears the value of the "local_user_password_change_not_allowed" field. -func (m *TaskMutation) ClearLocalUserPasswordChangeNotAllowed() { - m.local_user_password_change_not_allowed = nil - m.clearedFields[task.FieldLocalUserPasswordChangeNotAllowed] = struct{}{} -} - -// LocalUserPasswordChangeNotAllowedCleared returns if the "local_user_password_change_not_allowed" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordChangeNotAllowedCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordChangeNotAllowed] - return ok + return oldValue.Type, nil } -// ResetLocalUserPasswordChangeNotAllowed resets all changes to the "local_user_password_change_not_allowed" field. -func (m *TaskMutation) ResetLocalUserPasswordChangeNotAllowed() { - m.local_user_password_change_not_allowed = nil - delete(m.clearedFields, task.FieldLocalUserPasswordChangeNotAllowed) +// ResetType resets all changes to the "type" field. +func (m *TaskMutation) ResetType() { + m._type = nil } -// SetLocalUserPasswordChangeRequired sets the "local_user_password_change_required" field. -func (m *TaskMutation) SetLocalUserPasswordChangeRequired(b bool) { - m.local_user_password_change_required = &b +// SetPackageID sets the "package_id" field. +func (m *TaskMutation) SetPackageID(s string) { + m.package_id = &s } -// LocalUserPasswordChangeRequired returns the value of the "local_user_password_change_required" field in the mutation. -func (m *TaskMutation) LocalUserPasswordChangeRequired() (r bool, exists bool) { - v := m.local_user_password_change_required +// PackageID returns the value of the "package_id" field in the mutation. +func (m *TaskMutation) PackageID() (r string, exists bool) { + v := m.package_id if v == nil { return } return *v, true } -// OldLocalUserPasswordChangeRequired returns the old "local_user_password_change_required" field's value of the Task entity. +// OldPackageID returns the old "package_id" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordChangeRequired(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldPackageID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordChangeRequired is only allowed on UpdateOne operations") + return v, errors.New("OldPackageID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordChangeRequired requires an ID field in the mutation") + return v, errors.New("OldPackageID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordChangeRequired: %w", err) + return v, fmt.Errorf("querying old value for OldPackageID: %w", err) } - return oldValue.LocalUserPasswordChangeRequired, nil + return oldValue.PackageID, nil } -// ClearLocalUserPasswordChangeRequired clears the value of the "local_user_password_change_required" field. -func (m *TaskMutation) ClearLocalUserPasswordChangeRequired() { - m.local_user_password_change_required = nil - m.clearedFields[task.FieldLocalUserPasswordChangeRequired] = struct{}{} +// ClearPackageID clears the value of the "package_id" field. +func (m *TaskMutation) ClearPackageID() { + m.package_id = nil + m.clearedFields[task.FieldPackageID] = struct{}{} } -// LocalUserPasswordChangeRequiredCleared returns if the "local_user_password_change_required" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordChangeRequiredCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordChangeRequired] +// PackageIDCleared returns if the "package_id" field was cleared in this mutation. +func (m *TaskMutation) PackageIDCleared() bool { + _, ok := m.clearedFields[task.FieldPackageID] return ok } -// ResetLocalUserPasswordChangeRequired resets all changes to the "local_user_password_change_required" field. -func (m *TaskMutation) ResetLocalUserPasswordChangeRequired() { - m.local_user_password_change_required = nil - delete(m.clearedFields, task.FieldLocalUserPasswordChangeRequired) +// ResetPackageID resets all changes to the "package_id" field. +func (m *TaskMutation) ResetPackageID() { + m.package_id = nil + delete(m.clearedFields, task.FieldPackageID) } -// SetLocalUserPasswordNeverExpires sets the "local_user_password_never_expires" field. -func (m *TaskMutation) SetLocalUserPasswordNeverExpires(b bool) { - m.local_user_password_never_expires = &b +// SetPackageName sets the "package_name" field. +func (m *TaskMutation) SetPackageName(s string) { + m.package_name = &s } -// LocalUserPasswordNeverExpires returns the value of the "local_user_password_never_expires" field in the mutation. -func (m *TaskMutation) LocalUserPasswordNeverExpires() (r bool, exists bool) { - v := m.local_user_password_never_expires +// PackageName returns the value of the "package_name" field in the mutation. +func (m *TaskMutation) PackageName() (r string, exists bool) { + v := m.package_name if v == nil { return } return *v, true } -// OldLocalUserPasswordNeverExpires returns the old "local_user_password_never_expires" field's value of the Task entity. +// OldPackageName returns the old "package_name" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordNeverExpires(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldPackageName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordNeverExpires is only allowed on UpdateOne operations") + return v, errors.New("OldPackageName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordNeverExpires requires an ID field in the mutation") + return v, errors.New("OldPackageName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordNeverExpires: %w", err) + return v, fmt.Errorf("querying old value for OldPackageName: %w", err) } - return oldValue.LocalUserPasswordNeverExpires, nil + return oldValue.PackageName, nil } -// ClearLocalUserPasswordNeverExpires clears the value of the "local_user_password_never_expires" field. -func (m *TaskMutation) ClearLocalUserPasswordNeverExpires() { - m.local_user_password_never_expires = nil - m.clearedFields[task.FieldLocalUserPasswordNeverExpires] = struct{}{} +// ClearPackageName clears the value of the "package_name" field. +func (m *TaskMutation) ClearPackageName() { + m.package_name = nil + m.clearedFields[task.FieldPackageName] = struct{}{} } -// LocalUserPasswordNeverExpiresCleared returns if the "local_user_password_never_expires" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordNeverExpiresCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordNeverExpires] +// PackageNameCleared returns if the "package_name" field was cleared in this mutation. +func (m *TaskMutation) PackageNameCleared() bool { + _, ok := m.clearedFields[task.FieldPackageName] return ok } -// ResetLocalUserPasswordNeverExpires resets all changes to the "local_user_password_never_expires" field. -func (m *TaskMutation) ResetLocalUserPasswordNeverExpires() { - m.local_user_password_never_expires = nil - delete(m.clearedFields, task.FieldLocalUserPasswordNeverExpires) +// ResetPackageName resets all changes to the "package_name" field. +func (m *TaskMutation) ResetPackageName() { + m.package_name = nil + delete(m.clearedFields, task.FieldPackageName) } -// SetLocalUserAppend sets the "local_user_append" field. -func (m *TaskMutation) SetLocalUserAppend(b bool) { - m.local_user_append = &b +// SetPackageLatest sets the "package_latest" field. +func (m *TaskMutation) SetPackageLatest(b bool) { + m.package_latest = &b } -// LocalUserAppend returns the value of the "local_user_append" field in the mutation. -func (m *TaskMutation) LocalUserAppend() (r bool, exists bool) { - v := m.local_user_append +// PackageLatest returns the value of the "package_latest" field in the mutation. +func (m *TaskMutation) PackageLatest() (r bool, exists bool) { + v := m.package_latest if v == nil { return } return *v, true } -// OldLocalUserAppend returns the old "local_user_append" field's value of the Task entity. +// OldPackageLatest returns the old "package_latest" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserAppend(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldPackageLatest(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserAppend is only allowed on UpdateOne operations") + return v, errors.New("OldPackageLatest is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserAppend requires an ID field in the mutation") + return v, errors.New("OldPackageLatest requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserAppend: %w", err) + return v, fmt.Errorf("querying old value for OldPackageLatest: %w", err) } - return oldValue.LocalUserAppend, nil + return oldValue.PackageLatest, nil } -// ClearLocalUserAppend clears the value of the "local_user_append" field. -func (m *TaskMutation) ClearLocalUserAppend() { - m.local_user_append = nil - m.clearedFields[task.FieldLocalUserAppend] = struct{}{} +// ClearPackageLatest clears the value of the "package_latest" field. +func (m *TaskMutation) ClearPackageLatest() { + m.package_latest = nil + m.clearedFields[task.FieldPackageLatest] = struct{}{} } -// LocalUserAppendCleared returns if the "local_user_append" field was cleared in this mutation. -func (m *TaskMutation) LocalUserAppendCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserAppend] +// PackageLatestCleared returns if the "package_latest" field was cleared in this mutation. +func (m *TaskMutation) PackageLatestCleared() bool { + _, ok := m.clearedFields[task.FieldPackageLatest] return ok } -// ResetLocalUserAppend resets all changes to the "local_user_append" field. -func (m *TaskMutation) ResetLocalUserAppend() { - m.local_user_append = nil - delete(m.clearedFields, task.FieldLocalUserAppend) +// ResetPackageLatest resets all changes to the "package_latest" field. +func (m *TaskMutation) ResetPackageLatest() { + m.package_latest = nil + delete(m.clearedFields, task.FieldPackageLatest) } -// SetLocalUserCreateHome sets the "local_user_create_home" field. -func (m *TaskMutation) SetLocalUserCreateHome(b bool) { - m.local_user_create_home = &b +// SetRegistryKey sets the "registry_key" field. +func (m *TaskMutation) SetRegistryKey(s string) { + m.registry_key = &s } -// LocalUserCreateHome returns the value of the "local_user_create_home" field in the mutation. -func (m *TaskMutation) LocalUserCreateHome() (r bool, exists bool) { - v := m.local_user_create_home +// RegistryKey returns the value of the "registry_key" field in the mutation. +func (m *TaskMutation) RegistryKey() (r string, exists bool) { + v := m.registry_key if v == nil { return } return *v, true } -// OldLocalUserCreateHome returns the old "local_user_create_home" field's value of the Task entity. +// OldRegistryKey returns the old "registry_key" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserCreateHome(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldRegistryKey(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserCreateHome is only allowed on UpdateOne operations") + return v, errors.New("OldRegistryKey is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserCreateHome requires an ID field in the mutation") + return v, errors.New("OldRegistryKey requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserCreateHome: %w", err) + return v, fmt.Errorf("querying old value for OldRegistryKey: %w", err) } - return oldValue.LocalUserCreateHome, nil + return oldValue.RegistryKey, nil } -// ClearLocalUserCreateHome clears the value of the "local_user_create_home" field. -func (m *TaskMutation) ClearLocalUserCreateHome() { - m.local_user_create_home = nil - m.clearedFields[task.FieldLocalUserCreateHome] = struct{}{} +// ClearRegistryKey clears the value of the "registry_key" field. +func (m *TaskMutation) ClearRegistryKey() { + m.registry_key = nil + m.clearedFields[task.FieldRegistryKey] = struct{}{} } -// LocalUserCreateHomeCleared returns if the "local_user_create_home" field was cleared in this mutation. -func (m *TaskMutation) LocalUserCreateHomeCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserCreateHome] +// RegistryKeyCleared returns if the "registry_key" field was cleared in this mutation. +func (m *TaskMutation) RegistryKeyCleared() bool { + _, ok := m.clearedFields[task.FieldRegistryKey] return ok } -// ResetLocalUserCreateHome resets all changes to the "local_user_create_home" field. -func (m *TaskMutation) ResetLocalUserCreateHome() { - m.local_user_create_home = nil - delete(m.clearedFields, task.FieldLocalUserCreateHome) +// ResetRegistryKey resets all changes to the "registry_key" field. +func (m *TaskMutation) ResetRegistryKey() { + m.registry_key = nil + delete(m.clearedFields, task.FieldRegistryKey) } -// SetLocalUserExpires sets the "local_user_expires" field. -func (m *TaskMutation) SetLocalUserExpires(s string) { - m.local_user_expires = &s +// SetRegistryKeyValueName sets the "registry_key_value_name" field. +func (m *TaskMutation) SetRegistryKeyValueName(s string) { + m.registry_key_value_name = &s } -// LocalUserExpires returns the value of the "local_user_expires" field in the mutation. -func (m *TaskMutation) LocalUserExpires() (r string, exists bool) { - v := m.local_user_expires +// RegistryKeyValueName returns the value of the "registry_key_value_name" field in the mutation. +func (m *TaskMutation) RegistryKeyValueName() (r string, exists bool) { + v := m.registry_key_value_name if v == nil { return } return *v, true } -// OldLocalUserExpires returns the old "local_user_expires" field's value of the Task entity. +// OldRegistryKeyValueName returns the old "registry_key_value_name" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserExpires(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldRegistryKeyValueName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserExpires is only allowed on UpdateOne operations") + return v, errors.New("OldRegistryKeyValueName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserExpires requires an ID field in the mutation") + return v, errors.New("OldRegistryKeyValueName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserExpires: %w", err) + return v, fmt.Errorf("querying old value for OldRegistryKeyValueName: %w", err) } - return oldValue.LocalUserExpires, nil + return oldValue.RegistryKeyValueName, nil } -// ClearLocalUserExpires clears the value of the "local_user_expires" field. -func (m *TaskMutation) ClearLocalUserExpires() { - m.local_user_expires = nil - m.clearedFields[task.FieldLocalUserExpires] = struct{}{} +// ClearRegistryKeyValueName clears the value of the "registry_key_value_name" field. +func (m *TaskMutation) ClearRegistryKeyValueName() { + m.registry_key_value_name = nil + m.clearedFields[task.FieldRegistryKeyValueName] = struct{}{} } -// LocalUserExpiresCleared returns if the "local_user_expires" field was cleared in this mutation. -func (m *TaskMutation) LocalUserExpiresCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserExpires] +// RegistryKeyValueNameCleared returns if the "registry_key_value_name" field was cleared in this mutation. +func (m *TaskMutation) RegistryKeyValueNameCleared() bool { + _, ok := m.clearedFields[task.FieldRegistryKeyValueName] return ok } -// ResetLocalUserExpires resets all changes to the "local_user_expires" field. -func (m *TaskMutation) ResetLocalUserExpires() { - m.local_user_expires = nil - delete(m.clearedFields, task.FieldLocalUserExpires) +// ResetRegistryKeyValueName resets all changes to the "registry_key_value_name" field. +func (m *TaskMutation) ResetRegistryKeyValueName() { + m.registry_key_value_name = nil + delete(m.clearedFields, task.FieldRegistryKeyValueName) } -// SetLocalUserForce sets the "local_user_force" field. -func (m *TaskMutation) SetLocalUserForce(b bool) { - m.local_user_force = &b +// SetRegistryKeyValueType sets the "registry_key_value_type" field. +func (m *TaskMutation) SetRegistryKeyValueType(tkvt task.RegistryKeyValueType) { + m.registry_key_value_type = &tkvt } -// LocalUserForce returns the value of the "local_user_force" field in the mutation. -func (m *TaskMutation) LocalUserForce() (r bool, exists bool) { - v := m.local_user_force +// RegistryKeyValueType returns the value of the "registry_key_value_type" field in the mutation. +func (m *TaskMutation) RegistryKeyValueType() (r task.RegistryKeyValueType, exists bool) { + v := m.registry_key_value_type if v == nil { return } return *v, true } -// OldLocalUserForce returns the old "local_user_force" field's value of the Task entity. +// OldRegistryKeyValueType returns the old "registry_key_value_type" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserForce(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldRegistryKeyValueType(ctx context.Context) (v task.RegistryKeyValueType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserForce is only allowed on UpdateOne operations") + return v, errors.New("OldRegistryKeyValueType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserForce requires an ID field in the mutation") + return v, errors.New("OldRegistryKeyValueType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserForce: %w", err) + return v, fmt.Errorf("querying old value for OldRegistryKeyValueType: %w", err) } - return oldValue.LocalUserForce, nil + return oldValue.RegistryKeyValueType, nil } -// ClearLocalUserForce clears the value of the "local_user_force" field. -func (m *TaskMutation) ClearLocalUserForce() { - m.local_user_force = nil - m.clearedFields[task.FieldLocalUserForce] = struct{}{} +// ClearRegistryKeyValueType clears the value of the "registry_key_value_type" field. +func (m *TaskMutation) ClearRegistryKeyValueType() { + m.registry_key_value_type = nil + m.clearedFields[task.FieldRegistryKeyValueType] = struct{}{} } -// LocalUserForceCleared returns if the "local_user_force" field was cleared in this mutation. -func (m *TaskMutation) LocalUserForceCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserForce] +// RegistryKeyValueTypeCleared returns if the "registry_key_value_type" field was cleared in this mutation. +func (m *TaskMutation) RegistryKeyValueTypeCleared() bool { + _, ok := m.clearedFields[task.FieldRegistryKeyValueType] return ok } -// ResetLocalUserForce resets all changes to the "local_user_force" field. -func (m *TaskMutation) ResetLocalUserForce() { - m.local_user_force = nil - delete(m.clearedFields, task.FieldLocalUserForce) +// ResetRegistryKeyValueType resets all changes to the "registry_key_value_type" field. +func (m *TaskMutation) ResetRegistryKeyValueType() { + m.registry_key_value_type = nil + delete(m.clearedFields, task.FieldRegistryKeyValueType) } -// SetLocalUserGenerateSSHKey sets the "local_user_generate_ssh_key" field. -func (m *TaskMutation) SetLocalUserGenerateSSHKey(b bool) { - m.local_user_generate_ssh_key = &b +// SetRegistryKeyValueData sets the "registry_key_value_data" field. +func (m *TaskMutation) SetRegistryKeyValueData(s string) { + m.registry_key_value_data = &s } -// LocalUserGenerateSSHKey returns the value of the "local_user_generate_ssh_key" field in the mutation. -func (m *TaskMutation) LocalUserGenerateSSHKey() (r bool, exists bool) { - v := m.local_user_generate_ssh_key +// RegistryKeyValueData returns the value of the "registry_key_value_data" field in the mutation. +func (m *TaskMutation) RegistryKeyValueData() (r string, exists bool) { + v := m.registry_key_value_data if v == nil { return } return *v, true } -// OldLocalUserGenerateSSHKey returns the old "local_user_generate_ssh_key" field's value of the Task entity. +// OldRegistryKeyValueData returns the old "registry_key_value_data" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserGenerateSSHKey(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldRegistryKeyValueData(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserGenerateSSHKey is only allowed on UpdateOne operations") + return v, errors.New("OldRegistryKeyValueData is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserGenerateSSHKey requires an ID field in the mutation") + return v, errors.New("OldRegistryKeyValueData requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserGenerateSSHKey: %w", err) + return v, fmt.Errorf("querying old value for OldRegistryKeyValueData: %w", err) } - return oldValue.LocalUserGenerateSSHKey, nil + return oldValue.RegistryKeyValueData, nil } -// ClearLocalUserGenerateSSHKey clears the value of the "local_user_generate_ssh_key" field. -func (m *TaskMutation) ClearLocalUserGenerateSSHKey() { - m.local_user_generate_ssh_key = nil - m.clearedFields[task.FieldLocalUserGenerateSSHKey] = struct{}{} +// ClearRegistryKeyValueData clears the value of the "registry_key_value_data" field. +func (m *TaskMutation) ClearRegistryKeyValueData() { + m.registry_key_value_data = nil + m.clearedFields[task.FieldRegistryKeyValueData] = struct{}{} } -// LocalUserGenerateSSHKeyCleared returns if the "local_user_generate_ssh_key" field was cleared in this mutation. -func (m *TaskMutation) LocalUserGenerateSSHKeyCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserGenerateSSHKey] +// RegistryKeyValueDataCleared returns if the "registry_key_value_data" field was cleared in this mutation. +func (m *TaskMutation) RegistryKeyValueDataCleared() bool { + _, ok := m.clearedFields[task.FieldRegistryKeyValueData] return ok } -// ResetLocalUserGenerateSSHKey resets all changes to the "local_user_generate_ssh_key" field. -func (m *TaskMutation) ResetLocalUserGenerateSSHKey() { - m.local_user_generate_ssh_key = nil - delete(m.clearedFields, task.FieldLocalUserGenerateSSHKey) +// ResetRegistryKeyValueData resets all changes to the "registry_key_value_data" field. +func (m *TaskMutation) ResetRegistryKeyValueData() { + m.registry_key_value_data = nil + delete(m.clearedFields, task.FieldRegistryKeyValueData) } -// SetLocalUserGroup sets the "local_user_group" field. -func (m *TaskMutation) SetLocalUserGroup(s string) { - m.local_user_group = &s +// SetRegistryHex sets the "registry_hex" field. +func (m *TaskMutation) SetRegistryHex(b bool) { + m.registry_hex = &b } -// LocalUserGroup returns the value of the "local_user_group" field in the mutation. -func (m *TaskMutation) LocalUserGroup() (r string, exists bool) { - v := m.local_user_group +// RegistryHex returns the value of the "registry_hex" field in the mutation. +func (m *TaskMutation) RegistryHex() (r bool, exists bool) { + v := m.registry_hex if v == nil { return } return *v, true } -// OldLocalUserGroup returns the old "local_user_group" field's value of the Task entity. +// OldRegistryHex returns the old "registry_hex" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserGroup(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldRegistryHex(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserGroup is only allowed on UpdateOne operations") + return v, errors.New("OldRegistryHex is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserGroup requires an ID field in the mutation") + return v, errors.New("OldRegistryHex requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserGroup: %w", err) + return v, fmt.Errorf("querying old value for OldRegistryHex: %w", err) } - return oldValue.LocalUserGroup, nil + return oldValue.RegistryHex, nil } -// ClearLocalUserGroup clears the value of the "local_user_group" field. -func (m *TaskMutation) ClearLocalUserGroup() { - m.local_user_group = nil - m.clearedFields[task.FieldLocalUserGroup] = struct{}{} +// ClearRegistryHex clears the value of the "registry_hex" field. +func (m *TaskMutation) ClearRegistryHex() { + m.registry_hex = nil + m.clearedFields[task.FieldRegistryHex] = struct{}{} } -// LocalUserGroupCleared returns if the "local_user_group" field was cleared in this mutation. -func (m *TaskMutation) LocalUserGroupCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserGroup] +// RegistryHexCleared returns if the "registry_hex" field was cleared in this mutation. +func (m *TaskMutation) RegistryHexCleared() bool { + _, ok := m.clearedFields[task.FieldRegistryHex] return ok } -// ResetLocalUserGroup resets all changes to the "local_user_group" field. -func (m *TaskMutation) ResetLocalUserGroup() { - m.local_user_group = nil - delete(m.clearedFields, task.FieldLocalUserGroup) +// ResetRegistryHex resets all changes to the "registry_hex" field. +func (m *TaskMutation) ResetRegistryHex() { + m.registry_hex = nil + delete(m.clearedFields, task.FieldRegistryHex) } -// SetLocalUserGroups sets the "local_user_groups" field. -func (m *TaskMutation) SetLocalUserGroups(s string) { - m.local_user_groups = &s +// SetRegistryForce sets the "registry_force" field. +func (m *TaskMutation) SetRegistryForce(b bool) { + m.registry_force = &b } -// LocalUserGroups returns the value of the "local_user_groups" field in the mutation. -func (m *TaskMutation) LocalUserGroups() (r string, exists bool) { - v := m.local_user_groups +// RegistryForce returns the value of the "registry_force" field in the mutation. +func (m *TaskMutation) RegistryForce() (r bool, exists bool) { + v := m.registry_force if v == nil { return } return *v, true } -// OldLocalUserGroups returns the old "local_user_groups" field's value of the Task entity. +// OldRegistryForce returns the old "registry_force" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserGroups(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldRegistryForce(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserGroups is only allowed on UpdateOne operations") + return v, errors.New("OldRegistryForce is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserGroups requires an ID field in the mutation") + return v, errors.New("OldRegistryForce requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserGroups: %w", err) + return v, fmt.Errorf("querying old value for OldRegistryForce: %w", err) } - return oldValue.LocalUserGroups, nil + return oldValue.RegistryForce, nil } -// ClearLocalUserGroups clears the value of the "local_user_groups" field. -func (m *TaskMutation) ClearLocalUserGroups() { - m.local_user_groups = nil - m.clearedFields[task.FieldLocalUserGroups] = struct{}{} +// ClearRegistryForce clears the value of the "registry_force" field. +func (m *TaskMutation) ClearRegistryForce() { + m.registry_force = nil + m.clearedFields[task.FieldRegistryForce] = struct{}{} } -// LocalUserGroupsCleared returns if the "local_user_groups" field was cleared in this mutation. -func (m *TaskMutation) LocalUserGroupsCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserGroups] +// RegistryForceCleared returns if the "registry_force" field was cleared in this mutation. +func (m *TaskMutation) RegistryForceCleared() bool { + _, ok := m.clearedFields[task.FieldRegistryForce] return ok } -// ResetLocalUserGroups resets all changes to the "local_user_groups" field. -func (m *TaskMutation) ResetLocalUserGroups() { - m.local_user_groups = nil - delete(m.clearedFields, task.FieldLocalUserGroups) +// ResetRegistryForce resets all changes to the "registry_force" field. +func (m *TaskMutation) ResetRegistryForce() { + m.registry_force = nil + delete(m.clearedFields, task.FieldRegistryForce) } -// SetLocalUserHome sets the "local_user_home" field. -func (m *TaskMutation) SetLocalUserHome(s string) { - m.local_user_home = &s +// SetLocalUserUsername sets the "local_user_username" field. +func (m *TaskMutation) SetLocalUserUsername(s string) { + m.local_user_username = &s } -// LocalUserHome returns the value of the "local_user_home" field in the mutation. -func (m *TaskMutation) LocalUserHome() (r string, exists bool) { - v := m.local_user_home +// LocalUserUsername returns the value of the "local_user_username" field in the mutation. +func (m *TaskMutation) LocalUserUsername() (r string, exists bool) { + v := m.local_user_username if v == nil { return } return *v, true } -// OldLocalUserHome returns the old "local_user_home" field's value of the Task entity. +// OldLocalUserUsername returns the old "local_user_username" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserHome(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserUsername(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserHome is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserUsername is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserHome requires an ID field in the mutation") + return v, errors.New("OldLocalUserUsername requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserHome: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserUsername: %w", err) } - return oldValue.LocalUserHome, nil + return oldValue.LocalUserUsername, nil } -// ClearLocalUserHome clears the value of the "local_user_home" field. -func (m *TaskMutation) ClearLocalUserHome() { - m.local_user_home = nil - m.clearedFields[task.FieldLocalUserHome] = struct{}{} +// ClearLocalUserUsername clears the value of the "local_user_username" field. +func (m *TaskMutation) ClearLocalUserUsername() { + m.local_user_username = nil + m.clearedFields[task.FieldLocalUserUsername] = struct{}{} } -// LocalUserHomeCleared returns if the "local_user_home" field was cleared in this mutation. -func (m *TaskMutation) LocalUserHomeCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserHome] +// LocalUserUsernameCleared returns if the "local_user_username" field was cleared in this mutation. +func (m *TaskMutation) LocalUserUsernameCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserUsername] return ok } -// ResetLocalUserHome resets all changes to the "local_user_home" field. -func (m *TaskMutation) ResetLocalUserHome() { - m.local_user_home = nil - delete(m.clearedFields, task.FieldLocalUserHome) +// ResetLocalUserUsername resets all changes to the "local_user_username" field. +func (m *TaskMutation) ResetLocalUserUsername() { + m.local_user_username = nil + delete(m.clearedFields, task.FieldLocalUserUsername) } -// SetLocalUserMoveHome sets the "local_user_move_home" field. -func (m *TaskMutation) SetLocalUserMoveHome(b bool) { - m.local_user_move_home = &b +// SetLocalUserDescription sets the "local_user_description" field. +func (m *TaskMutation) SetLocalUserDescription(s string) { + m.local_user_description = &s } -// LocalUserMoveHome returns the value of the "local_user_move_home" field in the mutation. -func (m *TaskMutation) LocalUserMoveHome() (r bool, exists bool) { - v := m.local_user_move_home +// LocalUserDescription returns the value of the "local_user_description" field in the mutation. +func (m *TaskMutation) LocalUserDescription() (r string, exists bool) { + v := m.local_user_description if v == nil { return } return *v, true } -// OldLocalUserMoveHome returns the old "local_user_move_home" field's value of the Task entity. +// OldLocalUserDescription returns the old "local_user_description" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserMoveHome(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalUserDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserMoveHome is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserMoveHome requires an ID field in the mutation") + return v, errors.New("OldLocalUserDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserMoveHome: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserDescription: %w", err) } - return oldValue.LocalUserMoveHome, nil + return oldValue.LocalUserDescription, nil } -// ClearLocalUserMoveHome clears the value of the "local_user_move_home" field. -func (m *TaskMutation) ClearLocalUserMoveHome() { - m.local_user_move_home = nil - m.clearedFields[task.FieldLocalUserMoveHome] = struct{}{} +// ClearLocalUserDescription clears the value of the "local_user_description" field. +func (m *TaskMutation) ClearLocalUserDescription() { + m.local_user_description = nil + m.clearedFields[task.FieldLocalUserDescription] = struct{}{} } -// LocalUserMoveHomeCleared returns if the "local_user_move_home" field was cleared in this mutation. -func (m *TaskMutation) LocalUserMoveHomeCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserMoveHome] +// LocalUserDescriptionCleared returns if the "local_user_description" field was cleared in this mutation. +func (m *TaskMutation) LocalUserDescriptionCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserDescription] return ok } -// ResetLocalUserMoveHome resets all changes to the "local_user_move_home" field. -func (m *TaskMutation) ResetLocalUserMoveHome() { - m.local_user_move_home = nil - delete(m.clearedFields, task.FieldLocalUserMoveHome) +// ResetLocalUserDescription resets all changes to the "local_user_description" field. +func (m *TaskMutation) ResetLocalUserDescription() { + m.local_user_description = nil + delete(m.clearedFields, task.FieldLocalUserDescription) } -// SetLocalUserNonunique sets the "local_user_nonunique" field. -func (m *TaskMutation) SetLocalUserNonunique(b bool) { - m.local_user_nonunique = &b +// SetLocalUserDisable sets the "local_user_disable" field. +func (m *TaskMutation) SetLocalUserDisable(b bool) { + m.local_user_disable = &b } -// LocalUserNonunique returns the value of the "local_user_nonunique" field in the mutation. -func (m *TaskMutation) LocalUserNonunique() (r bool, exists bool) { - v := m.local_user_nonunique +// LocalUserDisable returns the value of the "local_user_disable" field in the mutation. +func (m *TaskMutation) LocalUserDisable() (r bool, exists bool) { + v := m.local_user_disable if v == nil { return } return *v, true } -// OldLocalUserNonunique returns the old "local_user_nonunique" field's value of the Task entity. +// OldLocalUserDisable returns the old "local_user_disable" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserNonunique(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalUserDisable(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserNonunique is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserDisable is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserNonunique requires an ID field in the mutation") + return v, errors.New("OldLocalUserDisable requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserNonunique: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserDisable: %w", err) } - return oldValue.LocalUserNonunique, nil + return oldValue.LocalUserDisable, nil } -// ClearLocalUserNonunique clears the value of the "local_user_nonunique" field. -func (m *TaskMutation) ClearLocalUserNonunique() { - m.local_user_nonunique = nil - m.clearedFields[task.FieldLocalUserNonunique] = struct{}{} +// ClearLocalUserDisable clears the value of the "local_user_disable" field. +func (m *TaskMutation) ClearLocalUserDisable() { + m.local_user_disable = nil + m.clearedFields[task.FieldLocalUserDisable] = struct{}{} } -// LocalUserNonuniqueCleared returns if the "local_user_nonunique" field was cleared in this mutation. -func (m *TaskMutation) LocalUserNonuniqueCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserNonunique] +// LocalUserDisableCleared returns if the "local_user_disable" field was cleared in this mutation. +func (m *TaskMutation) LocalUserDisableCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserDisable] return ok } -// ResetLocalUserNonunique resets all changes to the "local_user_nonunique" field. -func (m *TaskMutation) ResetLocalUserNonunique() { - m.local_user_nonunique = nil - delete(m.clearedFields, task.FieldLocalUserNonunique) +// ResetLocalUserDisable resets all changes to the "local_user_disable" field. +func (m *TaskMutation) ResetLocalUserDisable() { + m.local_user_disable = nil + delete(m.clearedFields, task.FieldLocalUserDisable) } -// SetLocalUserPasswordExpireAccountDisable sets the "local_user_password_expire_account_disable" field. -func (m *TaskMutation) SetLocalUserPasswordExpireAccountDisable(s string) { - m.local_user_password_expire_account_disable = &s +// SetLocalUserFullname sets the "local_user_fullname" field. +func (m *TaskMutation) SetLocalUserFullname(s string) { + m.local_user_fullname = &s } -// LocalUserPasswordExpireAccountDisable returns the value of the "local_user_password_expire_account_disable" field in the mutation. -func (m *TaskMutation) LocalUserPasswordExpireAccountDisable() (r string, exists bool) { - v := m.local_user_password_expire_account_disable +// LocalUserFullname returns the value of the "local_user_fullname" field in the mutation. +func (m *TaskMutation) LocalUserFullname() (r string, exists bool) { + v := m.local_user_fullname if v == nil { return } return *v, true } -// OldLocalUserPasswordExpireAccountDisable returns the old "local_user_password_expire_account_disable" field's value of the Task entity. +// OldLocalUserFullname returns the old "local_user_fullname" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordExpireAccountDisable(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserFullname(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordExpireAccountDisable is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserFullname is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordExpireAccountDisable requires an ID field in the mutation") + return v, errors.New("OldLocalUserFullname requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireAccountDisable: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserFullname: %w", err) } - return oldValue.LocalUserPasswordExpireAccountDisable, nil + return oldValue.LocalUserFullname, nil } -// ClearLocalUserPasswordExpireAccountDisable clears the value of the "local_user_password_expire_account_disable" field. -func (m *TaskMutation) ClearLocalUserPasswordExpireAccountDisable() { - m.local_user_password_expire_account_disable = nil - m.clearedFields[task.FieldLocalUserPasswordExpireAccountDisable] = struct{}{} +// ClearLocalUserFullname clears the value of the "local_user_fullname" field. +func (m *TaskMutation) ClearLocalUserFullname() { + m.local_user_fullname = nil + m.clearedFields[task.FieldLocalUserFullname] = struct{}{} } -// LocalUserPasswordExpireAccountDisableCleared returns if the "local_user_password_expire_account_disable" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordExpireAccountDisableCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireAccountDisable] +// LocalUserFullnameCleared returns if the "local_user_fullname" field was cleared in this mutation. +func (m *TaskMutation) LocalUserFullnameCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserFullname] return ok } -// ResetLocalUserPasswordExpireAccountDisable resets all changes to the "local_user_password_expire_account_disable" field. -func (m *TaskMutation) ResetLocalUserPasswordExpireAccountDisable() { - m.local_user_password_expire_account_disable = nil - delete(m.clearedFields, task.FieldLocalUserPasswordExpireAccountDisable) +// ResetLocalUserFullname resets all changes to the "local_user_fullname" field. +func (m *TaskMutation) ResetLocalUserFullname() { + m.local_user_fullname = nil + delete(m.clearedFields, task.FieldLocalUserFullname) } -// SetLocalUserPasswordExpireMax sets the "local_user_password_expire_max" field. -func (m *TaskMutation) SetLocalUserPasswordExpireMax(s string) { - m.local_user_password_expire_max = &s +// SetLocalUserPassword sets the "local_user_password" field. +func (m *TaskMutation) SetLocalUserPassword(s string) { + m.local_user_password = &s } -// LocalUserPasswordExpireMax returns the value of the "local_user_password_expire_max" field in the mutation. -func (m *TaskMutation) LocalUserPasswordExpireMax() (r string, exists bool) { - v := m.local_user_password_expire_max +// LocalUserPassword returns the value of the "local_user_password" field in the mutation. +func (m *TaskMutation) LocalUserPassword() (r string, exists bool) { + v := m.local_user_password if v == nil { return } return *v, true } -// OldLocalUserPasswordExpireMax returns the old "local_user_password_expire_max" field's value of the Task entity. +// OldLocalUserPassword returns the old "local_user_password" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordExpireMax(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPassword(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordExpireMax is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPassword is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordExpireMax requires an ID field in the mutation") + return v, errors.New("OldLocalUserPassword requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireMax: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPassword: %w", err) } - return oldValue.LocalUserPasswordExpireMax, nil + return oldValue.LocalUserPassword, nil } -// ClearLocalUserPasswordExpireMax clears the value of the "local_user_password_expire_max" field. -func (m *TaskMutation) ClearLocalUserPasswordExpireMax() { - m.local_user_password_expire_max = nil - m.clearedFields[task.FieldLocalUserPasswordExpireMax] = struct{}{} +// ClearLocalUserPassword clears the value of the "local_user_password" field. +func (m *TaskMutation) ClearLocalUserPassword() { + m.local_user_password = nil + m.clearedFields[task.FieldLocalUserPassword] = struct{}{} } -// LocalUserPasswordExpireMaxCleared returns if the "local_user_password_expire_max" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordExpireMaxCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireMax] +// LocalUserPasswordCleared returns if the "local_user_password" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPassword] return ok } -// ResetLocalUserPasswordExpireMax resets all changes to the "local_user_password_expire_max" field. -func (m *TaskMutation) ResetLocalUserPasswordExpireMax() { - m.local_user_password_expire_max = nil - delete(m.clearedFields, task.FieldLocalUserPasswordExpireMax) +// ResetLocalUserPassword resets all changes to the "local_user_password" field. +func (m *TaskMutation) ResetLocalUserPassword() { + m.local_user_password = nil + delete(m.clearedFields, task.FieldLocalUserPassword) } -// SetLocalUserPasswordExpireMin sets the "local_user_password_expire_min" field. -func (m *TaskMutation) SetLocalUserPasswordExpireMin(s string) { - m.local_user_password_expire_min = &s +// SetLocalUserPasswordChangeNotAllowed sets the "local_user_password_change_not_allowed" field. +func (m *TaskMutation) SetLocalUserPasswordChangeNotAllowed(b bool) { + m.local_user_password_change_not_allowed = &b } -// LocalUserPasswordExpireMin returns the value of the "local_user_password_expire_min" field in the mutation. -func (m *TaskMutation) LocalUserPasswordExpireMin() (r string, exists bool) { - v := m.local_user_password_expire_min +// LocalUserPasswordChangeNotAllowed returns the value of the "local_user_password_change_not_allowed" field in the mutation. +func (m *TaskMutation) LocalUserPasswordChangeNotAllowed() (r bool, exists bool) { + v := m.local_user_password_change_not_allowed if v == nil { return } return *v, true } -// OldLocalUserPasswordExpireMin returns the old "local_user_password_expire_min" field's value of the Task entity. +// OldLocalUserPasswordChangeNotAllowed returns the old "local_user_password_change_not_allowed" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordExpireMin(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordChangeNotAllowed(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordExpireMin is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordChangeNotAllowed is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordExpireMin requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordChangeNotAllowed requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireMin: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordChangeNotAllowed: %w", err) } - return oldValue.LocalUserPasswordExpireMin, nil + return oldValue.LocalUserPasswordChangeNotAllowed, nil } -// ClearLocalUserPasswordExpireMin clears the value of the "local_user_password_expire_min" field. -func (m *TaskMutation) ClearLocalUserPasswordExpireMin() { - m.local_user_password_expire_min = nil - m.clearedFields[task.FieldLocalUserPasswordExpireMin] = struct{}{} +// ClearLocalUserPasswordChangeNotAllowed clears the value of the "local_user_password_change_not_allowed" field. +func (m *TaskMutation) ClearLocalUserPasswordChangeNotAllowed() { + m.local_user_password_change_not_allowed = nil + m.clearedFields[task.FieldLocalUserPasswordChangeNotAllowed] = struct{}{} } -// LocalUserPasswordExpireMinCleared returns if the "local_user_password_expire_min" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordExpireMinCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireMin] +// LocalUserPasswordChangeNotAllowedCleared returns if the "local_user_password_change_not_allowed" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordChangeNotAllowedCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordChangeNotAllowed] return ok } -// ResetLocalUserPasswordExpireMin resets all changes to the "local_user_password_expire_min" field. -func (m *TaskMutation) ResetLocalUserPasswordExpireMin() { - m.local_user_password_expire_min = nil - delete(m.clearedFields, task.FieldLocalUserPasswordExpireMin) +// ResetLocalUserPasswordChangeNotAllowed resets all changes to the "local_user_password_change_not_allowed" field. +func (m *TaskMutation) ResetLocalUserPasswordChangeNotAllowed() { + m.local_user_password_change_not_allowed = nil + delete(m.clearedFields, task.FieldLocalUserPasswordChangeNotAllowed) } -// SetLocalUserPasswordExpireWarn sets the "local_user_password_expire_warn" field. -func (m *TaskMutation) SetLocalUserPasswordExpireWarn(s string) { - m.local_user_password_expire_warn = &s +// SetLocalUserPasswordChangeRequired sets the "local_user_password_change_required" field. +func (m *TaskMutation) SetLocalUserPasswordChangeRequired(b bool) { + m.local_user_password_change_required = &b } -// LocalUserPasswordExpireWarn returns the value of the "local_user_password_expire_warn" field in the mutation. -func (m *TaskMutation) LocalUserPasswordExpireWarn() (r string, exists bool) { - v := m.local_user_password_expire_warn +// LocalUserPasswordChangeRequired returns the value of the "local_user_password_change_required" field in the mutation. +func (m *TaskMutation) LocalUserPasswordChangeRequired() (r bool, exists bool) { + v := m.local_user_password_change_required if v == nil { return } return *v, true } -// OldLocalUserPasswordExpireWarn returns the old "local_user_password_expire_warn" field's value of the Task entity. +// OldLocalUserPasswordChangeRequired returns the old "local_user_password_change_required" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordExpireWarn(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordChangeRequired(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordExpireWarn is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordChangeRequired is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordExpireWarn requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordChangeRequired requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireWarn: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordChangeRequired: %w", err) } - return oldValue.LocalUserPasswordExpireWarn, nil + return oldValue.LocalUserPasswordChangeRequired, nil } -// ClearLocalUserPasswordExpireWarn clears the value of the "local_user_password_expire_warn" field. -func (m *TaskMutation) ClearLocalUserPasswordExpireWarn() { - m.local_user_password_expire_warn = nil - m.clearedFields[task.FieldLocalUserPasswordExpireWarn] = struct{}{} +// ClearLocalUserPasswordChangeRequired clears the value of the "local_user_password_change_required" field. +func (m *TaskMutation) ClearLocalUserPasswordChangeRequired() { + m.local_user_password_change_required = nil + m.clearedFields[task.FieldLocalUserPasswordChangeRequired] = struct{}{} } -// LocalUserPasswordExpireWarnCleared returns if the "local_user_password_expire_warn" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordExpireWarnCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireWarn] +// LocalUserPasswordChangeRequiredCleared returns if the "local_user_password_change_required" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordChangeRequiredCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordChangeRequired] return ok } -// ResetLocalUserPasswordExpireWarn resets all changes to the "local_user_password_expire_warn" field. -func (m *TaskMutation) ResetLocalUserPasswordExpireWarn() { - m.local_user_password_expire_warn = nil - delete(m.clearedFields, task.FieldLocalUserPasswordExpireWarn) +// ResetLocalUserPasswordChangeRequired resets all changes to the "local_user_password_change_required" field. +func (m *TaskMutation) ResetLocalUserPasswordChangeRequired() { + m.local_user_password_change_required = nil + delete(m.clearedFields, task.FieldLocalUserPasswordChangeRequired) } -// SetLocalUserPasswordLock sets the "local_user_password_lock" field. -func (m *TaskMutation) SetLocalUserPasswordLock(b bool) { - m.local_user_password_lock = &b +// SetLocalUserPasswordNeverExpires sets the "local_user_password_never_expires" field. +func (m *TaskMutation) SetLocalUserPasswordNeverExpires(b bool) { + m.local_user_password_never_expires = &b } -// LocalUserPasswordLock returns the value of the "local_user_password_lock" field in the mutation. -func (m *TaskMutation) LocalUserPasswordLock() (r bool, exists bool) { - v := m.local_user_password_lock +// LocalUserPasswordNeverExpires returns the value of the "local_user_password_never_expires" field in the mutation. +func (m *TaskMutation) LocalUserPasswordNeverExpires() (r bool, exists bool) { + v := m.local_user_password_never_expires if v == nil { return } return *v, true } -// OldLocalUserPasswordLock returns the old "local_user_password_lock" field's value of the Task entity. +// OldLocalUserPasswordNeverExpires returns the old "local_user_password_never_expires" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserPasswordLock(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalUserPasswordNeverExpires(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserPasswordLock is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordNeverExpires is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserPasswordLock requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordNeverExpires requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserPasswordLock: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordNeverExpires: %w", err) } - return oldValue.LocalUserPasswordLock, nil + return oldValue.LocalUserPasswordNeverExpires, nil } -// ClearLocalUserPasswordLock clears the value of the "local_user_password_lock" field. -func (m *TaskMutation) ClearLocalUserPasswordLock() { - m.local_user_password_lock = nil - m.clearedFields[task.FieldLocalUserPasswordLock] = struct{}{} +// ClearLocalUserPasswordNeverExpires clears the value of the "local_user_password_never_expires" field. +func (m *TaskMutation) ClearLocalUserPasswordNeverExpires() { + m.local_user_password_never_expires = nil + m.clearedFields[task.FieldLocalUserPasswordNeverExpires] = struct{}{} } -// LocalUserPasswordLockCleared returns if the "local_user_password_lock" field was cleared in this mutation. -func (m *TaskMutation) LocalUserPasswordLockCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserPasswordLock] +// LocalUserPasswordNeverExpiresCleared returns if the "local_user_password_never_expires" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordNeverExpiresCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordNeverExpires] return ok } -// ResetLocalUserPasswordLock resets all changes to the "local_user_password_lock" field. -func (m *TaskMutation) ResetLocalUserPasswordLock() { - m.local_user_password_lock = nil - delete(m.clearedFields, task.FieldLocalUserPasswordLock) +// ResetLocalUserPasswordNeverExpires resets all changes to the "local_user_password_never_expires" field. +func (m *TaskMutation) ResetLocalUserPasswordNeverExpires() { + m.local_user_password_never_expires = nil + delete(m.clearedFields, task.FieldLocalUserPasswordNeverExpires) } -// SetLocalUserSeuser sets the "local_user_seuser" field. -func (m *TaskMutation) SetLocalUserSeuser(s string) { - m.local_user_seuser = &s +// SetLocalUserAppend sets the "local_user_append" field. +func (m *TaskMutation) SetLocalUserAppend(b bool) { + m.local_user_append = &b } -// LocalUserSeuser returns the value of the "local_user_seuser" field in the mutation. -func (m *TaskMutation) LocalUserSeuser() (r string, exists bool) { - v := m.local_user_seuser +// LocalUserAppend returns the value of the "local_user_append" field in the mutation. +func (m *TaskMutation) LocalUserAppend() (r bool, exists bool) { + v := m.local_user_append if v == nil { return } return *v, true } -// OldLocalUserSeuser returns the old "local_user_seuser" field's value of the Task entity. +// OldLocalUserAppend returns the old "local_user_append" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSeuser(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserAppend(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSeuser is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserAppend is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSeuser requires an ID field in the mutation") + return v, errors.New("OldLocalUserAppend requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSeuser: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserAppend: %w", err) } - return oldValue.LocalUserSeuser, nil + return oldValue.LocalUserAppend, nil } -// ClearLocalUserSeuser clears the value of the "local_user_seuser" field. -func (m *TaskMutation) ClearLocalUserSeuser() { - m.local_user_seuser = nil - m.clearedFields[task.FieldLocalUserSeuser] = struct{}{} +// ClearLocalUserAppend clears the value of the "local_user_append" field. +func (m *TaskMutation) ClearLocalUserAppend() { + m.local_user_append = nil + m.clearedFields[task.FieldLocalUserAppend] = struct{}{} } -// LocalUserSeuserCleared returns if the "local_user_seuser" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSeuserCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSeuser] +// LocalUserAppendCleared returns if the "local_user_append" field was cleared in this mutation. +func (m *TaskMutation) LocalUserAppendCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserAppend] return ok } -// ResetLocalUserSeuser resets all changes to the "local_user_seuser" field. -func (m *TaskMutation) ResetLocalUserSeuser() { - m.local_user_seuser = nil - delete(m.clearedFields, task.FieldLocalUserSeuser) +// ResetLocalUserAppend resets all changes to the "local_user_append" field. +func (m *TaskMutation) ResetLocalUserAppend() { + m.local_user_append = nil + delete(m.clearedFields, task.FieldLocalUserAppend) } -// SetLocalUserShell sets the "local_user_shell" field. -func (m *TaskMutation) SetLocalUserShell(s string) { - m.local_user_shell = &s +// SetLocalUserCreateHome sets the "local_user_create_home" field. +func (m *TaskMutation) SetLocalUserCreateHome(b bool) { + m.local_user_create_home = &b } -// LocalUserShell returns the value of the "local_user_shell" field in the mutation. -func (m *TaskMutation) LocalUserShell() (r string, exists bool) { - v := m.local_user_shell +// LocalUserCreateHome returns the value of the "local_user_create_home" field in the mutation. +func (m *TaskMutation) LocalUserCreateHome() (r bool, exists bool) { + v := m.local_user_create_home if v == nil { return } return *v, true } -// OldLocalUserShell returns the old "local_user_shell" field's value of the Task entity. +// OldLocalUserCreateHome returns the old "local_user_create_home" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserShell(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserCreateHome(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserShell is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserCreateHome is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserShell requires an ID field in the mutation") + return v, errors.New("OldLocalUserCreateHome requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserShell: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserCreateHome: %w", err) } - return oldValue.LocalUserShell, nil + return oldValue.LocalUserCreateHome, nil } -// ClearLocalUserShell clears the value of the "local_user_shell" field. -func (m *TaskMutation) ClearLocalUserShell() { - m.local_user_shell = nil - m.clearedFields[task.FieldLocalUserShell] = struct{}{} +// ClearLocalUserCreateHome clears the value of the "local_user_create_home" field. +func (m *TaskMutation) ClearLocalUserCreateHome() { + m.local_user_create_home = nil + m.clearedFields[task.FieldLocalUserCreateHome] = struct{}{} } -// LocalUserShellCleared returns if the "local_user_shell" field was cleared in this mutation. -func (m *TaskMutation) LocalUserShellCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserShell] +// LocalUserCreateHomeCleared returns if the "local_user_create_home" field was cleared in this mutation. +func (m *TaskMutation) LocalUserCreateHomeCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserCreateHome] return ok } -// ResetLocalUserShell resets all changes to the "local_user_shell" field. -func (m *TaskMutation) ResetLocalUserShell() { - m.local_user_shell = nil - delete(m.clearedFields, task.FieldLocalUserShell) +// ResetLocalUserCreateHome resets all changes to the "local_user_create_home" field. +func (m *TaskMutation) ResetLocalUserCreateHome() { + m.local_user_create_home = nil + delete(m.clearedFields, task.FieldLocalUserCreateHome) } -// SetLocalUserSkeleton sets the "local_user_skeleton" field. -func (m *TaskMutation) SetLocalUserSkeleton(s string) { - m.local_user_skeleton = &s +// SetLocalUserExpires sets the "local_user_expires" field. +func (m *TaskMutation) SetLocalUserExpires(s string) { + m.local_user_expires = &s } -// LocalUserSkeleton returns the value of the "local_user_skeleton" field in the mutation. -func (m *TaskMutation) LocalUserSkeleton() (r string, exists bool) { - v := m.local_user_skeleton +// LocalUserExpires returns the value of the "local_user_expires" field in the mutation. +func (m *TaskMutation) LocalUserExpires() (r string, exists bool) { + v := m.local_user_expires if v == nil { return } return *v, true } -// OldLocalUserSkeleton returns the old "local_user_skeleton" field's value of the Task entity. +// OldLocalUserExpires returns the old "local_user_expires" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSkeleton(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserExpires(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSkeleton is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserExpires is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSkeleton requires an ID field in the mutation") + return v, errors.New("OldLocalUserExpires requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSkeleton: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserExpires: %w", err) } - return oldValue.LocalUserSkeleton, nil + return oldValue.LocalUserExpires, nil } -// ClearLocalUserSkeleton clears the value of the "local_user_skeleton" field. -func (m *TaskMutation) ClearLocalUserSkeleton() { - m.local_user_skeleton = nil - m.clearedFields[task.FieldLocalUserSkeleton] = struct{}{} +// ClearLocalUserExpires clears the value of the "local_user_expires" field. +func (m *TaskMutation) ClearLocalUserExpires() { + m.local_user_expires = nil + m.clearedFields[task.FieldLocalUserExpires] = struct{}{} } -// LocalUserSkeletonCleared returns if the "local_user_skeleton" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSkeletonCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSkeleton] +// LocalUserExpiresCleared returns if the "local_user_expires" field was cleared in this mutation. +func (m *TaskMutation) LocalUserExpiresCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserExpires] return ok } -// ResetLocalUserSkeleton resets all changes to the "local_user_skeleton" field. -func (m *TaskMutation) ResetLocalUserSkeleton() { - m.local_user_skeleton = nil - delete(m.clearedFields, task.FieldLocalUserSkeleton) +// ResetLocalUserExpires resets all changes to the "local_user_expires" field. +func (m *TaskMutation) ResetLocalUserExpires() { + m.local_user_expires = nil + delete(m.clearedFields, task.FieldLocalUserExpires) } -// SetLocalUserSystem sets the "local_user_system" field. -func (m *TaskMutation) SetLocalUserSystem(b bool) { - m.local_user_system = &b +// SetLocalUserForce sets the "local_user_force" field. +func (m *TaskMutation) SetLocalUserForce(b bool) { + m.local_user_force = &b } -// LocalUserSystem returns the value of the "local_user_system" field in the mutation. -func (m *TaskMutation) LocalUserSystem() (r bool, exists bool) { - v := m.local_user_system +// LocalUserForce returns the value of the "local_user_force" field in the mutation. +func (m *TaskMutation) LocalUserForce() (r bool, exists bool) { + v := m.local_user_force if v == nil { return } return *v, true } -// OldLocalUserSystem returns the old "local_user_system" field's value of the Task entity. +// OldLocalUserForce returns the old "local_user_force" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSystem(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalUserForce(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSystem is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserForce is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSystem requires an ID field in the mutation") + return v, errors.New("OldLocalUserForce requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSystem: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserForce: %w", err) } - return oldValue.LocalUserSystem, nil + return oldValue.LocalUserForce, nil } -// ClearLocalUserSystem clears the value of the "local_user_system" field. -func (m *TaskMutation) ClearLocalUserSystem() { - m.local_user_system = nil - m.clearedFields[task.FieldLocalUserSystem] = struct{}{} +// ClearLocalUserForce clears the value of the "local_user_force" field. +func (m *TaskMutation) ClearLocalUserForce() { + m.local_user_force = nil + m.clearedFields[task.FieldLocalUserForce] = struct{}{} } -// LocalUserSystemCleared returns if the "local_user_system" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSystemCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSystem] +// LocalUserForceCleared returns if the "local_user_force" field was cleared in this mutation. +func (m *TaskMutation) LocalUserForceCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserForce] return ok } -// ResetLocalUserSystem resets all changes to the "local_user_system" field. -func (m *TaskMutation) ResetLocalUserSystem() { - m.local_user_system = nil - delete(m.clearedFields, task.FieldLocalUserSystem) +// ResetLocalUserForce resets all changes to the "local_user_force" field. +func (m *TaskMutation) ResetLocalUserForce() { + m.local_user_force = nil + delete(m.clearedFields, task.FieldLocalUserForce) } -// SetLocalUserID sets the "local_user_id" field. -func (m *TaskMutation) SetLocalUserID(s string) { - m.local_user_id = &s +// SetLocalUserGenerateSSHKey sets the "local_user_generate_ssh_key" field. +func (m *TaskMutation) SetLocalUserGenerateSSHKey(b bool) { + m.local_user_generate_ssh_key = &b } -// LocalUserID returns the value of the "local_user_id" field in the mutation. -func (m *TaskMutation) LocalUserID() (r string, exists bool) { - v := m.local_user_id +// LocalUserGenerateSSHKey returns the value of the "local_user_generate_ssh_key" field in the mutation. +func (m *TaskMutation) LocalUserGenerateSSHKey() (r bool, exists bool) { + v := m.local_user_generate_ssh_key if v == nil { return } return *v, true } -// OldLocalUserID returns the old "local_user_id" field's value of the Task entity. +// OldLocalUserGenerateSSHKey returns the old "local_user_generate_ssh_key" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserID(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserGenerateSSHKey(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserID is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserGenerateSSHKey is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserID requires an ID field in the mutation") + return v, errors.New("OldLocalUserGenerateSSHKey requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserID: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserGenerateSSHKey: %w", err) } - return oldValue.LocalUserID, nil + return oldValue.LocalUserGenerateSSHKey, nil } -// ClearLocalUserID clears the value of the "local_user_id" field. -func (m *TaskMutation) ClearLocalUserID() { - m.local_user_id = nil - m.clearedFields[task.FieldLocalUserID] = struct{}{} +// ClearLocalUserGenerateSSHKey clears the value of the "local_user_generate_ssh_key" field. +func (m *TaskMutation) ClearLocalUserGenerateSSHKey() { + m.local_user_generate_ssh_key = nil + m.clearedFields[task.FieldLocalUserGenerateSSHKey] = struct{}{} } -// LocalUserIDCleared returns if the "local_user_id" field was cleared in this mutation. -func (m *TaskMutation) LocalUserIDCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserID] +// LocalUserGenerateSSHKeyCleared returns if the "local_user_generate_ssh_key" field was cleared in this mutation. +func (m *TaskMutation) LocalUserGenerateSSHKeyCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserGenerateSSHKey] return ok } -// ResetLocalUserID resets all changes to the "local_user_id" field. -func (m *TaskMutation) ResetLocalUserID() { - m.local_user_id = nil - delete(m.clearedFields, task.FieldLocalUserID) +// ResetLocalUserGenerateSSHKey resets all changes to the "local_user_generate_ssh_key" field. +func (m *TaskMutation) ResetLocalUserGenerateSSHKey() { + m.local_user_generate_ssh_key = nil + delete(m.clearedFields, task.FieldLocalUserGenerateSSHKey) } -// SetLocalUserIDMax sets the "local_user_id_max" field. -func (m *TaskMutation) SetLocalUserIDMax(s string) { - m.local_user_id_max = &s +// SetLocalUserGroup sets the "local_user_group" field. +func (m *TaskMutation) SetLocalUserGroup(s string) { + m.local_user_group = &s } -// LocalUserIDMax returns the value of the "local_user_id_max" field in the mutation. -func (m *TaskMutation) LocalUserIDMax() (r string, exists bool) { - v := m.local_user_id_max +// LocalUserGroup returns the value of the "local_user_group" field in the mutation. +func (m *TaskMutation) LocalUserGroup() (r string, exists bool) { + v := m.local_user_group if v == nil { return } return *v, true } -// OldLocalUserIDMax returns the old "local_user_id_max" field's value of the Task entity. +// OldLocalUserGroup returns the old "local_user_group" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserIDMax(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserGroup(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserIDMax is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserGroup is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserIDMax requires an ID field in the mutation") + return v, errors.New("OldLocalUserGroup requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserIDMax: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserGroup: %w", err) } - return oldValue.LocalUserIDMax, nil + return oldValue.LocalUserGroup, nil } -// ClearLocalUserIDMax clears the value of the "local_user_id_max" field. -func (m *TaskMutation) ClearLocalUserIDMax() { - m.local_user_id_max = nil - m.clearedFields[task.FieldLocalUserIDMax] = struct{}{} +// ClearLocalUserGroup clears the value of the "local_user_group" field. +func (m *TaskMutation) ClearLocalUserGroup() { + m.local_user_group = nil + m.clearedFields[task.FieldLocalUserGroup] = struct{}{} } -// LocalUserIDMaxCleared returns if the "local_user_id_max" field was cleared in this mutation. -func (m *TaskMutation) LocalUserIDMaxCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserIDMax] +// LocalUserGroupCleared returns if the "local_user_group" field was cleared in this mutation. +func (m *TaskMutation) LocalUserGroupCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserGroup] return ok } -// ResetLocalUserIDMax resets all changes to the "local_user_id_max" field. -func (m *TaskMutation) ResetLocalUserIDMax() { - m.local_user_id_max = nil - delete(m.clearedFields, task.FieldLocalUserIDMax) +// ResetLocalUserGroup resets all changes to the "local_user_group" field. +func (m *TaskMutation) ResetLocalUserGroup() { + m.local_user_group = nil + delete(m.clearedFields, task.FieldLocalUserGroup) } -// SetLocalUserIDMin sets the "local_user_id_min" field. -func (m *TaskMutation) SetLocalUserIDMin(s string) { - m.local_user_id_min = &s +// SetLocalUserGroups sets the "local_user_groups" field. +func (m *TaskMutation) SetLocalUserGroups(s string) { + m.local_user_groups = &s } -// LocalUserIDMin returns the value of the "local_user_id_min" field in the mutation. -func (m *TaskMutation) LocalUserIDMin() (r string, exists bool) { - v := m.local_user_id_min +// LocalUserGroups returns the value of the "local_user_groups" field in the mutation. +func (m *TaskMutation) LocalUserGroups() (r string, exists bool) { + v := m.local_user_groups if v == nil { return } return *v, true } -// OldLocalUserIDMin returns the old "local_user_id_min" field's value of the Task entity. +// OldLocalUserGroups returns the old "local_user_groups" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserIDMin(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserGroups(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserIDMin is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserGroups is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserIDMin requires an ID field in the mutation") + return v, errors.New("OldLocalUserGroups requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserIDMin: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserGroups: %w", err) } - return oldValue.LocalUserIDMin, nil + return oldValue.LocalUserGroups, nil } -// ClearLocalUserIDMin clears the value of the "local_user_id_min" field. -func (m *TaskMutation) ClearLocalUserIDMin() { - m.local_user_id_min = nil - m.clearedFields[task.FieldLocalUserIDMin] = struct{}{} +// ClearLocalUserGroups clears the value of the "local_user_groups" field. +func (m *TaskMutation) ClearLocalUserGroups() { + m.local_user_groups = nil + m.clearedFields[task.FieldLocalUserGroups] = struct{}{} } -// LocalUserIDMinCleared returns if the "local_user_id_min" field was cleared in this mutation. -func (m *TaskMutation) LocalUserIDMinCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserIDMin] +// LocalUserGroupsCleared returns if the "local_user_groups" field was cleared in this mutation. +func (m *TaskMutation) LocalUserGroupsCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserGroups] return ok } -// ResetLocalUserIDMin resets all changes to the "local_user_id_min" field. -func (m *TaskMutation) ResetLocalUserIDMin() { - m.local_user_id_min = nil - delete(m.clearedFields, task.FieldLocalUserIDMin) +// ResetLocalUserGroups resets all changes to the "local_user_groups" field. +func (m *TaskMutation) ResetLocalUserGroups() { + m.local_user_groups = nil + delete(m.clearedFields, task.FieldLocalUserGroups) } -// SetLocalUserSSHKeyBits sets the "local_user_ssh_key_bits" field. -func (m *TaskMutation) SetLocalUserSSHKeyBits(s string) { - m.local_user_ssh_key_bits = &s +// SetLocalUserHome sets the "local_user_home" field. +func (m *TaskMutation) SetLocalUserHome(s string) { + m.local_user_home = &s } -// LocalUserSSHKeyBits returns the value of the "local_user_ssh_key_bits" field in the mutation. -func (m *TaskMutation) LocalUserSSHKeyBits() (r string, exists bool) { - v := m.local_user_ssh_key_bits +// LocalUserHome returns the value of the "local_user_home" field in the mutation. +func (m *TaskMutation) LocalUserHome() (r string, exists bool) { + v := m.local_user_home if v == nil { return } return *v, true } -// OldLocalUserSSHKeyBits returns the old "local_user_ssh_key_bits" field's value of the Task entity. +// OldLocalUserHome returns the old "local_user_home" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSSHKeyBits(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserHome(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSSHKeyBits is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserHome is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSSHKeyBits requires an ID field in the mutation") + return v, errors.New("OldLocalUserHome requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyBits: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserHome: %w", err) } - return oldValue.LocalUserSSHKeyBits, nil + return oldValue.LocalUserHome, nil } -// ClearLocalUserSSHKeyBits clears the value of the "local_user_ssh_key_bits" field. -func (m *TaskMutation) ClearLocalUserSSHKeyBits() { - m.local_user_ssh_key_bits = nil - m.clearedFields[task.FieldLocalUserSSHKeyBits] = struct{}{} +// ClearLocalUserHome clears the value of the "local_user_home" field. +func (m *TaskMutation) ClearLocalUserHome() { + m.local_user_home = nil + m.clearedFields[task.FieldLocalUserHome] = struct{}{} } -// LocalUserSSHKeyBitsCleared returns if the "local_user_ssh_key_bits" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSSHKeyBitsCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSSHKeyBits] +// LocalUserHomeCleared returns if the "local_user_home" field was cleared in this mutation. +func (m *TaskMutation) LocalUserHomeCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserHome] return ok } -// ResetLocalUserSSHKeyBits resets all changes to the "local_user_ssh_key_bits" field. -func (m *TaskMutation) ResetLocalUserSSHKeyBits() { - m.local_user_ssh_key_bits = nil - delete(m.clearedFields, task.FieldLocalUserSSHKeyBits) +// ResetLocalUserHome resets all changes to the "local_user_home" field. +func (m *TaskMutation) ResetLocalUserHome() { + m.local_user_home = nil + delete(m.clearedFields, task.FieldLocalUserHome) } -// SetLocalUserSSHKeyComment sets the "local_user_ssh_key_comment" field. -func (m *TaskMutation) SetLocalUserSSHKeyComment(s string) { - m.local_user_ssh_key_comment = &s +// SetLocalUserMoveHome sets the "local_user_move_home" field. +func (m *TaskMutation) SetLocalUserMoveHome(b bool) { + m.local_user_move_home = &b } -// LocalUserSSHKeyComment returns the value of the "local_user_ssh_key_comment" field in the mutation. -func (m *TaskMutation) LocalUserSSHKeyComment() (r string, exists bool) { - v := m.local_user_ssh_key_comment +// LocalUserMoveHome returns the value of the "local_user_move_home" field in the mutation. +func (m *TaskMutation) LocalUserMoveHome() (r bool, exists bool) { + v := m.local_user_move_home if v == nil { return } return *v, true } -// OldLocalUserSSHKeyComment returns the old "local_user_ssh_key_comment" field's value of the Task entity. +// OldLocalUserMoveHome returns the old "local_user_move_home" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSSHKeyComment(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserMoveHome(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSSHKeyComment is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserMoveHome is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSSHKeyComment requires an ID field in the mutation") + return v, errors.New("OldLocalUserMoveHome requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyComment: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserMoveHome: %w", err) } - return oldValue.LocalUserSSHKeyComment, nil + return oldValue.LocalUserMoveHome, nil } -// ClearLocalUserSSHKeyComment clears the value of the "local_user_ssh_key_comment" field. -func (m *TaskMutation) ClearLocalUserSSHKeyComment() { - m.local_user_ssh_key_comment = nil - m.clearedFields[task.FieldLocalUserSSHKeyComment] = struct{}{} +// ClearLocalUserMoveHome clears the value of the "local_user_move_home" field. +func (m *TaskMutation) ClearLocalUserMoveHome() { + m.local_user_move_home = nil + m.clearedFields[task.FieldLocalUserMoveHome] = struct{}{} } -// LocalUserSSHKeyCommentCleared returns if the "local_user_ssh_key_comment" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSSHKeyCommentCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSSHKeyComment] +// LocalUserMoveHomeCleared returns if the "local_user_move_home" field was cleared in this mutation. +func (m *TaskMutation) LocalUserMoveHomeCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserMoveHome] return ok } -// ResetLocalUserSSHKeyComment resets all changes to the "local_user_ssh_key_comment" field. -func (m *TaskMutation) ResetLocalUserSSHKeyComment() { - m.local_user_ssh_key_comment = nil - delete(m.clearedFields, task.FieldLocalUserSSHKeyComment) +// ResetLocalUserMoveHome resets all changes to the "local_user_move_home" field. +func (m *TaskMutation) ResetLocalUserMoveHome() { + m.local_user_move_home = nil + delete(m.clearedFields, task.FieldLocalUserMoveHome) } -// SetLocalUserSSHKeyFile sets the "local_user_ssh_key_file" field. -func (m *TaskMutation) SetLocalUserSSHKeyFile(s string) { - m.local_user_ssh_key_file = &s +// SetLocalUserNonunique sets the "local_user_nonunique" field. +func (m *TaskMutation) SetLocalUserNonunique(b bool) { + m.local_user_nonunique = &b } -// LocalUserSSHKeyFile returns the value of the "local_user_ssh_key_file" field in the mutation. -func (m *TaskMutation) LocalUserSSHKeyFile() (r string, exists bool) { - v := m.local_user_ssh_key_file +// LocalUserNonunique returns the value of the "local_user_nonunique" field in the mutation. +func (m *TaskMutation) LocalUserNonunique() (r bool, exists bool) { + v := m.local_user_nonunique if v == nil { return } return *v, true } -// OldLocalUserSSHKeyFile returns the old "local_user_ssh_key_file" field's value of the Task entity. +// OldLocalUserNonunique returns the old "local_user_nonunique" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSSHKeyFile(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserNonunique(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSSHKeyFile is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserNonunique is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSSHKeyFile requires an ID field in the mutation") + return v, errors.New("OldLocalUserNonunique requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyFile: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserNonunique: %w", err) } - return oldValue.LocalUserSSHKeyFile, nil + return oldValue.LocalUserNonunique, nil } -// ClearLocalUserSSHKeyFile clears the value of the "local_user_ssh_key_file" field. -func (m *TaskMutation) ClearLocalUserSSHKeyFile() { - m.local_user_ssh_key_file = nil - m.clearedFields[task.FieldLocalUserSSHKeyFile] = struct{}{} +// ClearLocalUserNonunique clears the value of the "local_user_nonunique" field. +func (m *TaskMutation) ClearLocalUserNonunique() { + m.local_user_nonunique = nil + m.clearedFields[task.FieldLocalUserNonunique] = struct{}{} } -// LocalUserSSHKeyFileCleared returns if the "local_user_ssh_key_file" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSSHKeyFileCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSSHKeyFile] +// LocalUserNonuniqueCleared returns if the "local_user_nonunique" field was cleared in this mutation. +func (m *TaskMutation) LocalUserNonuniqueCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserNonunique] return ok } -// ResetLocalUserSSHKeyFile resets all changes to the "local_user_ssh_key_file" field. -func (m *TaskMutation) ResetLocalUserSSHKeyFile() { - m.local_user_ssh_key_file = nil - delete(m.clearedFields, task.FieldLocalUserSSHKeyFile) +// ResetLocalUserNonunique resets all changes to the "local_user_nonunique" field. +func (m *TaskMutation) ResetLocalUserNonunique() { + m.local_user_nonunique = nil + delete(m.clearedFields, task.FieldLocalUserNonunique) } -// SetLocalUserSSHKeyPassphrase sets the "local_user_ssh_key_passphrase" field. -func (m *TaskMutation) SetLocalUserSSHKeyPassphrase(s string) { - m.local_user_ssh_key_passphrase = &s +// SetLocalUserPasswordExpireAccountDisable sets the "local_user_password_expire_account_disable" field. +func (m *TaskMutation) SetLocalUserPasswordExpireAccountDisable(s string) { + m.local_user_password_expire_account_disable = &s } -// LocalUserSSHKeyPassphrase returns the value of the "local_user_ssh_key_passphrase" field in the mutation. -func (m *TaskMutation) LocalUserSSHKeyPassphrase() (r string, exists bool) { - v := m.local_user_ssh_key_passphrase +// LocalUserPasswordExpireAccountDisable returns the value of the "local_user_password_expire_account_disable" field in the mutation. +func (m *TaskMutation) LocalUserPasswordExpireAccountDisable() (r string, exists bool) { + v := m.local_user_password_expire_account_disable if v == nil { return } return *v, true } -// OldLocalUserSSHKeyPassphrase returns the old "local_user_ssh_key_passphrase" field's value of the Task entity. +// OldLocalUserPasswordExpireAccountDisable returns the old "local_user_password_expire_account_disable" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSSHKeyPassphrase(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordExpireAccountDisable(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSSHKeyPassphrase is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordExpireAccountDisable is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSSHKeyPassphrase requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordExpireAccountDisable requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyPassphrase: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireAccountDisable: %w", err) } - return oldValue.LocalUserSSHKeyPassphrase, nil + return oldValue.LocalUserPasswordExpireAccountDisable, nil } -// ClearLocalUserSSHKeyPassphrase clears the value of the "local_user_ssh_key_passphrase" field. -func (m *TaskMutation) ClearLocalUserSSHKeyPassphrase() { - m.local_user_ssh_key_passphrase = nil - m.clearedFields[task.FieldLocalUserSSHKeyPassphrase] = struct{}{} +// ClearLocalUserPasswordExpireAccountDisable clears the value of the "local_user_password_expire_account_disable" field. +func (m *TaskMutation) ClearLocalUserPasswordExpireAccountDisable() { + m.local_user_password_expire_account_disable = nil + m.clearedFields[task.FieldLocalUserPasswordExpireAccountDisable] = struct{}{} } -// LocalUserSSHKeyPassphraseCleared returns if the "local_user_ssh_key_passphrase" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSSHKeyPassphraseCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSSHKeyPassphrase] +// LocalUserPasswordExpireAccountDisableCleared returns if the "local_user_password_expire_account_disable" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordExpireAccountDisableCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireAccountDisable] return ok } -// ResetLocalUserSSHKeyPassphrase resets all changes to the "local_user_ssh_key_passphrase" field. -func (m *TaskMutation) ResetLocalUserSSHKeyPassphrase() { - m.local_user_ssh_key_passphrase = nil - delete(m.clearedFields, task.FieldLocalUserSSHKeyPassphrase) +// ResetLocalUserPasswordExpireAccountDisable resets all changes to the "local_user_password_expire_account_disable" field. +func (m *TaskMutation) ResetLocalUserPasswordExpireAccountDisable() { + m.local_user_password_expire_account_disable = nil + delete(m.clearedFields, task.FieldLocalUserPasswordExpireAccountDisable) } -// SetLocalUserSSHKeyType sets the "local_user_ssh_key_type" field. -func (m *TaskMutation) SetLocalUserSSHKeyType(s string) { - m.local_user_ssh_key_type = &s +// SetLocalUserPasswordExpireMax sets the "local_user_password_expire_max" field. +func (m *TaskMutation) SetLocalUserPasswordExpireMax(s string) { + m.local_user_password_expire_max = &s } -// LocalUserSSHKeyType returns the value of the "local_user_ssh_key_type" field in the mutation. -func (m *TaskMutation) LocalUserSSHKeyType() (r string, exists bool) { - v := m.local_user_ssh_key_type +// LocalUserPasswordExpireMax returns the value of the "local_user_password_expire_max" field in the mutation. +func (m *TaskMutation) LocalUserPasswordExpireMax() (r string, exists bool) { + v := m.local_user_password_expire_max if v == nil { return } return *v, true } -// OldLocalUserSSHKeyType returns the old "local_user_ssh_key_type" field's value of the Task entity. +// OldLocalUserPasswordExpireMax returns the old "local_user_password_expire_max" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserSSHKeyType(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordExpireMax(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserSSHKeyType is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordExpireMax is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserSSHKeyType requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordExpireMax requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyType: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireMax: %w", err) } - return oldValue.LocalUserSSHKeyType, nil + return oldValue.LocalUserPasswordExpireMax, nil } -// ClearLocalUserSSHKeyType clears the value of the "local_user_ssh_key_type" field. -func (m *TaskMutation) ClearLocalUserSSHKeyType() { - m.local_user_ssh_key_type = nil - m.clearedFields[task.FieldLocalUserSSHKeyType] = struct{}{} +// ClearLocalUserPasswordExpireMax clears the value of the "local_user_password_expire_max" field. +func (m *TaskMutation) ClearLocalUserPasswordExpireMax() { + m.local_user_password_expire_max = nil + m.clearedFields[task.FieldLocalUserPasswordExpireMax] = struct{}{} } -// LocalUserSSHKeyTypeCleared returns if the "local_user_ssh_key_type" field was cleared in this mutation. -func (m *TaskMutation) LocalUserSSHKeyTypeCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserSSHKeyType] +// LocalUserPasswordExpireMaxCleared returns if the "local_user_password_expire_max" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordExpireMaxCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireMax] return ok } -// ResetLocalUserSSHKeyType resets all changes to the "local_user_ssh_key_type" field. -func (m *TaskMutation) ResetLocalUserSSHKeyType() { - m.local_user_ssh_key_type = nil - delete(m.clearedFields, task.FieldLocalUserSSHKeyType) +// ResetLocalUserPasswordExpireMax resets all changes to the "local_user_password_expire_max" field. +func (m *TaskMutation) ResetLocalUserPasswordExpireMax() { + m.local_user_password_expire_max = nil + delete(m.clearedFields, task.FieldLocalUserPasswordExpireMax) } -// SetLocalUserUmask sets the "local_user_umask" field. -func (m *TaskMutation) SetLocalUserUmask(s string) { - m.local_user_umask = &s +// SetLocalUserPasswordExpireMin sets the "local_user_password_expire_min" field. +func (m *TaskMutation) SetLocalUserPasswordExpireMin(s string) { + m.local_user_password_expire_min = &s } -// LocalUserUmask returns the value of the "local_user_umask" field in the mutation. -func (m *TaskMutation) LocalUserUmask() (r string, exists bool) { - v := m.local_user_umask +// LocalUserPasswordExpireMin returns the value of the "local_user_password_expire_min" field in the mutation. +func (m *TaskMutation) LocalUserPasswordExpireMin() (r string, exists bool) { + v := m.local_user_password_expire_min if v == nil { return } return *v, true } -// OldLocalUserUmask returns the old "local_user_umask" field's value of the Task entity. +// OldLocalUserPasswordExpireMin returns the old "local_user_password_expire_min" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalUserUmask(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordExpireMin(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalUserUmask is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordExpireMin is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalUserUmask requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordExpireMin requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalUserUmask: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireMin: %w", err) } - return oldValue.LocalUserUmask, nil + return oldValue.LocalUserPasswordExpireMin, nil } -// ClearLocalUserUmask clears the value of the "local_user_umask" field. -func (m *TaskMutation) ClearLocalUserUmask() { - m.local_user_umask = nil - m.clearedFields[task.FieldLocalUserUmask] = struct{}{} +// ClearLocalUserPasswordExpireMin clears the value of the "local_user_password_expire_min" field. +func (m *TaskMutation) ClearLocalUserPasswordExpireMin() { + m.local_user_password_expire_min = nil + m.clearedFields[task.FieldLocalUserPasswordExpireMin] = struct{}{} } -// LocalUserUmaskCleared returns if the "local_user_umask" field was cleared in this mutation. -func (m *TaskMutation) LocalUserUmaskCleared() bool { - _, ok := m.clearedFields[task.FieldLocalUserUmask] +// LocalUserPasswordExpireMinCleared returns if the "local_user_password_expire_min" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordExpireMinCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireMin] return ok } -// ResetLocalUserUmask resets all changes to the "local_user_umask" field. -func (m *TaskMutation) ResetLocalUserUmask() { - m.local_user_umask = nil - delete(m.clearedFields, task.FieldLocalUserUmask) +// ResetLocalUserPasswordExpireMin resets all changes to the "local_user_password_expire_min" field. +func (m *TaskMutation) ResetLocalUserPasswordExpireMin() { + m.local_user_password_expire_min = nil + delete(m.clearedFields, task.FieldLocalUserPasswordExpireMin) } -// SetLocalGroupID sets the "local_group_id" field. -func (m *TaskMutation) SetLocalGroupID(s string) { - m.local_group_id = &s +// SetLocalUserPasswordExpireWarn sets the "local_user_password_expire_warn" field. +func (m *TaskMutation) SetLocalUserPasswordExpireWarn(s string) { + m.local_user_password_expire_warn = &s } -// LocalGroupID returns the value of the "local_group_id" field in the mutation. -func (m *TaskMutation) LocalGroupID() (r string, exists bool) { - v := m.local_group_id +// LocalUserPasswordExpireWarn returns the value of the "local_user_password_expire_warn" field in the mutation. +func (m *TaskMutation) LocalUserPasswordExpireWarn() (r string, exists bool) { + v := m.local_user_password_expire_warn if v == nil { return } return *v, true } -// OldLocalGroupID returns the old "local_group_id" field's value of the Task entity. +// OldLocalUserPasswordExpireWarn returns the old "local_user_password_expire_warn" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupID(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordExpireWarn(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupID is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordExpireWarn is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupID requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordExpireWarn requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupID: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordExpireWarn: %w", err) } - return oldValue.LocalGroupID, nil + return oldValue.LocalUserPasswordExpireWarn, nil } -// ClearLocalGroupID clears the value of the "local_group_id" field. -func (m *TaskMutation) ClearLocalGroupID() { - m.local_group_id = nil - m.clearedFields[task.FieldLocalGroupID] = struct{}{} +// ClearLocalUserPasswordExpireWarn clears the value of the "local_user_password_expire_warn" field. +func (m *TaskMutation) ClearLocalUserPasswordExpireWarn() { + m.local_user_password_expire_warn = nil + m.clearedFields[task.FieldLocalUserPasswordExpireWarn] = struct{}{} } -// LocalGroupIDCleared returns if the "local_group_id" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupIDCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupID] +// LocalUserPasswordExpireWarnCleared returns if the "local_user_password_expire_warn" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordExpireWarnCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordExpireWarn] return ok } -// ResetLocalGroupID resets all changes to the "local_group_id" field. -func (m *TaskMutation) ResetLocalGroupID() { - m.local_group_id = nil - delete(m.clearedFields, task.FieldLocalGroupID) +// ResetLocalUserPasswordExpireWarn resets all changes to the "local_user_password_expire_warn" field. +func (m *TaskMutation) ResetLocalUserPasswordExpireWarn() { + m.local_user_password_expire_warn = nil + delete(m.clearedFields, task.FieldLocalUserPasswordExpireWarn) } -// SetLocalGroupName sets the "local_group_name" field. -func (m *TaskMutation) SetLocalGroupName(s string) { - m.local_group_name = &s +// SetLocalUserPasswordLock sets the "local_user_password_lock" field. +func (m *TaskMutation) SetLocalUserPasswordLock(b bool) { + m.local_user_password_lock = &b } -// LocalGroupName returns the value of the "local_group_name" field in the mutation. -func (m *TaskMutation) LocalGroupName() (r string, exists bool) { - v := m.local_group_name +// LocalUserPasswordLock returns the value of the "local_user_password_lock" field in the mutation. +func (m *TaskMutation) LocalUserPasswordLock() (r bool, exists bool) { + v := m.local_user_password_lock if v == nil { return } return *v, true } -// OldLocalGroupName returns the old "local_group_name" field's value of the Task entity. +// OldLocalUserPasswordLock returns the old "local_user_password_lock" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupName(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserPasswordLock(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupName is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserPasswordLock is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupName requires an ID field in the mutation") + return v, errors.New("OldLocalUserPasswordLock requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupName: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserPasswordLock: %w", err) } - return oldValue.LocalGroupName, nil + return oldValue.LocalUserPasswordLock, nil } -// ClearLocalGroupName clears the value of the "local_group_name" field. -func (m *TaskMutation) ClearLocalGroupName() { - m.local_group_name = nil - m.clearedFields[task.FieldLocalGroupName] = struct{}{} +// ClearLocalUserPasswordLock clears the value of the "local_user_password_lock" field. +func (m *TaskMutation) ClearLocalUserPasswordLock() { + m.local_user_password_lock = nil + m.clearedFields[task.FieldLocalUserPasswordLock] = struct{}{} } -// LocalGroupNameCleared returns if the "local_group_name" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupNameCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupName] +// LocalUserPasswordLockCleared returns if the "local_user_password_lock" field was cleared in this mutation. +func (m *TaskMutation) LocalUserPasswordLockCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserPasswordLock] return ok } -// ResetLocalGroupName resets all changes to the "local_group_name" field. -func (m *TaskMutation) ResetLocalGroupName() { - m.local_group_name = nil - delete(m.clearedFields, task.FieldLocalGroupName) +// ResetLocalUserPasswordLock resets all changes to the "local_user_password_lock" field. +func (m *TaskMutation) ResetLocalUserPasswordLock() { + m.local_user_password_lock = nil + delete(m.clearedFields, task.FieldLocalUserPasswordLock) } -// SetLocalGroupDescription sets the "local_group_description" field. -func (m *TaskMutation) SetLocalGroupDescription(s string) { - m.local_group_description = &s +// SetLocalUserSeuser sets the "local_user_seuser" field. +func (m *TaskMutation) SetLocalUserSeuser(s string) { + m.local_user_seuser = &s } -// LocalGroupDescription returns the value of the "local_group_description" field in the mutation. -func (m *TaskMutation) LocalGroupDescription() (r string, exists bool) { - v := m.local_group_description +// LocalUserSeuser returns the value of the "local_user_seuser" field in the mutation. +func (m *TaskMutation) LocalUserSeuser() (r string, exists bool) { + v := m.local_user_seuser if v == nil { return } return *v, true } -// OldLocalGroupDescription returns the old "local_group_description" field's value of the Task entity. +// OldLocalUserSeuser returns the old "local_user_seuser" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupDescription(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserSeuser(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupDescription is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSeuser is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupDescription requires an ID field in the mutation") + return v, errors.New("OldLocalUserSeuser requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupDescription: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSeuser: %w", err) } - return oldValue.LocalGroupDescription, nil + return oldValue.LocalUserSeuser, nil } -// ClearLocalGroupDescription clears the value of the "local_group_description" field. -func (m *TaskMutation) ClearLocalGroupDescription() { - m.local_group_description = nil - m.clearedFields[task.FieldLocalGroupDescription] = struct{}{} +// ClearLocalUserSeuser clears the value of the "local_user_seuser" field. +func (m *TaskMutation) ClearLocalUserSeuser() { + m.local_user_seuser = nil + m.clearedFields[task.FieldLocalUserSeuser] = struct{}{} } -// LocalGroupDescriptionCleared returns if the "local_group_description" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupDescriptionCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupDescription] +// LocalUserSeuserCleared returns if the "local_user_seuser" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSeuserCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSeuser] return ok } -// ResetLocalGroupDescription resets all changes to the "local_group_description" field. -func (m *TaskMutation) ResetLocalGroupDescription() { - m.local_group_description = nil - delete(m.clearedFields, task.FieldLocalGroupDescription) +// ResetLocalUserSeuser resets all changes to the "local_user_seuser" field. +func (m *TaskMutation) ResetLocalUserSeuser() { + m.local_user_seuser = nil + delete(m.clearedFields, task.FieldLocalUserSeuser) } -// SetLocalGroupSystem sets the "local_group_system" field. -func (m *TaskMutation) SetLocalGroupSystem(b bool) { - m.local_group_system = &b +// SetLocalUserShell sets the "local_user_shell" field. +func (m *TaskMutation) SetLocalUserShell(s string) { + m.local_user_shell = &s } -// LocalGroupSystem returns the value of the "local_group_system" field in the mutation. -func (m *TaskMutation) LocalGroupSystem() (r bool, exists bool) { - v := m.local_group_system +// LocalUserShell returns the value of the "local_user_shell" field in the mutation. +func (m *TaskMutation) LocalUserShell() (r string, exists bool) { + v := m.local_user_shell if v == nil { return } return *v, true } -// OldLocalGroupSystem returns the old "local_group_system" field's value of the Task entity. +// OldLocalUserShell returns the old "local_user_shell" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupSystem(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalUserShell(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupSystem is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserShell is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupSystem requires an ID field in the mutation") + return v, errors.New("OldLocalUserShell requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupSystem: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserShell: %w", err) } - return oldValue.LocalGroupSystem, nil + return oldValue.LocalUserShell, nil } -// ClearLocalGroupSystem clears the value of the "local_group_system" field. -func (m *TaskMutation) ClearLocalGroupSystem() { - m.local_group_system = nil - m.clearedFields[task.FieldLocalGroupSystem] = struct{}{} +// ClearLocalUserShell clears the value of the "local_user_shell" field. +func (m *TaskMutation) ClearLocalUserShell() { + m.local_user_shell = nil + m.clearedFields[task.FieldLocalUserShell] = struct{}{} } -// LocalGroupSystemCleared returns if the "local_group_system" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupSystemCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupSystem] +// LocalUserShellCleared returns if the "local_user_shell" field was cleared in this mutation. +func (m *TaskMutation) LocalUserShellCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserShell] return ok } -// ResetLocalGroupSystem resets all changes to the "local_group_system" field. -func (m *TaskMutation) ResetLocalGroupSystem() { - m.local_group_system = nil - delete(m.clearedFields, task.FieldLocalGroupSystem) +// ResetLocalUserShell resets all changes to the "local_user_shell" field. +func (m *TaskMutation) ResetLocalUserShell() { + m.local_user_shell = nil + delete(m.clearedFields, task.FieldLocalUserShell) } -// SetLocalGroupForce sets the "local_group_force" field. -func (m *TaskMutation) SetLocalGroupForce(b bool) { - m.local_group_force = &b +// SetLocalUserSkeleton sets the "local_user_skeleton" field. +func (m *TaskMutation) SetLocalUserSkeleton(s string) { + m.local_user_skeleton = &s } -// LocalGroupForce returns the value of the "local_group_force" field in the mutation. -func (m *TaskMutation) LocalGroupForce() (r bool, exists bool) { - v := m.local_group_force +// LocalUserSkeleton returns the value of the "local_user_skeleton" field in the mutation. +func (m *TaskMutation) LocalUserSkeleton() (r string, exists bool) { + v := m.local_user_skeleton if v == nil { return } return *v, true } -// OldLocalGroupForce returns the old "local_group_force" field's value of the Task entity. +// OldLocalUserSkeleton returns the old "local_user_skeleton" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupForce(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalUserSkeleton(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupForce is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSkeleton is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupForce requires an ID field in the mutation") + return v, errors.New("OldLocalUserSkeleton requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupForce: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSkeleton: %w", err) } - return oldValue.LocalGroupForce, nil + return oldValue.LocalUserSkeleton, nil } -// ClearLocalGroupForce clears the value of the "local_group_force" field. -func (m *TaskMutation) ClearLocalGroupForce() { - m.local_group_force = nil - m.clearedFields[task.FieldLocalGroupForce] = struct{}{} +// ClearLocalUserSkeleton clears the value of the "local_user_skeleton" field. +func (m *TaskMutation) ClearLocalUserSkeleton() { + m.local_user_skeleton = nil + m.clearedFields[task.FieldLocalUserSkeleton] = struct{}{} } -// LocalGroupForceCleared returns if the "local_group_force" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupForceCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupForce] +// LocalUserSkeletonCleared returns if the "local_user_skeleton" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSkeletonCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSkeleton] return ok } -// ResetLocalGroupForce resets all changes to the "local_group_force" field. -func (m *TaskMutation) ResetLocalGroupForce() { - m.local_group_force = nil - delete(m.clearedFields, task.FieldLocalGroupForce) +// ResetLocalUserSkeleton resets all changes to the "local_user_skeleton" field. +func (m *TaskMutation) ResetLocalUserSkeleton() { + m.local_user_skeleton = nil + delete(m.clearedFields, task.FieldLocalUserSkeleton) } -// SetLocalGroupMembers sets the "local_group_members" field. -func (m *TaskMutation) SetLocalGroupMembers(s string) { - m.local_group_members = &s +// SetLocalUserSystem sets the "local_user_system" field. +func (m *TaskMutation) SetLocalUserSystem(b bool) { + m.local_user_system = &b } -// LocalGroupMembers returns the value of the "local_group_members" field in the mutation. -func (m *TaskMutation) LocalGroupMembers() (r string, exists bool) { - v := m.local_group_members +// LocalUserSystem returns the value of the "local_user_system" field in the mutation. +func (m *TaskMutation) LocalUserSystem() (r bool, exists bool) { + v := m.local_user_system if v == nil { return } return *v, true } -// OldLocalGroupMembers returns the old "local_group_members" field's value of the Task entity. +// OldLocalUserSystem returns the old "local_user_system" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupMembers(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserSystem(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupMembers is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSystem is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupMembers requires an ID field in the mutation") + return v, errors.New("OldLocalUserSystem requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupMembers: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSystem: %w", err) } - return oldValue.LocalGroupMembers, nil + return oldValue.LocalUserSystem, nil } -// ClearLocalGroupMembers clears the value of the "local_group_members" field. -func (m *TaskMutation) ClearLocalGroupMembers() { - m.local_group_members = nil - m.clearedFields[task.FieldLocalGroupMembers] = struct{}{} +// ClearLocalUserSystem clears the value of the "local_user_system" field. +func (m *TaskMutation) ClearLocalUserSystem() { + m.local_user_system = nil + m.clearedFields[task.FieldLocalUserSystem] = struct{}{} } -// LocalGroupMembersCleared returns if the "local_group_members" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupMembersCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupMembers] +// LocalUserSystemCleared returns if the "local_user_system" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSystemCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSystem] return ok } -// ResetLocalGroupMembers resets all changes to the "local_group_members" field. -func (m *TaskMutation) ResetLocalGroupMembers() { - m.local_group_members = nil - delete(m.clearedFields, task.FieldLocalGroupMembers) +// ResetLocalUserSystem resets all changes to the "local_user_system" field. +func (m *TaskMutation) ResetLocalUserSystem() { + m.local_user_system = nil + delete(m.clearedFields, task.FieldLocalUserSystem) } -// SetLocalGroupMembersToInclude sets the "local_group_members_to_include" field. -func (m *TaskMutation) SetLocalGroupMembersToInclude(s string) { - m.local_group_members_to_include = &s +// SetLocalUserID sets the "local_user_id" field. +func (m *TaskMutation) SetLocalUserID(s string) { + m.local_user_id = &s } -// LocalGroupMembersToInclude returns the value of the "local_group_members_to_include" field in the mutation. -func (m *TaskMutation) LocalGroupMembersToInclude() (r string, exists bool) { - v := m.local_group_members_to_include +// LocalUserID returns the value of the "local_user_id" field in the mutation. +func (m *TaskMutation) LocalUserID() (r string, exists bool) { + v := m.local_user_id if v == nil { return } return *v, true } -// OldLocalGroupMembersToInclude returns the old "local_group_members_to_include" field's value of the Task entity. +// OldLocalUserID returns the old "local_user_id" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupMembersToInclude(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupMembersToInclude is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupMembersToInclude requires an ID field in the mutation") + return v, errors.New("OldLocalUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupMembersToInclude: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserID: %w", err) } - return oldValue.LocalGroupMembersToInclude, nil + return oldValue.LocalUserID, nil } -// ClearLocalGroupMembersToInclude clears the value of the "local_group_members_to_include" field. -func (m *TaskMutation) ClearLocalGroupMembersToInclude() { - m.local_group_members_to_include = nil - m.clearedFields[task.FieldLocalGroupMembersToInclude] = struct{}{} +// ClearLocalUserID clears the value of the "local_user_id" field. +func (m *TaskMutation) ClearLocalUserID() { + m.local_user_id = nil + m.clearedFields[task.FieldLocalUserID] = struct{}{} } -// LocalGroupMembersToIncludeCleared returns if the "local_group_members_to_include" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupMembersToIncludeCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupMembersToInclude] +// LocalUserIDCleared returns if the "local_user_id" field was cleared in this mutation. +func (m *TaskMutation) LocalUserIDCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserID] return ok } -// ResetLocalGroupMembersToInclude resets all changes to the "local_group_members_to_include" field. -func (m *TaskMutation) ResetLocalGroupMembersToInclude() { - m.local_group_members_to_include = nil - delete(m.clearedFields, task.FieldLocalGroupMembersToInclude) -} - -// SetLocalGroupMembersToExclude sets the "local_group_members_to_exclude" field. -func (m *TaskMutation) SetLocalGroupMembersToExclude(s string) { - m.local_group_members_to_exclude = &s +// ResetLocalUserID resets all changes to the "local_user_id" field. +func (m *TaskMutation) ResetLocalUserID() { + m.local_user_id = nil + delete(m.clearedFields, task.FieldLocalUserID) } -// LocalGroupMembersToExclude returns the value of the "local_group_members_to_exclude" field in the mutation. -func (m *TaskMutation) LocalGroupMembersToExclude() (r string, exists bool) { - v := m.local_group_members_to_exclude +// SetLocalUserIDMax sets the "local_user_id_max" field. +func (m *TaskMutation) SetLocalUserIDMax(s string) { + m.local_user_id_max = &s +} + +// LocalUserIDMax returns the value of the "local_user_id_max" field in the mutation. +func (m *TaskMutation) LocalUserIDMax() (r string, exists bool) { + v := m.local_user_id_max if v == nil { return } return *v, true } -// OldLocalGroupMembersToExclude returns the old "local_group_members_to_exclude" field's value of the Task entity. +// OldLocalUserIDMax returns the old "local_user_id_max" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldLocalGroupMembersToExclude(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserIDMax(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalGroupMembersToExclude is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserIDMax is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalGroupMembersToExclude requires an ID field in the mutation") + return v, errors.New("OldLocalUserIDMax requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalGroupMembersToExclude: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserIDMax: %w", err) } - return oldValue.LocalGroupMembersToExclude, nil + return oldValue.LocalUserIDMax, nil } -// ClearLocalGroupMembersToExclude clears the value of the "local_group_members_to_exclude" field. -func (m *TaskMutation) ClearLocalGroupMembersToExclude() { - m.local_group_members_to_exclude = nil - m.clearedFields[task.FieldLocalGroupMembersToExclude] = struct{}{} +// ClearLocalUserIDMax clears the value of the "local_user_id_max" field. +func (m *TaskMutation) ClearLocalUserIDMax() { + m.local_user_id_max = nil + m.clearedFields[task.FieldLocalUserIDMax] = struct{}{} } -// LocalGroupMembersToExcludeCleared returns if the "local_group_members_to_exclude" field was cleared in this mutation. -func (m *TaskMutation) LocalGroupMembersToExcludeCleared() bool { - _, ok := m.clearedFields[task.FieldLocalGroupMembersToExclude] +// LocalUserIDMaxCleared returns if the "local_user_id_max" field was cleared in this mutation. +func (m *TaskMutation) LocalUserIDMaxCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserIDMax] return ok } -// ResetLocalGroupMembersToExclude resets all changes to the "local_group_members_to_exclude" field. -func (m *TaskMutation) ResetLocalGroupMembersToExclude() { - m.local_group_members_to_exclude = nil - delete(m.clearedFields, task.FieldLocalGroupMembersToExclude) +// ResetLocalUserIDMax resets all changes to the "local_user_id_max" field. +func (m *TaskMutation) ResetLocalUserIDMax() { + m.local_user_id_max = nil + delete(m.clearedFields, task.FieldLocalUserIDMax) } -// SetMsiProductid sets the "msi_productid" field. -func (m *TaskMutation) SetMsiProductid(s string) { - m.msi_productid = &s +// SetLocalUserIDMin sets the "local_user_id_min" field. +func (m *TaskMutation) SetLocalUserIDMin(s string) { + m.local_user_id_min = &s } -// MsiProductid returns the value of the "msi_productid" field in the mutation. -func (m *TaskMutation) MsiProductid() (r string, exists bool) { - v := m.msi_productid +// LocalUserIDMin returns the value of the "local_user_id_min" field in the mutation. +func (m *TaskMutation) LocalUserIDMin() (r string, exists bool) { + v := m.local_user_id_min if v == nil { return } return *v, true } -// OldMsiProductid returns the old "msi_productid" field's value of the Task entity. +// OldLocalUserIDMin returns the old "local_user_id_min" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldMsiProductid(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserIDMin(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMsiProductid is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserIDMin is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMsiProductid requires an ID field in the mutation") + return v, errors.New("OldLocalUserIDMin requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMsiProductid: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserIDMin: %w", err) } - return oldValue.MsiProductid, nil + return oldValue.LocalUserIDMin, nil } -// ClearMsiProductid clears the value of the "msi_productid" field. -func (m *TaskMutation) ClearMsiProductid() { - m.msi_productid = nil - m.clearedFields[task.FieldMsiProductid] = struct{}{} +// ClearLocalUserIDMin clears the value of the "local_user_id_min" field. +func (m *TaskMutation) ClearLocalUserIDMin() { + m.local_user_id_min = nil + m.clearedFields[task.FieldLocalUserIDMin] = struct{}{} } -// MsiProductidCleared returns if the "msi_productid" field was cleared in this mutation. -func (m *TaskMutation) MsiProductidCleared() bool { - _, ok := m.clearedFields[task.FieldMsiProductid] +// LocalUserIDMinCleared returns if the "local_user_id_min" field was cleared in this mutation. +func (m *TaskMutation) LocalUserIDMinCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserIDMin] return ok } -// ResetMsiProductid resets all changes to the "msi_productid" field. -func (m *TaskMutation) ResetMsiProductid() { - m.msi_productid = nil - delete(m.clearedFields, task.FieldMsiProductid) +// ResetLocalUserIDMin resets all changes to the "local_user_id_min" field. +func (m *TaskMutation) ResetLocalUserIDMin() { + m.local_user_id_min = nil + delete(m.clearedFields, task.FieldLocalUserIDMin) } -// SetMsiPath sets the "msi_path" field. -func (m *TaskMutation) SetMsiPath(s string) { - m.msi_path = &s +// SetLocalUserSSHKeyBits sets the "local_user_ssh_key_bits" field. +func (m *TaskMutation) SetLocalUserSSHKeyBits(s string) { + m.local_user_ssh_key_bits = &s } -// MsiPath returns the value of the "msi_path" field in the mutation. -func (m *TaskMutation) MsiPath() (r string, exists bool) { - v := m.msi_path +// LocalUserSSHKeyBits returns the value of the "local_user_ssh_key_bits" field in the mutation. +func (m *TaskMutation) LocalUserSSHKeyBits() (r string, exists bool) { + v := m.local_user_ssh_key_bits if v == nil { return } return *v, true } -// OldMsiPath returns the old "msi_path" field's value of the Task entity. +// OldLocalUserSSHKeyBits returns the old "local_user_ssh_key_bits" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldMsiPath(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserSSHKeyBits(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMsiPath is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSSHKeyBits is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMsiPath requires an ID field in the mutation") + return v, errors.New("OldLocalUserSSHKeyBits requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMsiPath: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyBits: %w", err) } - return oldValue.MsiPath, nil + return oldValue.LocalUserSSHKeyBits, nil } -// ClearMsiPath clears the value of the "msi_path" field. -func (m *TaskMutation) ClearMsiPath() { - m.msi_path = nil - m.clearedFields[task.FieldMsiPath] = struct{}{} +// ClearLocalUserSSHKeyBits clears the value of the "local_user_ssh_key_bits" field. +func (m *TaskMutation) ClearLocalUserSSHKeyBits() { + m.local_user_ssh_key_bits = nil + m.clearedFields[task.FieldLocalUserSSHKeyBits] = struct{}{} } -// MsiPathCleared returns if the "msi_path" field was cleared in this mutation. -func (m *TaskMutation) MsiPathCleared() bool { - _, ok := m.clearedFields[task.FieldMsiPath] +// LocalUserSSHKeyBitsCleared returns if the "local_user_ssh_key_bits" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSSHKeyBitsCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSSHKeyBits] return ok } -// ResetMsiPath resets all changes to the "msi_path" field. -func (m *TaskMutation) ResetMsiPath() { - m.msi_path = nil - delete(m.clearedFields, task.FieldMsiPath) +// ResetLocalUserSSHKeyBits resets all changes to the "local_user_ssh_key_bits" field. +func (m *TaskMutation) ResetLocalUserSSHKeyBits() { + m.local_user_ssh_key_bits = nil + delete(m.clearedFields, task.FieldLocalUserSSHKeyBits) } -// SetMsiArguments sets the "msi_arguments" field. -func (m *TaskMutation) SetMsiArguments(s string) { - m.msi_arguments = &s +// SetLocalUserSSHKeyComment sets the "local_user_ssh_key_comment" field. +func (m *TaskMutation) SetLocalUserSSHKeyComment(s string) { + m.local_user_ssh_key_comment = &s } -// MsiArguments returns the value of the "msi_arguments" field in the mutation. -func (m *TaskMutation) MsiArguments() (r string, exists bool) { - v := m.msi_arguments +// LocalUserSSHKeyComment returns the value of the "local_user_ssh_key_comment" field in the mutation. +func (m *TaskMutation) LocalUserSSHKeyComment() (r string, exists bool) { + v := m.local_user_ssh_key_comment if v == nil { return } return *v, true } -// OldMsiArguments returns the old "msi_arguments" field's value of the Task entity. +// OldLocalUserSSHKeyComment returns the old "local_user_ssh_key_comment" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldMsiArguments(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserSSHKeyComment(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMsiArguments is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSSHKeyComment is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMsiArguments requires an ID field in the mutation") + return v, errors.New("OldLocalUserSSHKeyComment requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMsiArguments: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyComment: %w", err) } - return oldValue.MsiArguments, nil + return oldValue.LocalUserSSHKeyComment, nil } -// ClearMsiArguments clears the value of the "msi_arguments" field. -func (m *TaskMutation) ClearMsiArguments() { - m.msi_arguments = nil - m.clearedFields[task.FieldMsiArguments] = struct{}{} +// ClearLocalUserSSHKeyComment clears the value of the "local_user_ssh_key_comment" field. +func (m *TaskMutation) ClearLocalUserSSHKeyComment() { + m.local_user_ssh_key_comment = nil + m.clearedFields[task.FieldLocalUserSSHKeyComment] = struct{}{} } -// MsiArgumentsCleared returns if the "msi_arguments" field was cleared in this mutation. -func (m *TaskMutation) MsiArgumentsCleared() bool { - _, ok := m.clearedFields[task.FieldMsiArguments] +// LocalUserSSHKeyCommentCleared returns if the "local_user_ssh_key_comment" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSSHKeyCommentCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSSHKeyComment] return ok } -// ResetMsiArguments resets all changes to the "msi_arguments" field. -func (m *TaskMutation) ResetMsiArguments() { - m.msi_arguments = nil - delete(m.clearedFields, task.FieldMsiArguments) +// ResetLocalUserSSHKeyComment resets all changes to the "local_user_ssh_key_comment" field. +func (m *TaskMutation) ResetLocalUserSSHKeyComment() { + m.local_user_ssh_key_comment = nil + delete(m.clearedFields, task.FieldLocalUserSSHKeyComment) } -// SetMsiFileHash sets the "msi_file_hash" field. -func (m *TaskMutation) SetMsiFileHash(s string) { - m.msi_file_hash = &s +// SetLocalUserSSHKeyFile sets the "local_user_ssh_key_file" field. +func (m *TaskMutation) SetLocalUserSSHKeyFile(s string) { + m.local_user_ssh_key_file = &s } -// MsiFileHash returns the value of the "msi_file_hash" field in the mutation. -func (m *TaskMutation) MsiFileHash() (r string, exists bool) { - v := m.msi_file_hash +// LocalUserSSHKeyFile returns the value of the "local_user_ssh_key_file" field in the mutation. +func (m *TaskMutation) LocalUserSSHKeyFile() (r string, exists bool) { + v := m.local_user_ssh_key_file if v == nil { return } return *v, true } -// OldMsiFileHash returns the old "msi_file_hash" field's value of the Task entity. +// OldLocalUserSSHKeyFile returns the old "local_user_ssh_key_file" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldMsiFileHash(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserSSHKeyFile(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMsiFileHash is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSSHKeyFile is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMsiFileHash requires an ID field in the mutation") + return v, errors.New("OldLocalUserSSHKeyFile requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMsiFileHash: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyFile: %w", err) } - return oldValue.MsiFileHash, nil + return oldValue.LocalUserSSHKeyFile, nil } -// ClearMsiFileHash clears the value of the "msi_file_hash" field. -func (m *TaskMutation) ClearMsiFileHash() { - m.msi_file_hash = nil - m.clearedFields[task.FieldMsiFileHash] = struct{}{} +// ClearLocalUserSSHKeyFile clears the value of the "local_user_ssh_key_file" field. +func (m *TaskMutation) ClearLocalUserSSHKeyFile() { + m.local_user_ssh_key_file = nil + m.clearedFields[task.FieldLocalUserSSHKeyFile] = struct{}{} } -// MsiFileHashCleared returns if the "msi_file_hash" field was cleared in this mutation. -func (m *TaskMutation) MsiFileHashCleared() bool { - _, ok := m.clearedFields[task.FieldMsiFileHash] +// LocalUserSSHKeyFileCleared returns if the "local_user_ssh_key_file" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSSHKeyFileCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSSHKeyFile] return ok } -// ResetMsiFileHash resets all changes to the "msi_file_hash" field. -func (m *TaskMutation) ResetMsiFileHash() { - m.msi_file_hash = nil - delete(m.clearedFields, task.FieldMsiFileHash) +// ResetLocalUserSSHKeyFile resets all changes to the "local_user_ssh_key_file" field. +func (m *TaskMutation) ResetLocalUserSSHKeyFile() { + m.local_user_ssh_key_file = nil + delete(m.clearedFields, task.FieldLocalUserSSHKeyFile) } -// SetMsiFileHashAlg sets the "msi_file_hash_alg" field. -func (m *TaskMutation) SetMsiFileHashAlg(tfha task.MsiFileHashAlg) { - m.msi_file_hash_alg = &tfha +// SetLocalUserSSHKeyPassphrase sets the "local_user_ssh_key_passphrase" field. +func (m *TaskMutation) SetLocalUserSSHKeyPassphrase(s string) { + m.local_user_ssh_key_passphrase = &s } -// MsiFileHashAlg returns the value of the "msi_file_hash_alg" field in the mutation. -func (m *TaskMutation) MsiFileHashAlg() (r task.MsiFileHashAlg, exists bool) { - v := m.msi_file_hash_alg +// LocalUserSSHKeyPassphrase returns the value of the "local_user_ssh_key_passphrase" field in the mutation. +func (m *TaskMutation) LocalUserSSHKeyPassphrase() (r string, exists bool) { + v := m.local_user_ssh_key_passphrase if v == nil { return } return *v, true } -// OldMsiFileHashAlg returns the old "msi_file_hash_alg" field's value of the Task entity. +// OldLocalUserSSHKeyPassphrase returns the old "local_user_ssh_key_passphrase" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldMsiFileHashAlg(ctx context.Context) (v task.MsiFileHashAlg, err error) { +func (m *TaskMutation) OldLocalUserSSHKeyPassphrase(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMsiFileHashAlg is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSSHKeyPassphrase is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMsiFileHashAlg requires an ID field in the mutation") + return v, errors.New("OldLocalUserSSHKeyPassphrase requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMsiFileHashAlg: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyPassphrase: %w", err) } - return oldValue.MsiFileHashAlg, nil + return oldValue.LocalUserSSHKeyPassphrase, nil } -// ClearMsiFileHashAlg clears the value of the "msi_file_hash_alg" field. -func (m *TaskMutation) ClearMsiFileHashAlg() { - m.msi_file_hash_alg = nil - m.clearedFields[task.FieldMsiFileHashAlg] = struct{}{} +// ClearLocalUserSSHKeyPassphrase clears the value of the "local_user_ssh_key_passphrase" field. +func (m *TaskMutation) ClearLocalUserSSHKeyPassphrase() { + m.local_user_ssh_key_passphrase = nil + m.clearedFields[task.FieldLocalUserSSHKeyPassphrase] = struct{}{} } -// MsiFileHashAlgCleared returns if the "msi_file_hash_alg" field was cleared in this mutation. -func (m *TaskMutation) MsiFileHashAlgCleared() bool { - _, ok := m.clearedFields[task.FieldMsiFileHashAlg] +// LocalUserSSHKeyPassphraseCleared returns if the "local_user_ssh_key_passphrase" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSSHKeyPassphraseCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSSHKeyPassphrase] return ok } -// ResetMsiFileHashAlg resets all changes to the "msi_file_hash_alg" field. -func (m *TaskMutation) ResetMsiFileHashAlg() { - m.msi_file_hash_alg = nil - delete(m.clearedFields, task.FieldMsiFileHashAlg) +// ResetLocalUserSSHKeyPassphrase resets all changes to the "local_user_ssh_key_passphrase" field. +func (m *TaskMutation) ResetLocalUserSSHKeyPassphrase() { + m.local_user_ssh_key_passphrase = nil + delete(m.clearedFields, task.FieldLocalUserSSHKeyPassphrase) } -// SetMsiLogPath sets the "msi_log_path" field. -func (m *TaskMutation) SetMsiLogPath(s string) { - m.msi_log_path = &s +// SetLocalUserSSHKeyType sets the "local_user_ssh_key_type" field. +func (m *TaskMutation) SetLocalUserSSHKeyType(s string) { + m.local_user_ssh_key_type = &s } -// MsiLogPath returns the value of the "msi_log_path" field in the mutation. -func (m *TaskMutation) MsiLogPath() (r string, exists bool) { - v := m.msi_log_path +// LocalUserSSHKeyType returns the value of the "local_user_ssh_key_type" field in the mutation. +func (m *TaskMutation) LocalUserSSHKeyType() (r string, exists bool) { + v := m.local_user_ssh_key_type if v == nil { return } return *v, true } -// OldMsiLogPath returns the old "msi_log_path" field's value of the Task entity. +// OldLocalUserSSHKeyType returns the old "local_user_ssh_key_type" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldMsiLogPath(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserSSHKeyType(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMsiLogPath is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserSSHKeyType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMsiLogPath requires an ID field in the mutation") + return v, errors.New("OldLocalUserSSHKeyType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMsiLogPath: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserSSHKeyType: %w", err) } - return oldValue.MsiLogPath, nil + return oldValue.LocalUserSSHKeyType, nil } -// ClearMsiLogPath clears the value of the "msi_log_path" field. -func (m *TaskMutation) ClearMsiLogPath() { - m.msi_log_path = nil - m.clearedFields[task.FieldMsiLogPath] = struct{}{} +// ClearLocalUserSSHKeyType clears the value of the "local_user_ssh_key_type" field. +func (m *TaskMutation) ClearLocalUserSSHKeyType() { + m.local_user_ssh_key_type = nil + m.clearedFields[task.FieldLocalUserSSHKeyType] = struct{}{} } -// MsiLogPathCleared returns if the "msi_log_path" field was cleared in this mutation. -func (m *TaskMutation) MsiLogPathCleared() bool { - _, ok := m.clearedFields[task.FieldMsiLogPath] +// LocalUserSSHKeyTypeCleared returns if the "local_user_ssh_key_type" field was cleared in this mutation. +func (m *TaskMutation) LocalUserSSHKeyTypeCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserSSHKeyType] return ok } -// ResetMsiLogPath resets all changes to the "msi_log_path" field. -func (m *TaskMutation) ResetMsiLogPath() { - m.msi_log_path = nil - delete(m.clearedFields, task.FieldMsiLogPath) +// ResetLocalUserSSHKeyType resets all changes to the "local_user_ssh_key_type" field. +func (m *TaskMutation) ResetLocalUserSSHKeyType() { + m.local_user_ssh_key_type = nil + delete(m.clearedFields, task.FieldLocalUserSSHKeyType) } -// SetScript sets the "script" field. -func (m *TaskMutation) SetScript(s string) { - m.script = &s +// SetLocalUserUmask sets the "local_user_umask" field. +func (m *TaskMutation) SetLocalUserUmask(s string) { + m.local_user_umask = &s } -// Script returns the value of the "script" field in the mutation. -func (m *TaskMutation) Script() (r string, exists bool) { - v := m.script +// LocalUserUmask returns the value of the "local_user_umask" field in the mutation. +func (m *TaskMutation) LocalUserUmask() (r string, exists bool) { + v := m.local_user_umask if v == nil { return } return *v, true } -// OldScript returns the old "script" field's value of the Task entity. +// OldLocalUserUmask returns the old "local_user_umask" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldScript(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalUserUmask(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScript is only allowed on UpdateOne operations") + return v, errors.New("OldLocalUserUmask is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScript requires an ID field in the mutation") + return v, errors.New("OldLocalUserUmask requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScript: %w", err) + return v, fmt.Errorf("querying old value for OldLocalUserUmask: %w", err) } - return oldValue.Script, nil + return oldValue.LocalUserUmask, nil } -// ClearScript clears the value of the "script" field. -func (m *TaskMutation) ClearScript() { - m.script = nil - m.clearedFields[task.FieldScript] = struct{}{} +// ClearLocalUserUmask clears the value of the "local_user_umask" field. +func (m *TaskMutation) ClearLocalUserUmask() { + m.local_user_umask = nil + m.clearedFields[task.FieldLocalUserUmask] = struct{}{} } -// ScriptCleared returns if the "script" field was cleared in this mutation. -func (m *TaskMutation) ScriptCleared() bool { - _, ok := m.clearedFields[task.FieldScript] +// LocalUserUmaskCleared returns if the "local_user_umask" field was cleared in this mutation. +func (m *TaskMutation) LocalUserUmaskCleared() bool { + _, ok := m.clearedFields[task.FieldLocalUserUmask] return ok } -// ResetScript resets all changes to the "script" field. -func (m *TaskMutation) ResetScript() { - m.script = nil - delete(m.clearedFields, task.FieldScript) +// ResetLocalUserUmask resets all changes to the "local_user_umask" field. +func (m *TaskMutation) ResetLocalUserUmask() { + m.local_user_umask = nil + delete(m.clearedFields, task.FieldLocalUserUmask) } -// SetScriptExecutable sets the "script_executable" field. -func (m *TaskMutation) SetScriptExecutable(s string) { - m.script_executable = &s +// SetLocalGroupID sets the "local_group_id" field. +func (m *TaskMutation) SetLocalGroupID(s string) { + m.local_group_id = &s } -// ScriptExecutable returns the value of the "script_executable" field in the mutation. -func (m *TaskMutation) ScriptExecutable() (r string, exists bool) { - v := m.script_executable +// LocalGroupID returns the value of the "local_group_id" field in the mutation. +func (m *TaskMutation) LocalGroupID() (r string, exists bool) { + v := m.local_group_id if v == nil { return } return *v, true } -// OldScriptExecutable returns the old "script_executable" field's value of the Task entity. +// OldLocalGroupID returns the old "local_group_id" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldScriptExecutable(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalGroupID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScriptExecutable is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScriptExecutable requires an ID field in the mutation") + return v, errors.New("OldLocalGroupID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScriptExecutable: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupID: %w", err) } - return oldValue.ScriptExecutable, nil + return oldValue.LocalGroupID, nil } -// ClearScriptExecutable clears the value of the "script_executable" field. -func (m *TaskMutation) ClearScriptExecutable() { - m.script_executable = nil - m.clearedFields[task.FieldScriptExecutable] = struct{}{} +// ClearLocalGroupID clears the value of the "local_group_id" field. +func (m *TaskMutation) ClearLocalGroupID() { + m.local_group_id = nil + m.clearedFields[task.FieldLocalGroupID] = struct{}{} } -// ScriptExecutableCleared returns if the "script_executable" field was cleared in this mutation. -func (m *TaskMutation) ScriptExecutableCleared() bool { - _, ok := m.clearedFields[task.FieldScriptExecutable] +// LocalGroupIDCleared returns if the "local_group_id" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupIDCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupID] return ok } -// ResetScriptExecutable resets all changes to the "script_executable" field. -func (m *TaskMutation) ResetScriptExecutable() { - m.script_executable = nil - delete(m.clearedFields, task.FieldScriptExecutable) +// ResetLocalGroupID resets all changes to the "local_group_id" field. +func (m *TaskMutation) ResetLocalGroupID() { + m.local_group_id = nil + delete(m.clearedFields, task.FieldLocalGroupID) } -// SetScriptCreates sets the "script_creates" field. -func (m *TaskMutation) SetScriptCreates(s string) { - m.script_creates = &s +// SetLocalGroupName sets the "local_group_name" field. +func (m *TaskMutation) SetLocalGroupName(s string) { + m.local_group_name = &s } -// ScriptCreates returns the value of the "script_creates" field in the mutation. -func (m *TaskMutation) ScriptCreates() (r string, exists bool) { - v := m.script_creates +// LocalGroupName returns the value of the "local_group_name" field in the mutation. +func (m *TaskMutation) LocalGroupName() (r string, exists bool) { + v := m.local_group_name if v == nil { return } return *v, true } -// OldScriptCreates returns the old "script_creates" field's value of the Task entity. +// OldLocalGroupName returns the old "local_group_name" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldScriptCreates(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalGroupName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScriptCreates is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScriptCreates requires an ID field in the mutation") + return v, errors.New("OldLocalGroupName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScriptCreates: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupName: %w", err) } - return oldValue.ScriptCreates, nil + return oldValue.LocalGroupName, nil } -// ClearScriptCreates clears the value of the "script_creates" field. -func (m *TaskMutation) ClearScriptCreates() { - m.script_creates = nil - m.clearedFields[task.FieldScriptCreates] = struct{}{} +// ClearLocalGroupName clears the value of the "local_group_name" field. +func (m *TaskMutation) ClearLocalGroupName() { + m.local_group_name = nil + m.clearedFields[task.FieldLocalGroupName] = struct{}{} } -// ScriptCreatesCleared returns if the "script_creates" field was cleared in this mutation. -func (m *TaskMutation) ScriptCreatesCleared() bool { - _, ok := m.clearedFields[task.FieldScriptCreates] +// LocalGroupNameCleared returns if the "local_group_name" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupNameCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupName] return ok } -// ResetScriptCreates resets all changes to the "script_creates" field. -func (m *TaskMutation) ResetScriptCreates() { - m.script_creates = nil - delete(m.clearedFields, task.FieldScriptCreates) +// ResetLocalGroupName resets all changes to the "local_group_name" field. +func (m *TaskMutation) ResetLocalGroupName() { + m.local_group_name = nil + delete(m.clearedFields, task.FieldLocalGroupName) } -// SetScriptRun sets the "script_run" field. -func (m *TaskMutation) SetScriptRun(tr task.ScriptRun) { - m.script_run = &tr +// SetLocalGroupDescription sets the "local_group_description" field. +func (m *TaskMutation) SetLocalGroupDescription(s string) { + m.local_group_description = &s } -// ScriptRun returns the value of the "script_run" field in the mutation. -func (m *TaskMutation) ScriptRun() (r task.ScriptRun, exists bool) { - v := m.script_run +// LocalGroupDescription returns the value of the "local_group_description" field in the mutation. +func (m *TaskMutation) LocalGroupDescription() (r string, exists bool) { + v := m.local_group_description if v == nil { return } return *v, true } -// OldScriptRun returns the old "script_run" field's value of the Task entity. +// OldLocalGroupDescription returns the old "local_group_description" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldScriptRun(ctx context.Context) (v task.ScriptRun, err error) { +func (m *TaskMutation) OldLocalGroupDescription(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScriptRun is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupDescription is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScriptRun requires an ID field in the mutation") + return v, errors.New("OldLocalGroupDescription requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScriptRun: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupDescription: %w", err) } - return oldValue.ScriptRun, nil + return oldValue.LocalGroupDescription, nil } -// ClearScriptRun clears the value of the "script_run" field. -func (m *TaskMutation) ClearScriptRun() { - m.script_run = nil - m.clearedFields[task.FieldScriptRun] = struct{}{} +// ClearLocalGroupDescription clears the value of the "local_group_description" field. +func (m *TaskMutation) ClearLocalGroupDescription() { + m.local_group_description = nil + m.clearedFields[task.FieldLocalGroupDescription] = struct{}{} } -// ScriptRunCleared returns if the "script_run" field was cleared in this mutation. -func (m *TaskMutation) ScriptRunCleared() bool { - _, ok := m.clearedFields[task.FieldScriptRun] +// LocalGroupDescriptionCleared returns if the "local_group_description" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupDescriptionCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupDescription] return ok } -// ResetScriptRun resets all changes to the "script_run" field. -func (m *TaskMutation) ResetScriptRun() { - m.script_run = nil - delete(m.clearedFields, task.FieldScriptRun) +// ResetLocalGroupDescription resets all changes to the "local_group_description" field. +func (m *TaskMutation) ResetLocalGroupDescription() { + m.local_group_description = nil + delete(m.clearedFields, task.FieldLocalGroupDescription) } -// SetAgentType sets the "agent_type" field. -func (m *TaskMutation) SetAgentType(tt task.AgentType) { - m.agent_type = &tt +// SetLocalGroupSystem sets the "local_group_system" field. +func (m *TaskMutation) SetLocalGroupSystem(b bool) { + m.local_group_system = &b } -// AgentType returns the value of the "agent_type" field in the mutation. -func (m *TaskMutation) AgentType() (r task.AgentType, exists bool) { - v := m.agent_type +// LocalGroupSystem returns the value of the "local_group_system" field in the mutation. +func (m *TaskMutation) LocalGroupSystem() (r bool, exists bool) { + v := m.local_group_system if v == nil { return } return *v, true } -// OldAgentType returns the old "agent_type" field's value of the Task entity. +// OldLocalGroupSystem returns the old "local_group_system" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAgentType(ctx context.Context) (v task.AgentType, err error) { +func (m *TaskMutation) OldLocalGroupSystem(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAgentType is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupSystem is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAgentType requires an ID field in the mutation") + return v, errors.New("OldLocalGroupSystem requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAgentType: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupSystem: %w", err) } - return oldValue.AgentType, nil + return oldValue.LocalGroupSystem, nil } -// ClearAgentType clears the value of the "agent_type" field. -func (m *TaskMutation) ClearAgentType() { - m.agent_type = nil - m.clearedFields[task.FieldAgentType] = struct{}{} +// ClearLocalGroupSystem clears the value of the "local_group_system" field. +func (m *TaskMutation) ClearLocalGroupSystem() { + m.local_group_system = nil + m.clearedFields[task.FieldLocalGroupSystem] = struct{}{} } -// AgentTypeCleared returns if the "agent_type" field was cleared in this mutation. -func (m *TaskMutation) AgentTypeCleared() bool { - _, ok := m.clearedFields[task.FieldAgentType] +// LocalGroupSystemCleared returns if the "local_group_system" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupSystemCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupSystem] return ok } -// ResetAgentType resets all changes to the "agent_type" field. -func (m *TaskMutation) ResetAgentType() { - m.agent_type = nil - delete(m.clearedFields, task.FieldAgentType) +// ResetLocalGroupSystem resets all changes to the "local_group_system" field. +func (m *TaskMutation) ResetLocalGroupSystem() { + m.local_group_system = nil + delete(m.clearedFields, task.FieldLocalGroupSystem) } -// SetWhen sets the "when" field. -func (m *TaskMutation) SetWhen(t time.Time) { - m.when = &t +// SetLocalGroupForce sets the "local_group_force" field. +func (m *TaskMutation) SetLocalGroupForce(b bool) { + m.local_group_force = &b } -// When returns the value of the "when" field in the mutation. -func (m *TaskMutation) When() (r time.Time, exists bool) { - v := m.when +// LocalGroupForce returns the value of the "local_group_force" field in the mutation. +func (m *TaskMutation) LocalGroupForce() (r bool, exists bool) { + v := m.local_group_force if v == nil { return } return *v, true } -// OldWhen returns the old "when" field's value of the Task entity. +// OldLocalGroupForce returns the old "local_group_force" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldWhen(ctx context.Context) (v time.Time, err error) { +func (m *TaskMutation) OldLocalGroupForce(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWhen is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupForce is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWhen requires an ID field in the mutation") + return v, errors.New("OldLocalGroupForce requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldWhen: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupForce: %w", err) } - return oldValue.When, nil + return oldValue.LocalGroupForce, nil } -// ClearWhen clears the value of the "when" field. -func (m *TaskMutation) ClearWhen() { - m.when = nil - m.clearedFields[task.FieldWhen] = struct{}{} +// ClearLocalGroupForce clears the value of the "local_group_force" field. +func (m *TaskMutation) ClearLocalGroupForce() { + m.local_group_force = nil + m.clearedFields[task.FieldLocalGroupForce] = struct{}{} } -// WhenCleared returns if the "when" field was cleared in this mutation. -func (m *TaskMutation) WhenCleared() bool { - _, ok := m.clearedFields[task.FieldWhen] +// LocalGroupForceCleared returns if the "local_group_force" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupForceCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupForce] return ok } -// ResetWhen resets all changes to the "when" field. -func (m *TaskMutation) ResetWhen() { - m.when = nil - delete(m.clearedFields, task.FieldWhen) +// ResetLocalGroupForce resets all changes to the "local_group_force" field. +func (m *TaskMutation) ResetLocalGroupForce() { + m.local_group_force = nil + delete(m.clearedFields, task.FieldLocalGroupForce) } -// SetBrewUpdate sets the "brew_update" field. -func (m *TaskMutation) SetBrewUpdate(b bool) { - m.brew_update = &b +// SetLocalGroupMembers sets the "local_group_members" field. +func (m *TaskMutation) SetLocalGroupMembers(s string) { + m.local_group_members = &s } -// BrewUpdate returns the value of the "brew_update" field in the mutation. -func (m *TaskMutation) BrewUpdate() (r bool, exists bool) { - v := m.brew_update +// LocalGroupMembers returns the value of the "local_group_members" field in the mutation. +func (m *TaskMutation) LocalGroupMembers() (r string, exists bool) { + v := m.local_group_members if v == nil { return } return *v, true } -// OldBrewUpdate returns the old "brew_update" field's value of the Task entity. +// OldLocalGroupMembers returns the old "local_group_members" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldBrewUpdate(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalGroupMembers(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBrewUpdate is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupMembers is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBrewUpdate requires an ID field in the mutation") + return v, errors.New("OldLocalGroupMembers requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBrewUpdate: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupMembers: %w", err) } - return oldValue.BrewUpdate, nil + return oldValue.LocalGroupMembers, nil } -// ClearBrewUpdate clears the value of the "brew_update" field. -func (m *TaskMutation) ClearBrewUpdate() { - m.brew_update = nil - m.clearedFields[task.FieldBrewUpdate] = struct{}{} +// ClearLocalGroupMembers clears the value of the "local_group_members" field. +func (m *TaskMutation) ClearLocalGroupMembers() { + m.local_group_members = nil + m.clearedFields[task.FieldLocalGroupMembers] = struct{}{} } -// BrewUpdateCleared returns if the "brew_update" field was cleared in this mutation. -func (m *TaskMutation) BrewUpdateCleared() bool { - _, ok := m.clearedFields[task.FieldBrewUpdate] +// LocalGroupMembersCleared returns if the "local_group_members" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupMembersCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupMembers] return ok } -// ResetBrewUpdate resets all changes to the "brew_update" field. -func (m *TaskMutation) ResetBrewUpdate() { - m.brew_update = nil - delete(m.clearedFields, task.FieldBrewUpdate) +// ResetLocalGroupMembers resets all changes to the "local_group_members" field. +func (m *TaskMutation) ResetLocalGroupMembers() { + m.local_group_members = nil + delete(m.clearedFields, task.FieldLocalGroupMembers) } -// SetBrewUpgradeAll sets the "brew_upgrade_all" field. -func (m *TaskMutation) SetBrewUpgradeAll(b bool) { - m.brew_upgrade_all = &b +// SetLocalGroupMembersToInclude sets the "local_group_members_to_include" field. +func (m *TaskMutation) SetLocalGroupMembersToInclude(s string) { + m.local_group_members_to_include = &s } -// BrewUpgradeAll returns the value of the "brew_upgrade_all" field in the mutation. -func (m *TaskMutation) BrewUpgradeAll() (r bool, exists bool) { - v := m.brew_upgrade_all +// LocalGroupMembersToInclude returns the value of the "local_group_members_to_include" field in the mutation. +func (m *TaskMutation) LocalGroupMembersToInclude() (r string, exists bool) { + v := m.local_group_members_to_include if v == nil { return } return *v, true } -// OldBrewUpgradeAll returns the old "brew_upgrade_all" field's value of the Task entity. +// OldLocalGroupMembersToInclude returns the old "local_group_members_to_include" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldBrewUpgradeAll(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldLocalGroupMembersToInclude(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBrewUpgradeAll is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupMembersToInclude is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBrewUpgradeAll requires an ID field in the mutation") + return v, errors.New("OldLocalGroupMembersToInclude requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBrewUpgradeAll: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupMembersToInclude: %w", err) } - return oldValue.BrewUpgradeAll, nil + return oldValue.LocalGroupMembersToInclude, nil } -// ClearBrewUpgradeAll clears the value of the "brew_upgrade_all" field. -func (m *TaskMutation) ClearBrewUpgradeAll() { - m.brew_upgrade_all = nil - m.clearedFields[task.FieldBrewUpgradeAll] = struct{}{} +// ClearLocalGroupMembersToInclude clears the value of the "local_group_members_to_include" field. +func (m *TaskMutation) ClearLocalGroupMembersToInclude() { + m.local_group_members_to_include = nil + m.clearedFields[task.FieldLocalGroupMembersToInclude] = struct{}{} } -// BrewUpgradeAllCleared returns if the "brew_upgrade_all" field was cleared in this mutation. -func (m *TaskMutation) BrewUpgradeAllCleared() bool { - _, ok := m.clearedFields[task.FieldBrewUpgradeAll] +// LocalGroupMembersToIncludeCleared returns if the "local_group_members_to_include" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupMembersToIncludeCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupMembersToInclude] return ok } -// ResetBrewUpgradeAll resets all changes to the "brew_upgrade_all" field. -func (m *TaskMutation) ResetBrewUpgradeAll() { - m.brew_upgrade_all = nil - delete(m.clearedFields, task.FieldBrewUpgradeAll) +// ResetLocalGroupMembersToInclude resets all changes to the "local_group_members_to_include" field. +func (m *TaskMutation) ResetLocalGroupMembersToInclude() { + m.local_group_members_to_include = nil + delete(m.clearedFields, task.FieldLocalGroupMembersToInclude) } -// SetBrewUpgradeOptions sets the "brew_upgrade_options" field. -func (m *TaskMutation) SetBrewUpgradeOptions(s string) { - m.brew_upgrade_options = &s +// SetLocalGroupMembersToExclude sets the "local_group_members_to_exclude" field. +func (m *TaskMutation) SetLocalGroupMembersToExclude(s string) { + m.local_group_members_to_exclude = &s } -// BrewUpgradeOptions returns the value of the "brew_upgrade_options" field in the mutation. -func (m *TaskMutation) BrewUpgradeOptions() (r string, exists bool) { - v := m.brew_upgrade_options +// LocalGroupMembersToExclude returns the value of the "local_group_members_to_exclude" field in the mutation. +func (m *TaskMutation) LocalGroupMembersToExclude() (r string, exists bool) { + v := m.local_group_members_to_exclude if v == nil { return } return *v, true } -// OldBrewUpgradeOptions returns the old "brew_upgrade_options" field's value of the Task entity. +// OldLocalGroupMembersToExclude returns the old "local_group_members_to_exclude" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldBrewUpgradeOptions(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldLocalGroupMembersToExclude(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBrewUpgradeOptions is only allowed on UpdateOne operations") + return v, errors.New("OldLocalGroupMembersToExclude is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBrewUpgradeOptions requires an ID field in the mutation") + return v, errors.New("OldLocalGroupMembersToExclude requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBrewUpgradeOptions: %w", err) + return v, fmt.Errorf("querying old value for OldLocalGroupMembersToExclude: %w", err) } - return oldValue.BrewUpgradeOptions, nil + return oldValue.LocalGroupMembersToExclude, nil } -// ClearBrewUpgradeOptions clears the value of the "brew_upgrade_options" field. -func (m *TaskMutation) ClearBrewUpgradeOptions() { - m.brew_upgrade_options = nil - m.clearedFields[task.FieldBrewUpgradeOptions] = struct{}{} +// ClearLocalGroupMembersToExclude clears the value of the "local_group_members_to_exclude" field. +func (m *TaskMutation) ClearLocalGroupMembersToExclude() { + m.local_group_members_to_exclude = nil + m.clearedFields[task.FieldLocalGroupMembersToExclude] = struct{}{} } -// BrewUpgradeOptionsCleared returns if the "brew_upgrade_options" field was cleared in this mutation. -func (m *TaskMutation) BrewUpgradeOptionsCleared() bool { - _, ok := m.clearedFields[task.FieldBrewUpgradeOptions] +// LocalGroupMembersToExcludeCleared returns if the "local_group_members_to_exclude" field was cleared in this mutation. +func (m *TaskMutation) LocalGroupMembersToExcludeCleared() bool { + _, ok := m.clearedFields[task.FieldLocalGroupMembersToExclude] return ok } -// ResetBrewUpgradeOptions resets all changes to the "brew_upgrade_options" field. -func (m *TaskMutation) ResetBrewUpgradeOptions() { - m.brew_upgrade_options = nil - delete(m.clearedFields, task.FieldBrewUpgradeOptions) +// ResetLocalGroupMembersToExclude resets all changes to the "local_group_members_to_exclude" field. +func (m *TaskMutation) ResetLocalGroupMembersToExclude() { + m.local_group_members_to_exclude = nil + delete(m.clearedFields, task.FieldLocalGroupMembersToExclude) } -// SetBrewInstallOptions sets the "brew_install_options" field. -func (m *TaskMutation) SetBrewInstallOptions(s string) { - m.brew_install_options = &s +// SetMsiProductid sets the "msi_productid" field. +func (m *TaskMutation) SetMsiProductid(s string) { + m.msi_productid = &s } -// BrewInstallOptions returns the value of the "brew_install_options" field in the mutation. -func (m *TaskMutation) BrewInstallOptions() (r string, exists bool) { - v := m.brew_install_options +// MsiProductid returns the value of the "msi_productid" field in the mutation. +func (m *TaskMutation) MsiProductid() (r string, exists bool) { + v := m.msi_productid if v == nil { return } return *v, true } -// OldBrewInstallOptions returns the old "brew_install_options" field's value of the Task entity. +// OldMsiProductid returns the old "msi_productid" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldBrewInstallOptions(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldMsiProductid(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBrewInstallOptions is only allowed on UpdateOne operations") + return v, errors.New("OldMsiProductid is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBrewInstallOptions requires an ID field in the mutation") + return v, errors.New("OldMsiProductid requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBrewInstallOptions: %w", err) + return v, fmt.Errorf("querying old value for OldMsiProductid: %w", err) } - return oldValue.BrewInstallOptions, nil + return oldValue.MsiProductid, nil } -// ClearBrewInstallOptions clears the value of the "brew_install_options" field. -func (m *TaskMutation) ClearBrewInstallOptions() { - m.brew_install_options = nil - m.clearedFields[task.FieldBrewInstallOptions] = struct{}{} +// ClearMsiProductid clears the value of the "msi_productid" field. +func (m *TaskMutation) ClearMsiProductid() { + m.msi_productid = nil + m.clearedFields[task.FieldMsiProductid] = struct{}{} } -// BrewInstallOptionsCleared returns if the "brew_install_options" field was cleared in this mutation. -func (m *TaskMutation) BrewInstallOptionsCleared() bool { - _, ok := m.clearedFields[task.FieldBrewInstallOptions] +// MsiProductidCleared returns if the "msi_productid" field was cleared in this mutation. +func (m *TaskMutation) MsiProductidCleared() bool { + _, ok := m.clearedFields[task.FieldMsiProductid] return ok } -// ResetBrewInstallOptions resets all changes to the "brew_install_options" field. -func (m *TaskMutation) ResetBrewInstallOptions() { - m.brew_install_options = nil - delete(m.clearedFields, task.FieldBrewInstallOptions) +// ResetMsiProductid resets all changes to the "msi_productid" field. +func (m *TaskMutation) ResetMsiProductid() { + m.msi_productid = nil + delete(m.clearedFields, task.FieldMsiProductid) } -// SetBrewGreedy sets the "brew_greedy" field. -func (m *TaskMutation) SetBrewGreedy(b bool) { - m.brew_greedy = &b +// SetMsiPath sets the "msi_path" field. +func (m *TaskMutation) SetMsiPath(s string) { + m.msi_path = &s } -// BrewGreedy returns the value of the "brew_greedy" field in the mutation. -func (m *TaskMutation) BrewGreedy() (r bool, exists bool) { - v := m.brew_greedy +// MsiPath returns the value of the "msi_path" field in the mutation. +func (m *TaskMutation) MsiPath() (r string, exists bool) { + v := m.msi_path if v == nil { return } return *v, true } -// OldBrewGreedy returns the old "brew_greedy" field's value of the Task entity. +// OldMsiPath returns the old "msi_path" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldBrewGreedy(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldMsiPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBrewGreedy is only allowed on UpdateOne operations") + return v, errors.New("OldMsiPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBrewGreedy requires an ID field in the mutation") + return v, errors.New("OldMsiPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBrewGreedy: %w", err) + return v, fmt.Errorf("querying old value for OldMsiPath: %w", err) } - return oldValue.BrewGreedy, nil + return oldValue.MsiPath, nil } -// ClearBrewGreedy clears the value of the "brew_greedy" field. -func (m *TaskMutation) ClearBrewGreedy() { - m.brew_greedy = nil - m.clearedFields[task.FieldBrewGreedy] = struct{}{} +// ClearMsiPath clears the value of the "msi_path" field. +func (m *TaskMutation) ClearMsiPath() { + m.msi_path = nil + m.clearedFields[task.FieldMsiPath] = struct{}{} } -// BrewGreedyCleared returns if the "brew_greedy" field was cleared in this mutation. -func (m *TaskMutation) BrewGreedyCleared() bool { - _, ok := m.clearedFields[task.FieldBrewGreedy] +// MsiPathCleared returns if the "msi_path" field was cleared in this mutation. +func (m *TaskMutation) MsiPathCleared() bool { + _, ok := m.clearedFields[task.FieldMsiPath] return ok } -// ResetBrewGreedy resets all changes to the "brew_greedy" field. -func (m *TaskMutation) ResetBrewGreedy() { - m.brew_greedy = nil - delete(m.clearedFields, task.FieldBrewGreedy) +// ResetMsiPath resets all changes to the "msi_path" field. +func (m *TaskMutation) ResetMsiPath() { + m.msi_path = nil + delete(m.clearedFields, task.FieldMsiPath) } -// SetPackageVersion sets the "package_version" field. -func (m *TaskMutation) SetPackageVersion(s string) { - m.package_version = &s +// SetMsiArguments sets the "msi_arguments" field. +func (m *TaskMutation) SetMsiArguments(s string) { + m.msi_arguments = &s } -// PackageVersion returns the value of the "package_version" field in the mutation. -func (m *TaskMutation) PackageVersion() (r string, exists bool) { - v := m.package_version +// MsiArguments returns the value of the "msi_arguments" field in the mutation. +func (m *TaskMutation) MsiArguments() (r string, exists bool) { + v := m.msi_arguments if v == nil { return } return *v, true } -// OldPackageVersion returns the old "package_version" field's value of the Task entity. +// OldMsiArguments returns the old "msi_arguments" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldPackageVersion(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldMsiArguments(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPackageVersion is only allowed on UpdateOne operations") + return v, errors.New("OldMsiArguments is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPackageVersion requires an ID field in the mutation") + return v, errors.New("OldMsiArguments requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPackageVersion: %w", err) + return v, fmt.Errorf("querying old value for OldMsiArguments: %w", err) } - return oldValue.PackageVersion, nil + return oldValue.MsiArguments, nil } -// ClearPackageVersion clears the value of the "package_version" field. -func (m *TaskMutation) ClearPackageVersion() { - m.package_version = nil - m.clearedFields[task.FieldPackageVersion] = struct{}{} +// ClearMsiArguments clears the value of the "msi_arguments" field. +func (m *TaskMutation) ClearMsiArguments() { + m.msi_arguments = nil + m.clearedFields[task.FieldMsiArguments] = struct{}{} } -// PackageVersionCleared returns if the "package_version" field was cleared in this mutation. -func (m *TaskMutation) PackageVersionCleared() bool { - _, ok := m.clearedFields[task.FieldPackageVersion] +// MsiArgumentsCleared returns if the "msi_arguments" field was cleared in this mutation. +func (m *TaskMutation) MsiArgumentsCleared() bool { + _, ok := m.clearedFields[task.FieldMsiArguments] return ok } -// ResetPackageVersion resets all changes to the "package_version" field. -func (m *TaskMutation) ResetPackageVersion() { - m.package_version = nil - delete(m.clearedFields, task.FieldPackageVersion) +// ResetMsiArguments resets all changes to the "msi_arguments" field. +func (m *TaskMutation) ResetMsiArguments() { + m.msi_arguments = nil + delete(m.clearedFields, task.FieldMsiArguments) } -// SetAptAllowDowngrade sets the "apt_allow_downgrade" field. -func (m *TaskMutation) SetAptAllowDowngrade(b bool) { - m.apt_allow_downgrade = &b +// SetMsiFileHash sets the "msi_file_hash" field. +func (m *TaskMutation) SetMsiFileHash(s string) { + m.msi_file_hash = &s } -// AptAllowDowngrade returns the value of the "apt_allow_downgrade" field in the mutation. -func (m *TaskMutation) AptAllowDowngrade() (r bool, exists bool) { - v := m.apt_allow_downgrade +// MsiFileHash returns the value of the "msi_file_hash" field in the mutation. +func (m *TaskMutation) MsiFileHash() (r string, exists bool) { + v := m.msi_file_hash if v == nil { return } return *v, true } -// OldAptAllowDowngrade returns the old "apt_allow_downgrade" field's value of the Task entity. +// OldMsiFileHash returns the old "msi_file_hash" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptAllowDowngrade(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldMsiFileHash(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptAllowDowngrade is only allowed on UpdateOne operations") + return v, errors.New("OldMsiFileHash is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptAllowDowngrade requires an ID field in the mutation") + return v, errors.New("OldMsiFileHash requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptAllowDowngrade: %w", err) + return v, fmt.Errorf("querying old value for OldMsiFileHash: %w", err) } - return oldValue.AptAllowDowngrade, nil + return oldValue.MsiFileHash, nil } -// ClearAptAllowDowngrade clears the value of the "apt_allow_downgrade" field. -func (m *TaskMutation) ClearAptAllowDowngrade() { - m.apt_allow_downgrade = nil - m.clearedFields[task.FieldAptAllowDowngrade] = struct{}{} +// ClearMsiFileHash clears the value of the "msi_file_hash" field. +func (m *TaskMutation) ClearMsiFileHash() { + m.msi_file_hash = nil + m.clearedFields[task.FieldMsiFileHash] = struct{}{} } -// AptAllowDowngradeCleared returns if the "apt_allow_downgrade" field was cleared in this mutation. -func (m *TaskMutation) AptAllowDowngradeCleared() bool { - _, ok := m.clearedFields[task.FieldAptAllowDowngrade] +// MsiFileHashCleared returns if the "msi_file_hash" field was cleared in this mutation. +func (m *TaskMutation) MsiFileHashCleared() bool { + _, ok := m.clearedFields[task.FieldMsiFileHash] return ok } -// ResetAptAllowDowngrade resets all changes to the "apt_allow_downgrade" field. -func (m *TaskMutation) ResetAptAllowDowngrade() { - m.apt_allow_downgrade = nil - delete(m.clearedFields, task.FieldAptAllowDowngrade) +// ResetMsiFileHash resets all changes to the "msi_file_hash" field. +func (m *TaskMutation) ResetMsiFileHash() { + m.msi_file_hash = nil + delete(m.clearedFields, task.FieldMsiFileHash) } -// SetAptDeb sets the "apt_deb" field. -func (m *TaskMutation) SetAptDeb(s string) { - m.apt_deb = &s +// SetMsiFileHashAlg sets the "msi_file_hash_alg" field. +func (m *TaskMutation) SetMsiFileHashAlg(tfha task.MsiFileHashAlg) { + m.msi_file_hash_alg = &tfha } -// AptDeb returns the value of the "apt_deb" field in the mutation. -func (m *TaskMutation) AptDeb() (r string, exists bool) { - v := m.apt_deb +// MsiFileHashAlg returns the value of the "msi_file_hash_alg" field in the mutation. +func (m *TaskMutation) MsiFileHashAlg() (r task.MsiFileHashAlg, exists bool) { + v := m.msi_file_hash_alg if v == nil { return } return *v, true } -// OldAptDeb returns the old "apt_deb" field's value of the Task entity. +// OldMsiFileHashAlg returns the old "msi_file_hash_alg" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptDeb(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldMsiFileHashAlg(ctx context.Context) (v task.MsiFileHashAlg, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptDeb is only allowed on UpdateOne operations") + return v, errors.New("OldMsiFileHashAlg is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptDeb requires an ID field in the mutation") + return v, errors.New("OldMsiFileHashAlg requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptDeb: %w", err) + return v, fmt.Errorf("querying old value for OldMsiFileHashAlg: %w", err) } - return oldValue.AptDeb, nil + return oldValue.MsiFileHashAlg, nil } -// ClearAptDeb clears the value of the "apt_deb" field. -func (m *TaskMutation) ClearAptDeb() { - m.apt_deb = nil - m.clearedFields[task.FieldAptDeb] = struct{}{} +// ClearMsiFileHashAlg clears the value of the "msi_file_hash_alg" field. +func (m *TaskMutation) ClearMsiFileHashAlg() { + m.msi_file_hash_alg = nil + m.clearedFields[task.FieldMsiFileHashAlg] = struct{}{} } -// AptDebCleared returns if the "apt_deb" field was cleared in this mutation. -func (m *TaskMutation) AptDebCleared() bool { - _, ok := m.clearedFields[task.FieldAptDeb] +// MsiFileHashAlgCleared returns if the "msi_file_hash_alg" field was cleared in this mutation. +func (m *TaskMutation) MsiFileHashAlgCleared() bool { + _, ok := m.clearedFields[task.FieldMsiFileHashAlg] return ok } -// ResetAptDeb resets all changes to the "apt_deb" field. -func (m *TaskMutation) ResetAptDeb() { - m.apt_deb = nil - delete(m.clearedFields, task.FieldAptDeb) +// ResetMsiFileHashAlg resets all changes to the "msi_file_hash_alg" field. +func (m *TaskMutation) ResetMsiFileHashAlg() { + m.msi_file_hash_alg = nil + delete(m.clearedFields, task.FieldMsiFileHashAlg) } -// SetAptDpkgOptions sets the "apt_dpkg_options" field. -func (m *TaskMutation) SetAptDpkgOptions(s string) { - m.apt_dpkg_options = &s +// SetMsiLogPath sets the "msi_log_path" field. +func (m *TaskMutation) SetMsiLogPath(s string) { + m.msi_log_path = &s } -// AptDpkgOptions returns the value of the "apt_dpkg_options" field in the mutation. -func (m *TaskMutation) AptDpkgOptions() (r string, exists bool) { - v := m.apt_dpkg_options +// MsiLogPath returns the value of the "msi_log_path" field in the mutation. +func (m *TaskMutation) MsiLogPath() (r string, exists bool) { + v := m.msi_log_path if v == nil { return } return *v, true } -// OldAptDpkgOptions returns the old "apt_dpkg_options" field's value of the Task entity. +// OldMsiLogPath returns the old "msi_log_path" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptDpkgOptions(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldMsiLogPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptDpkgOptions is only allowed on UpdateOne operations") + return v, errors.New("OldMsiLogPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptDpkgOptions requires an ID field in the mutation") + return v, errors.New("OldMsiLogPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptDpkgOptions: %w", err) + return v, fmt.Errorf("querying old value for OldMsiLogPath: %w", err) } - return oldValue.AptDpkgOptions, nil + return oldValue.MsiLogPath, nil } -// ClearAptDpkgOptions clears the value of the "apt_dpkg_options" field. -func (m *TaskMutation) ClearAptDpkgOptions() { - m.apt_dpkg_options = nil - m.clearedFields[task.FieldAptDpkgOptions] = struct{}{} +// ClearMsiLogPath clears the value of the "msi_log_path" field. +func (m *TaskMutation) ClearMsiLogPath() { + m.msi_log_path = nil + m.clearedFields[task.FieldMsiLogPath] = struct{}{} } -// AptDpkgOptionsCleared returns if the "apt_dpkg_options" field was cleared in this mutation. -func (m *TaskMutation) AptDpkgOptionsCleared() bool { - _, ok := m.clearedFields[task.FieldAptDpkgOptions] +// MsiLogPathCleared returns if the "msi_log_path" field was cleared in this mutation. +func (m *TaskMutation) MsiLogPathCleared() bool { + _, ok := m.clearedFields[task.FieldMsiLogPath] return ok } -// ResetAptDpkgOptions resets all changes to the "apt_dpkg_options" field. -func (m *TaskMutation) ResetAptDpkgOptions() { - m.apt_dpkg_options = nil - delete(m.clearedFields, task.FieldAptDpkgOptions) +// ResetMsiLogPath resets all changes to the "msi_log_path" field. +func (m *TaskMutation) ResetMsiLogPath() { + m.msi_log_path = nil + delete(m.clearedFields, task.FieldMsiLogPath) } -// SetAptFailOnAutoremove sets the "apt_fail_on_autoremove" field. -func (m *TaskMutation) SetAptFailOnAutoremove(b bool) { - m.apt_fail_on_autoremove = &b +// SetScript sets the "script" field. +func (m *TaskMutation) SetScript(s string) { + m.script = &s } -// AptFailOnAutoremove returns the value of the "apt_fail_on_autoremove" field in the mutation. -func (m *TaskMutation) AptFailOnAutoremove() (r bool, exists bool) { - v := m.apt_fail_on_autoremove +// Script returns the value of the "script" field in the mutation. +func (m *TaskMutation) Script() (r string, exists bool) { + v := m.script if v == nil { return } return *v, true } -// OldAptFailOnAutoremove returns the old "apt_fail_on_autoremove" field's value of the Task entity. +// OldScript returns the old "script" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptFailOnAutoremove(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldScript(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptFailOnAutoremove is only allowed on UpdateOne operations") + return v, errors.New("OldScript is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptFailOnAutoremove requires an ID field in the mutation") + return v, errors.New("OldScript requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptFailOnAutoremove: %w", err) + return v, fmt.Errorf("querying old value for OldScript: %w", err) } - return oldValue.AptFailOnAutoremove, nil + return oldValue.Script, nil } -// ClearAptFailOnAutoremove clears the value of the "apt_fail_on_autoremove" field. -func (m *TaskMutation) ClearAptFailOnAutoremove() { - m.apt_fail_on_autoremove = nil - m.clearedFields[task.FieldAptFailOnAutoremove] = struct{}{} +// ClearScript clears the value of the "script" field. +func (m *TaskMutation) ClearScript() { + m.script = nil + m.clearedFields[task.FieldScript] = struct{}{} } -// AptFailOnAutoremoveCleared returns if the "apt_fail_on_autoremove" field was cleared in this mutation. -func (m *TaskMutation) AptFailOnAutoremoveCleared() bool { - _, ok := m.clearedFields[task.FieldAptFailOnAutoremove] +// ScriptCleared returns if the "script" field was cleared in this mutation. +func (m *TaskMutation) ScriptCleared() bool { + _, ok := m.clearedFields[task.FieldScript] return ok } -// ResetAptFailOnAutoremove resets all changes to the "apt_fail_on_autoremove" field. -func (m *TaskMutation) ResetAptFailOnAutoremove() { - m.apt_fail_on_autoremove = nil - delete(m.clearedFields, task.FieldAptFailOnAutoremove) +// ResetScript resets all changes to the "script" field. +func (m *TaskMutation) ResetScript() { + m.script = nil + delete(m.clearedFields, task.FieldScript) } -// SetAptForce sets the "apt_force" field. -func (m *TaskMutation) SetAptForce(b bool) { - m.apt_force = &b +// SetScriptExecutable sets the "script_executable" field. +func (m *TaskMutation) SetScriptExecutable(s string) { + m.script_executable = &s } -// AptForce returns the value of the "apt_force" field in the mutation. -func (m *TaskMutation) AptForce() (r bool, exists bool) { - v := m.apt_force +// ScriptExecutable returns the value of the "script_executable" field in the mutation. +func (m *TaskMutation) ScriptExecutable() (r string, exists bool) { + v := m.script_executable if v == nil { return } return *v, true } -// OldAptForce returns the old "apt_force" field's value of the Task entity. +// OldScriptExecutable returns the old "script_executable" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptForce(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldScriptExecutable(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptForce is only allowed on UpdateOne operations") + return v, errors.New("OldScriptExecutable is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptForce requires an ID field in the mutation") + return v, errors.New("OldScriptExecutable requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptForce: %w", err) + return v, fmt.Errorf("querying old value for OldScriptExecutable: %w", err) } - return oldValue.AptForce, nil + return oldValue.ScriptExecutable, nil } -// ClearAptForce clears the value of the "apt_force" field. -func (m *TaskMutation) ClearAptForce() { - m.apt_force = nil - m.clearedFields[task.FieldAptForce] = struct{}{} +// ClearScriptExecutable clears the value of the "script_executable" field. +func (m *TaskMutation) ClearScriptExecutable() { + m.script_executable = nil + m.clearedFields[task.FieldScriptExecutable] = struct{}{} } -// AptForceCleared returns if the "apt_force" field was cleared in this mutation. -func (m *TaskMutation) AptForceCleared() bool { - _, ok := m.clearedFields[task.FieldAptForce] +// ScriptExecutableCleared returns if the "script_executable" field was cleared in this mutation. +func (m *TaskMutation) ScriptExecutableCleared() bool { + _, ok := m.clearedFields[task.FieldScriptExecutable] return ok } -// ResetAptForce resets all changes to the "apt_force" field. -func (m *TaskMutation) ResetAptForce() { - m.apt_force = nil - delete(m.clearedFields, task.FieldAptForce) +// ResetScriptExecutable resets all changes to the "script_executable" field. +func (m *TaskMutation) ResetScriptExecutable() { + m.script_executable = nil + delete(m.clearedFields, task.FieldScriptExecutable) } -// SetAptInstallRecommends sets the "apt_install_recommends" field. -func (m *TaskMutation) SetAptInstallRecommends(b bool) { - m.apt_install_recommends = &b +// SetScriptCreates sets the "script_creates" field. +func (m *TaskMutation) SetScriptCreates(s string) { + m.script_creates = &s } -// AptInstallRecommends returns the value of the "apt_install_recommends" field in the mutation. -func (m *TaskMutation) AptInstallRecommends() (r bool, exists bool) { - v := m.apt_install_recommends +// ScriptCreates returns the value of the "script_creates" field in the mutation. +func (m *TaskMutation) ScriptCreates() (r string, exists bool) { + v := m.script_creates if v == nil { return } return *v, true } -// OldAptInstallRecommends returns the old "apt_install_recommends" field's value of the Task entity. +// OldScriptCreates returns the old "script_creates" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptInstallRecommends(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldScriptCreates(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptInstallRecommends is only allowed on UpdateOne operations") + return v, errors.New("OldScriptCreates is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptInstallRecommends requires an ID field in the mutation") + return v, errors.New("OldScriptCreates requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptInstallRecommends: %w", err) + return v, fmt.Errorf("querying old value for OldScriptCreates: %w", err) } - return oldValue.AptInstallRecommends, nil + return oldValue.ScriptCreates, nil } -// ClearAptInstallRecommends clears the value of the "apt_install_recommends" field. -func (m *TaskMutation) ClearAptInstallRecommends() { - m.apt_install_recommends = nil - m.clearedFields[task.FieldAptInstallRecommends] = struct{}{} +// ClearScriptCreates clears the value of the "script_creates" field. +func (m *TaskMutation) ClearScriptCreates() { + m.script_creates = nil + m.clearedFields[task.FieldScriptCreates] = struct{}{} } -// AptInstallRecommendsCleared returns if the "apt_install_recommends" field was cleared in this mutation. -func (m *TaskMutation) AptInstallRecommendsCleared() bool { - _, ok := m.clearedFields[task.FieldAptInstallRecommends] +// ScriptCreatesCleared returns if the "script_creates" field was cleared in this mutation. +func (m *TaskMutation) ScriptCreatesCleared() bool { + _, ok := m.clearedFields[task.FieldScriptCreates] return ok } -// ResetAptInstallRecommends resets all changes to the "apt_install_recommends" field. -func (m *TaskMutation) ResetAptInstallRecommends() { - m.apt_install_recommends = nil - delete(m.clearedFields, task.FieldAptInstallRecommends) +// ResetScriptCreates resets all changes to the "script_creates" field. +func (m *TaskMutation) ResetScriptCreates() { + m.script_creates = nil + delete(m.clearedFields, task.FieldScriptCreates) } -// SetAptName sets the "apt_name" field. -func (m *TaskMutation) SetAptName(s string) { - m.apt_name = &s +// SetScriptRun sets the "script_run" field. +func (m *TaskMutation) SetScriptRun(tr task.ScriptRun) { + m.script_run = &tr } -// AptName returns the value of the "apt_name" field in the mutation. -func (m *TaskMutation) AptName() (r string, exists bool) { - v := m.apt_name +// ScriptRun returns the value of the "script_run" field in the mutation. +func (m *TaskMutation) ScriptRun() (r task.ScriptRun, exists bool) { + v := m.script_run if v == nil { return } return *v, true } -// OldAptName returns the old "apt_name" field's value of the Task entity. +// OldScriptRun returns the old "script_run" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptName(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldScriptRun(ctx context.Context) (v task.ScriptRun, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptName is only allowed on UpdateOne operations") + return v, errors.New("OldScriptRun is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptName requires an ID field in the mutation") + return v, errors.New("OldScriptRun requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptName: %w", err) + return v, fmt.Errorf("querying old value for OldScriptRun: %w", err) } - return oldValue.AptName, nil + return oldValue.ScriptRun, nil } -// ClearAptName clears the value of the "apt_name" field. -func (m *TaskMutation) ClearAptName() { - m.apt_name = nil - m.clearedFields[task.FieldAptName] = struct{}{} +// ClearScriptRun clears the value of the "script_run" field. +func (m *TaskMutation) ClearScriptRun() { + m.script_run = nil + m.clearedFields[task.FieldScriptRun] = struct{}{} } -// AptNameCleared returns if the "apt_name" field was cleared in this mutation. -func (m *TaskMutation) AptNameCleared() bool { - _, ok := m.clearedFields[task.FieldAptName] +// ScriptRunCleared returns if the "script_run" field was cleared in this mutation. +func (m *TaskMutation) ScriptRunCleared() bool { + _, ok := m.clearedFields[task.FieldScriptRun] return ok } -// ResetAptName resets all changes to the "apt_name" field. -func (m *TaskMutation) ResetAptName() { - m.apt_name = nil - delete(m.clearedFields, task.FieldAptName) +// ResetScriptRun resets all changes to the "script_run" field. +func (m *TaskMutation) ResetScriptRun() { + m.script_run = nil + delete(m.clearedFields, task.FieldScriptRun) } -// SetAptOnlyUpgrade sets the "apt_only_upgrade" field. -func (m *TaskMutation) SetAptOnlyUpgrade(b bool) { - m.apt_only_upgrade = &b +// SetAgentType sets the "agent_type" field. +func (m *TaskMutation) SetAgentType(tt task.AgentType) { + m.agent_type = &tt } -// AptOnlyUpgrade returns the value of the "apt_only_upgrade" field in the mutation. -func (m *TaskMutation) AptOnlyUpgrade() (r bool, exists bool) { - v := m.apt_only_upgrade +// AgentType returns the value of the "agent_type" field in the mutation. +func (m *TaskMutation) AgentType() (r task.AgentType, exists bool) { + v := m.agent_type if v == nil { return } return *v, true } -// OldAptOnlyUpgrade returns the old "apt_only_upgrade" field's value of the Task entity. +// OldAgentType returns the old "agent_type" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptOnlyUpgrade(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldAgentType(ctx context.Context) (v task.AgentType, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptOnlyUpgrade is only allowed on UpdateOne operations") + return v, errors.New("OldAgentType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptOnlyUpgrade requires an ID field in the mutation") + return v, errors.New("OldAgentType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptOnlyUpgrade: %w", err) + return v, fmt.Errorf("querying old value for OldAgentType: %w", err) } - return oldValue.AptOnlyUpgrade, nil + return oldValue.AgentType, nil } -// ClearAptOnlyUpgrade clears the value of the "apt_only_upgrade" field. -func (m *TaskMutation) ClearAptOnlyUpgrade() { - m.apt_only_upgrade = nil - m.clearedFields[task.FieldAptOnlyUpgrade] = struct{}{} +// ClearAgentType clears the value of the "agent_type" field. +func (m *TaskMutation) ClearAgentType() { + m.agent_type = nil + m.clearedFields[task.FieldAgentType] = struct{}{} } -// AptOnlyUpgradeCleared returns if the "apt_only_upgrade" field was cleared in this mutation. -func (m *TaskMutation) AptOnlyUpgradeCleared() bool { - _, ok := m.clearedFields[task.FieldAptOnlyUpgrade] +// AgentTypeCleared returns if the "agent_type" field was cleared in this mutation. +func (m *TaskMutation) AgentTypeCleared() bool { + _, ok := m.clearedFields[task.FieldAgentType] return ok } -// ResetAptOnlyUpgrade resets all changes to the "apt_only_upgrade" field. -func (m *TaskMutation) ResetAptOnlyUpgrade() { - m.apt_only_upgrade = nil - delete(m.clearedFields, task.FieldAptOnlyUpgrade) +// ResetAgentType resets all changes to the "agent_type" field. +func (m *TaskMutation) ResetAgentType() { + m.agent_type = nil + delete(m.clearedFields, task.FieldAgentType) } -// SetAptPurge sets the "apt_purge" field. -func (m *TaskMutation) SetAptPurge(b bool) { - m.apt_purge = &b +// SetWhen sets the "when" field. +func (m *TaskMutation) SetWhen(t time.Time) { + m.when = &t } -// AptPurge returns the value of the "apt_purge" field in the mutation. -func (m *TaskMutation) AptPurge() (r bool, exists bool) { - v := m.apt_purge +// When returns the value of the "when" field in the mutation. +func (m *TaskMutation) When() (r time.Time, exists bool) { + v := m.when if v == nil { return } return *v, true } -// OldAptPurge returns the old "apt_purge" field's value of the Task entity. +// OldWhen returns the old "when" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptPurge(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldWhen(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptPurge is only allowed on UpdateOne operations") + return v, errors.New("OldWhen is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptPurge requires an ID field in the mutation") + return v, errors.New("OldWhen requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptPurge: %w", err) + return v, fmt.Errorf("querying old value for OldWhen: %w", err) } - return oldValue.AptPurge, nil + return oldValue.When, nil } -// ClearAptPurge clears the value of the "apt_purge" field. -func (m *TaskMutation) ClearAptPurge() { - m.apt_purge = nil - m.clearedFields[task.FieldAptPurge] = struct{}{} +// ClearWhen clears the value of the "when" field. +func (m *TaskMutation) ClearWhen() { + m.when = nil + m.clearedFields[task.FieldWhen] = struct{}{} } -// AptPurgeCleared returns if the "apt_purge" field was cleared in this mutation. -func (m *TaskMutation) AptPurgeCleared() bool { - _, ok := m.clearedFields[task.FieldAptPurge] +// WhenCleared returns if the "when" field was cleared in this mutation. +func (m *TaskMutation) WhenCleared() bool { + _, ok := m.clearedFields[task.FieldWhen] return ok } -// ResetAptPurge resets all changes to the "apt_purge" field. -func (m *TaskMutation) ResetAptPurge() { - m.apt_purge = nil - delete(m.clearedFields, task.FieldAptPurge) +// ResetWhen resets all changes to the "when" field. +func (m *TaskMutation) ResetWhen() { + m.when = nil + delete(m.clearedFields, task.FieldWhen) } -// SetAptUpdateCache sets the "apt_update_cache" field. -func (m *TaskMutation) SetAptUpdateCache(b bool) { - m.apt_update_cache = &b +// SetBrewUpdate sets the "brew_update" field. +func (m *TaskMutation) SetBrewUpdate(b bool) { + m.brew_update = &b } -// AptUpdateCache returns the value of the "apt_update_cache" field in the mutation. -func (m *TaskMutation) AptUpdateCache() (r bool, exists bool) { - v := m.apt_update_cache +// BrewUpdate returns the value of the "brew_update" field in the mutation. +func (m *TaskMutation) BrewUpdate() (r bool, exists bool) { + v := m.brew_update if v == nil { return } return *v, true } -// OldAptUpdateCache returns the old "apt_update_cache" field's value of the Task entity. +// OldBrewUpdate returns the old "brew_update" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptUpdateCache(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldBrewUpdate(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptUpdateCache is only allowed on UpdateOne operations") + return v, errors.New("OldBrewUpdate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptUpdateCache requires an ID field in the mutation") + return v, errors.New("OldBrewUpdate requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptUpdateCache: %w", err) + return v, fmt.Errorf("querying old value for OldBrewUpdate: %w", err) } - return oldValue.AptUpdateCache, nil + return oldValue.BrewUpdate, nil } -// ClearAptUpdateCache clears the value of the "apt_update_cache" field. -func (m *TaskMutation) ClearAptUpdateCache() { - m.apt_update_cache = nil - m.clearedFields[task.FieldAptUpdateCache] = struct{}{} +// ClearBrewUpdate clears the value of the "brew_update" field. +func (m *TaskMutation) ClearBrewUpdate() { + m.brew_update = nil + m.clearedFields[task.FieldBrewUpdate] = struct{}{} } -// AptUpdateCacheCleared returns if the "apt_update_cache" field was cleared in this mutation. -func (m *TaskMutation) AptUpdateCacheCleared() bool { - _, ok := m.clearedFields[task.FieldAptUpdateCache] +// BrewUpdateCleared returns if the "brew_update" field was cleared in this mutation. +func (m *TaskMutation) BrewUpdateCleared() bool { + _, ok := m.clearedFields[task.FieldBrewUpdate] return ok } -// ResetAptUpdateCache resets all changes to the "apt_update_cache" field. -func (m *TaskMutation) ResetAptUpdateCache() { - m.apt_update_cache = nil - delete(m.clearedFields, task.FieldAptUpdateCache) +// ResetBrewUpdate resets all changes to the "brew_update" field. +func (m *TaskMutation) ResetBrewUpdate() { + m.brew_update = nil + delete(m.clearedFields, task.FieldBrewUpdate) } -// SetAptUpgradeType sets the "apt_upgrade_type" field. -func (m *TaskMutation) SetAptUpgradeType(tut task.AptUpgradeType) { - m.apt_upgrade_type = &tut +// SetBrewUpgradeAll sets the "brew_upgrade_all" field. +func (m *TaskMutation) SetBrewUpgradeAll(b bool) { + m.brew_upgrade_all = &b } -// AptUpgradeType returns the value of the "apt_upgrade_type" field in the mutation. -func (m *TaskMutation) AptUpgradeType() (r task.AptUpgradeType, exists bool) { - v := m.apt_upgrade_type +// BrewUpgradeAll returns the value of the "brew_upgrade_all" field in the mutation. +func (m *TaskMutation) BrewUpgradeAll() (r bool, exists bool) { + v := m.brew_upgrade_all if v == nil { return } return *v, true } -// OldAptUpgradeType returns the old "apt_upgrade_type" field's value of the Task entity. +// OldBrewUpgradeAll returns the old "brew_upgrade_all" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldAptUpgradeType(ctx context.Context) (v task.AptUpgradeType, err error) { +func (m *TaskMutation) OldBrewUpgradeAll(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAptUpgradeType is only allowed on UpdateOne operations") + return v, errors.New("OldBrewUpgradeAll is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAptUpgradeType requires an ID field in the mutation") + return v, errors.New("OldBrewUpgradeAll requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAptUpgradeType: %w", err) + return v, fmt.Errorf("querying old value for OldBrewUpgradeAll: %w", err) } - return oldValue.AptUpgradeType, nil + return oldValue.BrewUpgradeAll, nil } -// ClearAptUpgradeType clears the value of the "apt_upgrade_type" field. -func (m *TaskMutation) ClearAptUpgradeType() { - m.apt_upgrade_type = nil - m.clearedFields[task.FieldAptUpgradeType] = struct{}{} +// ClearBrewUpgradeAll clears the value of the "brew_upgrade_all" field. +func (m *TaskMutation) ClearBrewUpgradeAll() { + m.brew_upgrade_all = nil + m.clearedFields[task.FieldBrewUpgradeAll] = struct{}{} } -// AptUpgradeTypeCleared returns if the "apt_upgrade_type" field was cleared in this mutation. -func (m *TaskMutation) AptUpgradeTypeCleared() bool { - _, ok := m.clearedFields[task.FieldAptUpgradeType] +// BrewUpgradeAllCleared returns if the "brew_upgrade_all" field was cleared in this mutation. +func (m *TaskMutation) BrewUpgradeAllCleared() bool { + _, ok := m.clearedFields[task.FieldBrewUpgradeAll] return ok } -// ResetAptUpgradeType resets all changes to the "apt_upgrade_type" field. -func (m *TaskMutation) ResetAptUpgradeType() { - m.apt_upgrade_type = nil - delete(m.clearedFields, task.FieldAptUpgradeType) +// ResetBrewUpgradeAll resets all changes to the "brew_upgrade_all" field. +func (m *TaskMutation) ResetBrewUpgradeAll() { + m.brew_upgrade_all = nil + delete(m.clearedFields, task.FieldBrewUpgradeAll) } -// SetVersion sets the "version" field. -func (m *TaskMutation) SetVersion(i int) { - m.version = &i - m.addversion = nil +// SetBrewUpgradeOptions sets the "brew_upgrade_options" field. +func (m *TaskMutation) SetBrewUpgradeOptions(s string) { + m.brew_upgrade_options = &s } -// Version returns the value of the "version" field in the mutation. -func (m *TaskMutation) Version() (r int, exists bool) { - v := m.version +// BrewUpgradeOptions returns the value of the "brew_upgrade_options" field in the mutation. +func (m *TaskMutation) BrewUpgradeOptions() (r string, exists bool) { + v := m.brew_upgrade_options if v == nil { return } return *v, true } -// OldVersion returns the old "version" field's value of the Task entity. +// OldBrewUpgradeOptions returns the old "brew_upgrade_options" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldVersion(ctx context.Context) (v int, err error) { +func (m *TaskMutation) OldBrewUpgradeOptions(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVersion is only allowed on UpdateOne operations") + return v, errors.New("OldBrewUpgradeOptions is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVersion requires an ID field in the mutation") + return v, errors.New("OldBrewUpgradeOptions requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVersion: %w", err) - } - return oldValue.Version, nil -} - -// AddVersion adds i to the "version" field. -func (m *TaskMutation) AddVersion(i int) { - if m.addversion != nil { - *m.addversion += i - } else { - m.addversion = &i - } -} - -// AddedVersion returns the value that was added to the "version" field in this mutation. -func (m *TaskMutation) AddedVersion() (r int, exists bool) { - v := m.addversion - if v == nil { - return + return v, fmt.Errorf("querying old value for OldBrewUpgradeOptions: %w", err) } - return *v, true + return oldValue.BrewUpgradeOptions, nil } -// ClearVersion clears the value of the "version" field. -func (m *TaskMutation) ClearVersion() { - m.version = nil - m.addversion = nil - m.clearedFields[task.FieldVersion] = struct{}{} +// ClearBrewUpgradeOptions clears the value of the "brew_upgrade_options" field. +func (m *TaskMutation) ClearBrewUpgradeOptions() { + m.brew_upgrade_options = nil + m.clearedFields[task.FieldBrewUpgradeOptions] = struct{}{} } -// VersionCleared returns if the "version" field was cleared in this mutation. -func (m *TaskMutation) VersionCleared() bool { - _, ok := m.clearedFields[task.FieldVersion] +// BrewUpgradeOptionsCleared returns if the "brew_upgrade_options" field was cleared in this mutation. +func (m *TaskMutation) BrewUpgradeOptionsCleared() bool { + _, ok := m.clearedFields[task.FieldBrewUpgradeOptions] return ok } -// ResetVersion resets all changes to the "version" field. -func (m *TaskMutation) ResetVersion() { - m.version = nil - m.addversion = nil - delete(m.clearedFields, task.FieldVersion) +// ResetBrewUpgradeOptions resets all changes to the "brew_upgrade_options" field. +func (m *TaskMutation) ResetBrewUpgradeOptions() { + m.brew_upgrade_options = nil + delete(m.clearedFields, task.FieldBrewUpgradeOptions) } -// SetTenant sets the "tenant" field. -func (m *TaskMutation) SetTenant(i int) { - m.tenant = &i - m.addtenant = nil +// SetBrewInstallOptions sets the "brew_install_options" field. +func (m *TaskMutation) SetBrewInstallOptions(s string) { + m.brew_install_options = &s } -// Tenant returns the value of the "tenant" field in the mutation. -func (m *TaskMutation) Tenant() (r int, exists bool) { - v := m.tenant +// BrewInstallOptions returns the value of the "brew_install_options" field in the mutation. +func (m *TaskMutation) BrewInstallOptions() (r string, exists bool) { + v := m.brew_install_options if v == nil { return } return *v, true } -// OldTenant returns the old "tenant" field's value of the Task entity. +// OldBrewInstallOptions returns the old "brew_install_options" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldTenant(ctx context.Context) (v int, err error) { +func (m *TaskMutation) OldBrewInstallOptions(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTenant is only allowed on UpdateOne operations") + return v, errors.New("OldBrewInstallOptions is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTenant requires an ID field in the mutation") + return v, errors.New("OldBrewInstallOptions requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTenant: %w", err) - } - return oldValue.Tenant, nil -} - -// AddTenant adds i to the "tenant" field. -func (m *TaskMutation) AddTenant(i int) { - if m.addtenant != nil { - *m.addtenant += i - } else { - m.addtenant = &i - } -} - -// AddedTenant returns the value that was added to the "tenant" field in this mutation. -func (m *TaskMutation) AddedTenant() (r int, exists bool) { - v := m.addtenant - if v == nil { - return + return v, fmt.Errorf("querying old value for OldBrewInstallOptions: %w", err) } - return *v, true + return oldValue.BrewInstallOptions, nil } -// ClearTenant clears the value of the "tenant" field. -func (m *TaskMutation) ClearTenant() { - m.tenant = nil - m.addtenant = nil - m.clearedFields[task.FieldTenant] = struct{}{} +// ClearBrewInstallOptions clears the value of the "brew_install_options" field. +func (m *TaskMutation) ClearBrewInstallOptions() { + m.brew_install_options = nil + m.clearedFields[task.FieldBrewInstallOptions] = struct{}{} } -// TenantCleared returns if the "tenant" field was cleared in this mutation. -func (m *TaskMutation) TenantCleared() bool { - _, ok := m.clearedFields[task.FieldTenant] +// BrewInstallOptionsCleared returns if the "brew_install_options" field was cleared in this mutation. +func (m *TaskMutation) BrewInstallOptionsCleared() bool { + _, ok := m.clearedFields[task.FieldBrewInstallOptions] return ok } -// ResetTenant resets all changes to the "tenant" field. -func (m *TaskMutation) ResetTenant() { - m.tenant = nil - m.addtenant = nil - delete(m.clearedFields, task.FieldTenant) +// ResetBrewInstallOptions resets all changes to the "brew_install_options" field. +func (m *TaskMutation) ResetBrewInstallOptions() { + m.brew_install_options = nil + delete(m.clearedFields, task.FieldBrewInstallOptions) } -// SetNetbirdGroups sets the "netbird_groups" field. -func (m *TaskMutation) SetNetbirdGroups(s string) { - m.netbird_groups = &s +// SetBrewGreedy sets the "brew_greedy" field. +func (m *TaskMutation) SetBrewGreedy(b bool) { + m.brew_greedy = &b } -// NetbirdGroups returns the value of the "netbird_groups" field in the mutation. -func (m *TaskMutation) NetbirdGroups() (r string, exists bool) { - v := m.netbird_groups +// BrewGreedy returns the value of the "brew_greedy" field in the mutation. +func (m *TaskMutation) BrewGreedy() (r bool, exists bool) { + v := m.brew_greedy if v == nil { return } return *v, true } -// OldNetbirdGroups returns the old "netbird_groups" field's value of the Task entity. +// OldBrewGreedy returns the old "brew_greedy" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldNetbirdGroups(ctx context.Context) (v string, err error) { +func (m *TaskMutation) OldBrewGreedy(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNetbirdGroups is only allowed on UpdateOne operations") + return v, errors.New("OldBrewGreedy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNetbirdGroups requires an ID field in the mutation") + return v, errors.New("OldBrewGreedy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNetbirdGroups: %w", err) + return v, fmt.Errorf("querying old value for OldBrewGreedy: %w", err) } - return oldValue.NetbirdGroups, nil + return oldValue.BrewGreedy, nil } -// ClearNetbirdGroups clears the value of the "netbird_groups" field. -func (m *TaskMutation) ClearNetbirdGroups() { - m.netbird_groups = nil - m.clearedFields[task.FieldNetbirdGroups] = struct{}{} +// ClearBrewGreedy clears the value of the "brew_greedy" field. +func (m *TaskMutation) ClearBrewGreedy() { + m.brew_greedy = nil + m.clearedFields[task.FieldBrewGreedy] = struct{}{} } -// NetbirdGroupsCleared returns if the "netbird_groups" field was cleared in this mutation. -func (m *TaskMutation) NetbirdGroupsCleared() bool { - _, ok := m.clearedFields[task.FieldNetbirdGroups] +// BrewGreedyCleared returns if the "brew_greedy" field was cleared in this mutation. +func (m *TaskMutation) BrewGreedyCleared() bool { + _, ok := m.clearedFields[task.FieldBrewGreedy] return ok } -// ResetNetbirdGroups resets all changes to the "netbird_groups" field. -func (m *TaskMutation) ResetNetbirdGroups() { - m.netbird_groups = nil - delete(m.clearedFields, task.FieldNetbirdGroups) +// ResetBrewGreedy resets all changes to the "brew_greedy" field. +func (m *TaskMutation) ResetBrewGreedy() { + m.brew_greedy = nil + delete(m.clearedFields, task.FieldBrewGreedy) } -// SetNetbirdAllowExtraDNSLabels sets the "netbird_allow_extra_dns_labels" field. -func (m *TaskMutation) SetNetbirdAllowExtraDNSLabels(b bool) { - m.netbird_allow_extra_dns_labels = &b +// SetPackageVersion sets the "package_version" field. +func (m *TaskMutation) SetPackageVersion(s string) { + m.package_version = &s } -// NetbirdAllowExtraDNSLabels returns the value of the "netbird_allow_extra_dns_labels" field in the mutation. -func (m *TaskMutation) NetbirdAllowExtraDNSLabels() (r bool, exists bool) { - v := m.netbird_allow_extra_dns_labels +// PackageVersion returns the value of the "package_version" field in the mutation. +func (m *TaskMutation) PackageVersion() (r string, exists bool) { + v := m.package_version if v == nil { return } return *v, true } -// OldNetbirdAllowExtraDNSLabels returns the old "netbird_allow_extra_dns_labels" field's value of the Task entity. +// OldPackageVersion returns the old "package_version" field's value of the Task entity. // If the Task object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TaskMutation) OldNetbirdAllowExtraDNSLabels(ctx context.Context) (v bool, err error) { +func (m *TaskMutation) OldPackageVersion(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNetbirdAllowExtraDNSLabels is only allowed on UpdateOne operations") + return v, errors.New("OldPackageVersion is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNetbirdAllowExtraDNSLabels requires an ID field in the mutation") + return v, errors.New("OldPackageVersion requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNetbirdAllowExtraDNSLabels: %w", err) + return v, fmt.Errorf("querying old value for OldPackageVersion: %w", err) } - return oldValue.NetbirdAllowExtraDNSLabels, nil + return oldValue.PackageVersion, nil } -// ClearNetbirdAllowExtraDNSLabels clears the value of the "netbird_allow_extra_dns_labels" field. -func (m *TaskMutation) ClearNetbirdAllowExtraDNSLabels() { - m.netbird_allow_extra_dns_labels = nil - m.clearedFields[task.FieldNetbirdAllowExtraDNSLabels] = struct{}{} +// ClearPackageVersion clears the value of the "package_version" field. +func (m *TaskMutation) ClearPackageVersion() { + m.package_version = nil + m.clearedFields[task.FieldPackageVersion] = struct{}{} } -// NetbirdAllowExtraDNSLabelsCleared returns if the "netbird_allow_extra_dns_labels" field was cleared in this mutation. -func (m *TaskMutation) NetbirdAllowExtraDNSLabelsCleared() bool { - _, ok := m.clearedFields[task.FieldNetbirdAllowExtraDNSLabels] +// PackageVersionCleared returns if the "package_version" field was cleared in this mutation. +func (m *TaskMutation) PackageVersionCleared() bool { + _, ok := m.clearedFields[task.FieldPackageVersion] return ok } -// ResetNetbirdAllowExtraDNSLabels resets all changes to the "netbird_allow_extra_dns_labels" field. -func (m *TaskMutation) ResetNetbirdAllowExtraDNSLabels() { - m.netbird_allow_extra_dns_labels = nil - delete(m.clearedFields, task.FieldNetbirdAllowExtraDNSLabels) +// ResetPackageVersion resets all changes to the "package_version" field. +func (m *TaskMutation) ResetPackageVersion() { + m.package_version = nil + delete(m.clearedFields, task.FieldPackageVersion) } -// AddTagIDs adds the "tags" edge to the Tag entity by ids. -func (m *TaskMutation) AddTagIDs(ids ...int) { - if m.tags == nil { - m.tags = make(map[int]struct{}) +// SetAptAllowDowngrade sets the "apt_allow_downgrade" field. +func (m *TaskMutation) SetAptAllowDowngrade(b bool) { + m.apt_allow_downgrade = &b +} + +// AptAllowDowngrade returns the value of the "apt_allow_downgrade" field in the mutation. +func (m *TaskMutation) AptAllowDowngrade() (r bool, exists bool) { + v := m.apt_allow_downgrade + if v == nil { + return } - for i := range ids { - m.tags[ids[i]] = struct{}{} + return *v, true +} + +// OldAptAllowDowngrade returns the old "apt_allow_downgrade" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptAllowDowngrade(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptAllowDowngrade is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptAllowDowngrade requires an ID field in the mutation") } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptAllowDowngrade: %w", err) + } + return oldValue.AptAllowDowngrade, nil } -// ClearTags clears the "tags" edge to the Tag entity. -func (m *TaskMutation) ClearTags() { - m.clearedtags = true +// ClearAptAllowDowngrade clears the value of the "apt_allow_downgrade" field. +func (m *TaskMutation) ClearAptAllowDowngrade() { + m.apt_allow_downgrade = nil + m.clearedFields[task.FieldAptAllowDowngrade] = struct{}{} } -// TagsCleared reports if the "tags" edge to the Tag entity was cleared. -func (m *TaskMutation) TagsCleared() bool { - return m.clearedtags +// AptAllowDowngradeCleared returns if the "apt_allow_downgrade" field was cleared in this mutation. +func (m *TaskMutation) AptAllowDowngradeCleared() bool { + _, ok := m.clearedFields[task.FieldAptAllowDowngrade] + return ok } -// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. -func (m *TaskMutation) RemoveTagIDs(ids ...int) { - if m.removedtags == nil { - m.removedtags = make(map[int]struct{}) +// ResetAptAllowDowngrade resets all changes to the "apt_allow_downgrade" field. +func (m *TaskMutation) ResetAptAllowDowngrade() { + m.apt_allow_downgrade = nil + delete(m.clearedFields, task.FieldAptAllowDowngrade) +} + +// SetAptDeb sets the "apt_deb" field. +func (m *TaskMutation) SetAptDeb(s string) { + m.apt_deb = &s +} + +// AptDeb returns the value of the "apt_deb" field in the mutation. +func (m *TaskMutation) AptDeb() (r string, exists bool) { + v := m.apt_deb + if v == nil { + return } - for i := range ids { - delete(m.tags, ids[i]) - m.removedtags[ids[i]] = struct{}{} + return *v, true +} + +// OldAptDeb returns the old "apt_deb" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptDeb(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptDeb is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptDeb requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptDeb: %w", err) } + return oldValue.AptDeb, nil } -// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. -func (m *TaskMutation) RemovedTagsIDs() (ids []int) { - for id := range m.removedtags { - ids = append(ids, id) +// ClearAptDeb clears the value of the "apt_deb" field. +func (m *TaskMutation) ClearAptDeb() { + m.apt_deb = nil + m.clearedFields[task.FieldAptDeb] = struct{}{} +} + +// AptDebCleared returns if the "apt_deb" field was cleared in this mutation. +func (m *TaskMutation) AptDebCleared() bool { + _, ok := m.clearedFields[task.FieldAptDeb] + return ok +} + +// ResetAptDeb resets all changes to the "apt_deb" field. +func (m *TaskMutation) ResetAptDeb() { + m.apt_deb = nil + delete(m.clearedFields, task.FieldAptDeb) +} + +// SetAptDpkgOptions sets the "apt_dpkg_options" field. +func (m *TaskMutation) SetAptDpkgOptions(s string) { + m.apt_dpkg_options = &s +} + +// AptDpkgOptions returns the value of the "apt_dpkg_options" field in the mutation. +func (m *TaskMutation) AptDpkgOptions() (r string, exists bool) { + v := m.apt_dpkg_options + if v == nil { + return + } + return *v, true +} + +// OldAptDpkgOptions returns the old "apt_dpkg_options" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptDpkgOptions(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptDpkgOptions is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptDpkgOptions requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptDpkgOptions: %w", err) + } + return oldValue.AptDpkgOptions, nil +} + +// ClearAptDpkgOptions clears the value of the "apt_dpkg_options" field. +func (m *TaskMutation) ClearAptDpkgOptions() { + m.apt_dpkg_options = nil + m.clearedFields[task.FieldAptDpkgOptions] = struct{}{} +} + +// AptDpkgOptionsCleared returns if the "apt_dpkg_options" field was cleared in this mutation. +func (m *TaskMutation) AptDpkgOptionsCleared() bool { + _, ok := m.clearedFields[task.FieldAptDpkgOptions] + return ok +} + +// ResetAptDpkgOptions resets all changes to the "apt_dpkg_options" field. +func (m *TaskMutation) ResetAptDpkgOptions() { + m.apt_dpkg_options = nil + delete(m.clearedFields, task.FieldAptDpkgOptions) +} + +// SetAptFailOnAutoremove sets the "apt_fail_on_autoremove" field. +func (m *TaskMutation) SetAptFailOnAutoremove(b bool) { + m.apt_fail_on_autoremove = &b +} + +// AptFailOnAutoremove returns the value of the "apt_fail_on_autoremove" field in the mutation. +func (m *TaskMutation) AptFailOnAutoremove() (r bool, exists bool) { + v := m.apt_fail_on_autoremove + if v == nil { + return + } + return *v, true +} + +// OldAptFailOnAutoremove returns the old "apt_fail_on_autoremove" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptFailOnAutoremove(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptFailOnAutoremove is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptFailOnAutoremove requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptFailOnAutoremove: %w", err) + } + return oldValue.AptFailOnAutoremove, nil +} + +// ClearAptFailOnAutoremove clears the value of the "apt_fail_on_autoremove" field. +func (m *TaskMutation) ClearAptFailOnAutoremove() { + m.apt_fail_on_autoremove = nil + m.clearedFields[task.FieldAptFailOnAutoremove] = struct{}{} +} + +// AptFailOnAutoremoveCleared returns if the "apt_fail_on_autoremove" field was cleared in this mutation. +func (m *TaskMutation) AptFailOnAutoremoveCleared() bool { + _, ok := m.clearedFields[task.FieldAptFailOnAutoremove] + return ok +} + +// ResetAptFailOnAutoremove resets all changes to the "apt_fail_on_autoremove" field. +func (m *TaskMutation) ResetAptFailOnAutoremove() { + m.apt_fail_on_autoremove = nil + delete(m.clearedFields, task.FieldAptFailOnAutoremove) +} + +// SetAptForce sets the "apt_force" field. +func (m *TaskMutation) SetAptForce(b bool) { + m.apt_force = &b +} + +// AptForce returns the value of the "apt_force" field in the mutation. +func (m *TaskMutation) AptForce() (r bool, exists bool) { + v := m.apt_force + if v == nil { + return + } + return *v, true +} + +// OldAptForce returns the old "apt_force" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptForce(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptForce is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptForce requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptForce: %w", err) + } + return oldValue.AptForce, nil +} + +// ClearAptForce clears the value of the "apt_force" field. +func (m *TaskMutation) ClearAptForce() { + m.apt_force = nil + m.clearedFields[task.FieldAptForce] = struct{}{} +} + +// AptForceCleared returns if the "apt_force" field was cleared in this mutation. +func (m *TaskMutation) AptForceCleared() bool { + _, ok := m.clearedFields[task.FieldAptForce] + return ok +} + +// ResetAptForce resets all changes to the "apt_force" field. +func (m *TaskMutation) ResetAptForce() { + m.apt_force = nil + delete(m.clearedFields, task.FieldAptForce) +} + +// SetAptInstallRecommends sets the "apt_install_recommends" field. +func (m *TaskMutation) SetAptInstallRecommends(b bool) { + m.apt_install_recommends = &b +} + +// AptInstallRecommends returns the value of the "apt_install_recommends" field in the mutation. +func (m *TaskMutation) AptInstallRecommends() (r bool, exists bool) { + v := m.apt_install_recommends + if v == nil { + return + } + return *v, true +} + +// OldAptInstallRecommends returns the old "apt_install_recommends" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptInstallRecommends(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptInstallRecommends is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptInstallRecommends requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptInstallRecommends: %w", err) + } + return oldValue.AptInstallRecommends, nil +} + +// ClearAptInstallRecommends clears the value of the "apt_install_recommends" field. +func (m *TaskMutation) ClearAptInstallRecommends() { + m.apt_install_recommends = nil + m.clearedFields[task.FieldAptInstallRecommends] = struct{}{} +} + +// AptInstallRecommendsCleared returns if the "apt_install_recommends" field was cleared in this mutation. +func (m *TaskMutation) AptInstallRecommendsCleared() bool { + _, ok := m.clearedFields[task.FieldAptInstallRecommends] + return ok +} + +// ResetAptInstallRecommends resets all changes to the "apt_install_recommends" field. +func (m *TaskMutation) ResetAptInstallRecommends() { + m.apt_install_recommends = nil + delete(m.clearedFields, task.FieldAptInstallRecommends) +} + +// SetAptName sets the "apt_name" field. +func (m *TaskMutation) SetAptName(s string) { + m.apt_name = &s +} + +// AptName returns the value of the "apt_name" field in the mutation. +func (m *TaskMutation) AptName() (r string, exists bool) { + v := m.apt_name + if v == nil { + return + } + return *v, true +} + +// OldAptName returns the old "apt_name" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptName: %w", err) + } + return oldValue.AptName, nil +} + +// ClearAptName clears the value of the "apt_name" field. +func (m *TaskMutation) ClearAptName() { + m.apt_name = nil + m.clearedFields[task.FieldAptName] = struct{}{} +} + +// AptNameCleared returns if the "apt_name" field was cleared in this mutation. +func (m *TaskMutation) AptNameCleared() bool { + _, ok := m.clearedFields[task.FieldAptName] + return ok +} + +// ResetAptName resets all changes to the "apt_name" field. +func (m *TaskMutation) ResetAptName() { + m.apt_name = nil + delete(m.clearedFields, task.FieldAptName) +} + +// SetAptOnlyUpgrade sets the "apt_only_upgrade" field. +func (m *TaskMutation) SetAptOnlyUpgrade(b bool) { + m.apt_only_upgrade = &b +} + +// AptOnlyUpgrade returns the value of the "apt_only_upgrade" field in the mutation. +func (m *TaskMutation) AptOnlyUpgrade() (r bool, exists bool) { + v := m.apt_only_upgrade + if v == nil { + return + } + return *v, true +} + +// OldAptOnlyUpgrade returns the old "apt_only_upgrade" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptOnlyUpgrade(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptOnlyUpgrade is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptOnlyUpgrade requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptOnlyUpgrade: %w", err) + } + return oldValue.AptOnlyUpgrade, nil +} + +// ClearAptOnlyUpgrade clears the value of the "apt_only_upgrade" field. +func (m *TaskMutation) ClearAptOnlyUpgrade() { + m.apt_only_upgrade = nil + m.clearedFields[task.FieldAptOnlyUpgrade] = struct{}{} +} + +// AptOnlyUpgradeCleared returns if the "apt_only_upgrade" field was cleared in this mutation. +func (m *TaskMutation) AptOnlyUpgradeCleared() bool { + _, ok := m.clearedFields[task.FieldAptOnlyUpgrade] + return ok +} + +// ResetAptOnlyUpgrade resets all changes to the "apt_only_upgrade" field. +func (m *TaskMutation) ResetAptOnlyUpgrade() { + m.apt_only_upgrade = nil + delete(m.clearedFields, task.FieldAptOnlyUpgrade) +} + +// SetAptPurge sets the "apt_purge" field. +func (m *TaskMutation) SetAptPurge(b bool) { + m.apt_purge = &b +} + +// AptPurge returns the value of the "apt_purge" field in the mutation. +func (m *TaskMutation) AptPurge() (r bool, exists bool) { + v := m.apt_purge + if v == nil { + return + } + return *v, true +} + +// OldAptPurge returns the old "apt_purge" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptPurge(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptPurge is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptPurge requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptPurge: %w", err) + } + return oldValue.AptPurge, nil +} + +// ClearAptPurge clears the value of the "apt_purge" field. +func (m *TaskMutation) ClearAptPurge() { + m.apt_purge = nil + m.clearedFields[task.FieldAptPurge] = struct{}{} +} + +// AptPurgeCleared returns if the "apt_purge" field was cleared in this mutation. +func (m *TaskMutation) AptPurgeCleared() bool { + _, ok := m.clearedFields[task.FieldAptPurge] + return ok +} + +// ResetAptPurge resets all changes to the "apt_purge" field. +func (m *TaskMutation) ResetAptPurge() { + m.apt_purge = nil + delete(m.clearedFields, task.FieldAptPurge) +} + +// SetAptUpdateCache sets the "apt_update_cache" field. +func (m *TaskMutation) SetAptUpdateCache(b bool) { + m.apt_update_cache = &b +} + +// AptUpdateCache returns the value of the "apt_update_cache" field in the mutation. +func (m *TaskMutation) AptUpdateCache() (r bool, exists bool) { + v := m.apt_update_cache + if v == nil { + return + } + return *v, true +} + +// OldAptUpdateCache returns the old "apt_update_cache" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptUpdateCache(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptUpdateCache is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptUpdateCache requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptUpdateCache: %w", err) + } + return oldValue.AptUpdateCache, nil +} + +// ClearAptUpdateCache clears the value of the "apt_update_cache" field. +func (m *TaskMutation) ClearAptUpdateCache() { + m.apt_update_cache = nil + m.clearedFields[task.FieldAptUpdateCache] = struct{}{} +} + +// AptUpdateCacheCleared returns if the "apt_update_cache" field was cleared in this mutation. +func (m *TaskMutation) AptUpdateCacheCleared() bool { + _, ok := m.clearedFields[task.FieldAptUpdateCache] + return ok +} + +// ResetAptUpdateCache resets all changes to the "apt_update_cache" field. +func (m *TaskMutation) ResetAptUpdateCache() { + m.apt_update_cache = nil + delete(m.clearedFields, task.FieldAptUpdateCache) +} + +// SetAptUpgradeType sets the "apt_upgrade_type" field. +func (m *TaskMutation) SetAptUpgradeType(tut task.AptUpgradeType) { + m.apt_upgrade_type = &tut +} + +// AptUpgradeType returns the value of the "apt_upgrade_type" field in the mutation. +func (m *TaskMutation) AptUpgradeType() (r task.AptUpgradeType, exists bool) { + v := m.apt_upgrade_type + if v == nil { + return + } + return *v, true +} + +// OldAptUpgradeType returns the old "apt_upgrade_type" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldAptUpgradeType(ctx context.Context) (v task.AptUpgradeType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAptUpgradeType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAptUpgradeType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAptUpgradeType: %w", err) + } + return oldValue.AptUpgradeType, nil +} + +// ClearAptUpgradeType clears the value of the "apt_upgrade_type" field. +func (m *TaskMutation) ClearAptUpgradeType() { + m.apt_upgrade_type = nil + m.clearedFields[task.FieldAptUpgradeType] = struct{}{} +} + +// AptUpgradeTypeCleared returns if the "apt_upgrade_type" field was cleared in this mutation. +func (m *TaskMutation) AptUpgradeTypeCleared() bool { + _, ok := m.clearedFields[task.FieldAptUpgradeType] + return ok +} + +// ResetAptUpgradeType resets all changes to the "apt_upgrade_type" field. +func (m *TaskMutation) ResetAptUpgradeType() { + m.apt_upgrade_type = nil + delete(m.clearedFields, task.FieldAptUpgradeType) +} + +// SetVersion sets the "version" field. +func (m *TaskMutation) SetVersion(i int) { + m.version = &i + m.addversion = nil +} + +// Version returns the value of the "version" field in the mutation. +func (m *TaskMutation) Version() (r int, exists bool) { + v := m.version + if v == nil { + return + } + return *v, true +} + +// OldVersion returns the old "version" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldVersion(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVersion is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVersion requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVersion: %w", err) + } + return oldValue.Version, nil +} + +// AddVersion adds i to the "version" field. +func (m *TaskMutation) AddVersion(i int) { + if m.addversion != nil { + *m.addversion += i + } else { + m.addversion = &i + } +} + +// AddedVersion returns the value that was added to the "version" field in this mutation. +func (m *TaskMutation) AddedVersion() (r int, exists bool) { + v := m.addversion + if v == nil { + return + } + return *v, true +} + +// ClearVersion clears the value of the "version" field. +func (m *TaskMutation) ClearVersion() { + m.version = nil + m.addversion = nil + m.clearedFields[task.FieldVersion] = struct{}{} +} + +// VersionCleared returns if the "version" field was cleared in this mutation. +func (m *TaskMutation) VersionCleared() bool { + _, ok := m.clearedFields[task.FieldVersion] + return ok +} + +// ResetVersion resets all changes to the "version" field. +func (m *TaskMutation) ResetVersion() { + m.version = nil + m.addversion = nil + delete(m.clearedFields, task.FieldVersion) +} + +// SetTenant sets the "tenant" field. +func (m *TaskMutation) SetTenant(i int) { + m.tenant = &i + m.addtenant = nil +} + +// Tenant returns the value of the "tenant" field in the mutation. +func (m *TaskMutation) Tenant() (r int, exists bool) { + v := m.tenant + if v == nil { + return + } + return *v, true +} + +// OldTenant returns the old "tenant" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldTenant(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenant is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenant requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenant: %w", err) + } + return oldValue.Tenant, nil +} + +// AddTenant adds i to the "tenant" field. +func (m *TaskMutation) AddTenant(i int) { + if m.addtenant != nil { + *m.addtenant += i + } else { + m.addtenant = &i + } +} + +// AddedTenant returns the value that was added to the "tenant" field in this mutation. +func (m *TaskMutation) AddedTenant() (r int, exists bool) { + v := m.addtenant + if v == nil { + return + } + return *v, true +} + +// ClearTenant clears the value of the "tenant" field. +func (m *TaskMutation) ClearTenant() { + m.tenant = nil + m.addtenant = nil + m.clearedFields[task.FieldTenant] = struct{}{} +} + +// TenantCleared returns if the "tenant" field was cleared in this mutation. +func (m *TaskMutation) TenantCleared() bool { + _, ok := m.clearedFields[task.FieldTenant] + return ok +} + +// ResetTenant resets all changes to the "tenant" field. +func (m *TaskMutation) ResetTenant() { + m.tenant = nil + m.addtenant = nil + delete(m.clearedFields, task.FieldTenant) +} + +// SetNetbirdGroups sets the "netbird_groups" field. +func (m *TaskMutation) SetNetbirdGroups(s string) { + m.netbird_groups = &s +} + +// NetbirdGroups returns the value of the "netbird_groups" field in the mutation. +func (m *TaskMutation) NetbirdGroups() (r string, exists bool) { + v := m.netbird_groups + if v == nil { + return + } + return *v, true +} + +// OldNetbirdGroups returns the old "netbird_groups" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldNetbirdGroups(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNetbirdGroups is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNetbirdGroups requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNetbirdGroups: %w", err) + } + return oldValue.NetbirdGroups, nil +} + +// ClearNetbirdGroups clears the value of the "netbird_groups" field. +func (m *TaskMutation) ClearNetbirdGroups() { + m.netbird_groups = nil + m.clearedFields[task.FieldNetbirdGroups] = struct{}{} +} + +// NetbirdGroupsCleared returns if the "netbird_groups" field was cleared in this mutation. +func (m *TaskMutation) NetbirdGroupsCleared() bool { + _, ok := m.clearedFields[task.FieldNetbirdGroups] + return ok +} + +// ResetNetbirdGroups resets all changes to the "netbird_groups" field. +func (m *TaskMutation) ResetNetbirdGroups() { + m.netbird_groups = nil + delete(m.clearedFields, task.FieldNetbirdGroups) +} + +// SetNetbirdAllowExtraDNSLabels sets the "netbird_allow_extra_dns_labels" field. +func (m *TaskMutation) SetNetbirdAllowExtraDNSLabels(b bool) { + m.netbird_allow_extra_dns_labels = &b +} + +// NetbirdAllowExtraDNSLabels returns the value of the "netbird_allow_extra_dns_labels" field in the mutation. +func (m *TaskMutation) NetbirdAllowExtraDNSLabels() (r bool, exists bool) { + v := m.netbird_allow_extra_dns_labels + if v == nil { + return + } + return *v, true +} + +// OldNetbirdAllowExtraDNSLabels returns the old "netbird_allow_extra_dns_labels" field's value of the Task entity. +// If the Task object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TaskMutation) OldNetbirdAllowExtraDNSLabels(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNetbirdAllowExtraDNSLabels is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNetbirdAllowExtraDNSLabels requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNetbirdAllowExtraDNSLabels: %w", err) + } + return oldValue.NetbirdAllowExtraDNSLabels, nil +} + +// ClearNetbirdAllowExtraDNSLabels clears the value of the "netbird_allow_extra_dns_labels" field. +func (m *TaskMutation) ClearNetbirdAllowExtraDNSLabels() { + m.netbird_allow_extra_dns_labels = nil + m.clearedFields[task.FieldNetbirdAllowExtraDNSLabels] = struct{}{} +} + +// NetbirdAllowExtraDNSLabelsCleared returns if the "netbird_allow_extra_dns_labels" field was cleared in this mutation. +func (m *TaskMutation) NetbirdAllowExtraDNSLabelsCleared() bool { + _, ok := m.clearedFields[task.FieldNetbirdAllowExtraDNSLabels] + return ok +} + +// ResetNetbirdAllowExtraDNSLabels resets all changes to the "netbird_allow_extra_dns_labels" field. +func (m *TaskMutation) ResetNetbirdAllowExtraDNSLabels() { + m.netbird_allow_extra_dns_labels = nil + delete(m.clearedFields, task.FieldNetbirdAllowExtraDNSLabels) +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *TaskMutation) AddTagIDs(ids ...int) { + if m.tags == nil { + m.tags = make(map[int]struct{}) + } + for i := range ids { + m.tags[ids[i]] = struct{}{} + } +} + +// ClearTags clears the "tags" edge to the Tag entity. +func (m *TaskMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *TaskMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *TaskMutation) RemoveTagIDs(ids ...int) { + if m.removedtags == nil { + m.removedtags = make(map[int]struct{}) + } + for i := range ids { + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} + } +} + +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *TaskMutation) RemovedTagsIDs() (ids []int) { + for id := range m.removedtags { + ids = append(ids, id) + } + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *TaskMutation) TagsIDs() (ids []int) { + for id := range m.tags { + ids = append(ids, id) + } + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *TaskMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// SetProfileID sets the "profile" edge to the Profile entity by id. +func (m *TaskMutation) SetProfileID(id int) { + m.profile = &id +} + +// ClearProfile clears the "profile" edge to the Profile entity. +func (m *TaskMutation) ClearProfile() { + m.clearedprofile = true +} + +// ProfileCleared reports if the "profile" edge to the Profile entity was cleared. +func (m *TaskMutation) ProfileCleared() bool { + return m.clearedprofile +} + +// ProfileID returns the "profile" edge ID in the mutation. +func (m *TaskMutation) ProfileID() (id int, exists bool) { + if m.profile != nil { + return *m.profile, true + } + return +} + +// ProfileIDs returns the "profile" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ProfileID instead. It exists only for internal usage by the builders. +func (m *TaskMutation) ProfileIDs() (ids []int) { + if id := m.profile; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetProfile resets all changes to the "profile" edge. +func (m *TaskMutation) ResetProfile() { + m.profile = nil + m.clearedprofile = false +} + +// Where appends a list predicates to the TaskMutation builder. +func (m *TaskMutation) Where(ps ...predicate.Task) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the TaskMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TaskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Task, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *TaskMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *TaskMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Task). +func (m *TaskMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *TaskMutation) Fields() []string { + fields := make([]string, 0, 88) + if m.name != nil { + fields = append(fields, task.FieldName) + } + if m._type != nil { + fields = append(fields, task.FieldType) + } + if m.package_id != nil { + fields = append(fields, task.FieldPackageID) + } + if m.package_name != nil { + fields = append(fields, task.FieldPackageName) + } + if m.package_latest != nil { + fields = append(fields, task.FieldPackageLatest) + } + if m.registry_key != nil { + fields = append(fields, task.FieldRegistryKey) + } + if m.registry_key_value_name != nil { + fields = append(fields, task.FieldRegistryKeyValueName) + } + if m.registry_key_value_type != nil { + fields = append(fields, task.FieldRegistryKeyValueType) + } + if m.registry_key_value_data != nil { + fields = append(fields, task.FieldRegistryKeyValueData) + } + if m.registry_hex != nil { + fields = append(fields, task.FieldRegistryHex) + } + if m.registry_force != nil { + fields = append(fields, task.FieldRegistryForce) + } + if m.local_user_username != nil { + fields = append(fields, task.FieldLocalUserUsername) + } + if m.local_user_description != nil { + fields = append(fields, task.FieldLocalUserDescription) + } + if m.local_user_disable != nil { + fields = append(fields, task.FieldLocalUserDisable) + } + if m.local_user_fullname != nil { + fields = append(fields, task.FieldLocalUserFullname) + } + if m.local_user_password != nil { + fields = append(fields, task.FieldLocalUserPassword) + } + if m.local_user_password_change_not_allowed != nil { + fields = append(fields, task.FieldLocalUserPasswordChangeNotAllowed) + } + if m.local_user_password_change_required != nil { + fields = append(fields, task.FieldLocalUserPasswordChangeRequired) + } + if m.local_user_password_never_expires != nil { + fields = append(fields, task.FieldLocalUserPasswordNeverExpires) + } + if m.local_user_append != nil { + fields = append(fields, task.FieldLocalUserAppend) + } + if m.local_user_create_home != nil { + fields = append(fields, task.FieldLocalUserCreateHome) + } + if m.local_user_expires != nil { + fields = append(fields, task.FieldLocalUserExpires) + } + if m.local_user_force != nil { + fields = append(fields, task.FieldLocalUserForce) + } + if m.local_user_generate_ssh_key != nil { + fields = append(fields, task.FieldLocalUserGenerateSSHKey) + } + if m.local_user_group != nil { + fields = append(fields, task.FieldLocalUserGroup) + } + if m.local_user_groups != nil { + fields = append(fields, task.FieldLocalUserGroups) + } + if m.local_user_home != nil { + fields = append(fields, task.FieldLocalUserHome) + } + if m.local_user_move_home != nil { + fields = append(fields, task.FieldLocalUserMoveHome) + } + if m.local_user_nonunique != nil { + fields = append(fields, task.FieldLocalUserNonunique) + } + if m.local_user_password_expire_account_disable != nil { + fields = append(fields, task.FieldLocalUserPasswordExpireAccountDisable) + } + if m.local_user_password_expire_max != nil { + fields = append(fields, task.FieldLocalUserPasswordExpireMax) + } + if m.local_user_password_expire_min != nil { + fields = append(fields, task.FieldLocalUserPasswordExpireMin) + } + if m.local_user_password_expire_warn != nil { + fields = append(fields, task.FieldLocalUserPasswordExpireWarn) + } + if m.local_user_password_lock != nil { + fields = append(fields, task.FieldLocalUserPasswordLock) + } + if m.local_user_seuser != nil { + fields = append(fields, task.FieldLocalUserSeuser) + } + if m.local_user_shell != nil { + fields = append(fields, task.FieldLocalUserShell) + } + if m.local_user_skeleton != nil { + fields = append(fields, task.FieldLocalUserSkeleton) + } + if m.local_user_system != nil { + fields = append(fields, task.FieldLocalUserSystem) + } + if m.local_user_id != nil { + fields = append(fields, task.FieldLocalUserID) + } + if m.local_user_id_max != nil { + fields = append(fields, task.FieldLocalUserIDMax) + } + if m.local_user_id_min != nil { + fields = append(fields, task.FieldLocalUserIDMin) + } + if m.local_user_ssh_key_bits != nil { + fields = append(fields, task.FieldLocalUserSSHKeyBits) + } + if m.local_user_ssh_key_comment != nil { + fields = append(fields, task.FieldLocalUserSSHKeyComment) + } + if m.local_user_ssh_key_file != nil { + fields = append(fields, task.FieldLocalUserSSHKeyFile) + } + if m.local_user_ssh_key_passphrase != nil { + fields = append(fields, task.FieldLocalUserSSHKeyPassphrase) + } + if m.local_user_ssh_key_type != nil { + fields = append(fields, task.FieldLocalUserSSHKeyType) + } + if m.local_user_umask != nil { + fields = append(fields, task.FieldLocalUserUmask) + } + if m.local_group_id != nil { + fields = append(fields, task.FieldLocalGroupID) + } + if m.local_group_name != nil { + fields = append(fields, task.FieldLocalGroupName) + } + if m.local_group_description != nil { + fields = append(fields, task.FieldLocalGroupDescription) + } + if m.local_group_system != nil { + fields = append(fields, task.FieldLocalGroupSystem) + } + if m.local_group_force != nil { + fields = append(fields, task.FieldLocalGroupForce) + } + if m.local_group_members != nil { + fields = append(fields, task.FieldLocalGroupMembers) + } + if m.local_group_members_to_include != nil { + fields = append(fields, task.FieldLocalGroupMembersToInclude) + } + if m.local_group_members_to_exclude != nil { + fields = append(fields, task.FieldLocalGroupMembersToExclude) + } + if m.msi_productid != nil { + fields = append(fields, task.FieldMsiProductid) + } + if m.msi_path != nil { + fields = append(fields, task.FieldMsiPath) + } + if m.msi_arguments != nil { + fields = append(fields, task.FieldMsiArguments) + } + if m.msi_file_hash != nil { + fields = append(fields, task.FieldMsiFileHash) + } + if m.msi_file_hash_alg != nil { + fields = append(fields, task.FieldMsiFileHashAlg) + } + if m.msi_log_path != nil { + fields = append(fields, task.FieldMsiLogPath) + } + if m.script != nil { + fields = append(fields, task.FieldScript) + } + if m.script_executable != nil { + fields = append(fields, task.FieldScriptExecutable) + } + if m.script_creates != nil { + fields = append(fields, task.FieldScriptCreates) + } + if m.script_run != nil { + fields = append(fields, task.FieldScriptRun) + } + if m.agent_type != nil { + fields = append(fields, task.FieldAgentType) + } + if m.when != nil { + fields = append(fields, task.FieldWhen) + } + if m.brew_update != nil { + fields = append(fields, task.FieldBrewUpdate) + } + if m.brew_upgrade_all != nil { + fields = append(fields, task.FieldBrewUpgradeAll) + } + if m.brew_upgrade_options != nil { + fields = append(fields, task.FieldBrewUpgradeOptions) + } + if m.brew_install_options != nil { + fields = append(fields, task.FieldBrewInstallOptions) + } + if m.brew_greedy != nil { + fields = append(fields, task.FieldBrewGreedy) + } + if m.package_version != nil { + fields = append(fields, task.FieldPackageVersion) + } + if m.apt_allow_downgrade != nil { + fields = append(fields, task.FieldAptAllowDowngrade) + } + if m.apt_deb != nil { + fields = append(fields, task.FieldAptDeb) + } + if m.apt_dpkg_options != nil { + fields = append(fields, task.FieldAptDpkgOptions) + } + if m.apt_fail_on_autoremove != nil { + fields = append(fields, task.FieldAptFailOnAutoremove) + } + if m.apt_force != nil { + fields = append(fields, task.FieldAptForce) + } + if m.apt_install_recommends != nil { + fields = append(fields, task.FieldAptInstallRecommends) + } + if m.apt_name != nil { + fields = append(fields, task.FieldAptName) + } + if m.apt_only_upgrade != nil { + fields = append(fields, task.FieldAptOnlyUpgrade) + } + if m.apt_purge != nil { + fields = append(fields, task.FieldAptPurge) + } + if m.apt_update_cache != nil { + fields = append(fields, task.FieldAptUpdateCache) + } + if m.apt_upgrade_type != nil { + fields = append(fields, task.FieldAptUpgradeType) + } + if m.version != nil { + fields = append(fields, task.FieldVersion) + } + if m.tenant != nil { + fields = append(fields, task.FieldTenant) + } + if m.netbird_groups != nil { + fields = append(fields, task.FieldNetbirdGroups) + } + if m.netbird_allow_extra_dns_labels != nil { + fields = append(fields, task.FieldNetbirdAllowExtraDNSLabels) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *TaskMutation) Field(name string) (ent.Value, bool) { + switch name { + case task.FieldName: + return m.Name() + case task.FieldType: + return m.GetType() + case task.FieldPackageID: + return m.PackageID() + case task.FieldPackageName: + return m.PackageName() + case task.FieldPackageLatest: + return m.PackageLatest() + case task.FieldRegistryKey: + return m.RegistryKey() + case task.FieldRegistryKeyValueName: + return m.RegistryKeyValueName() + case task.FieldRegistryKeyValueType: + return m.RegistryKeyValueType() + case task.FieldRegistryKeyValueData: + return m.RegistryKeyValueData() + case task.FieldRegistryHex: + return m.RegistryHex() + case task.FieldRegistryForce: + return m.RegistryForce() + case task.FieldLocalUserUsername: + return m.LocalUserUsername() + case task.FieldLocalUserDescription: + return m.LocalUserDescription() + case task.FieldLocalUserDisable: + return m.LocalUserDisable() + case task.FieldLocalUserFullname: + return m.LocalUserFullname() + case task.FieldLocalUserPassword: + return m.LocalUserPassword() + case task.FieldLocalUserPasswordChangeNotAllowed: + return m.LocalUserPasswordChangeNotAllowed() + case task.FieldLocalUserPasswordChangeRequired: + return m.LocalUserPasswordChangeRequired() + case task.FieldLocalUserPasswordNeverExpires: + return m.LocalUserPasswordNeverExpires() + case task.FieldLocalUserAppend: + return m.LocalUserAppend() + case task.FieldLocalUserCreateHome: + return m.LocalUserCreateHome() + case task.FieldLocalUserExpires: + return m.LocalUserExpires() + case task.FieldLocalUserForce: + return m.LocalUserForce() + case task.FieldLocalUserGenerateSSHKey: + return m.LocalUserGenerateSSHKey() + case task.FieldLocalUserGroup: + return m.LocalUserGroup() + case task.FieldLocalUserGroups: + return m.LocalUserGroups() + case task.FieldLocalUserHome: + return m.LocalUserHome() + case task.FieldLocalUserMoveHome: + return m.LocalUserMoveHome() + case task.FieldLocalUserNonunique: + return m.LocalUserNonunique() + case task.FieldLocalUserPasswordExpireAccountDisable: + return m.LocalUserPasswordExpireAccountDisable() + case task.FieldLocalUserPasswordExpireMax: + return m.LocalUserPasswordExpireMax() + case task.FieldLocalUserPasswordExpireMin: + return m.LocalUserPasswordExpireMin() + case task.FieldLocalUserPasswordExpireWarn: + return m.LocalUserPasswordExpireWarn() + case task.FieldLocalUserPasswordLock: + return m.LocalUserPasswordLock() + case task.FieldLocalUserSeuser: + return m.LocalUserSeuser() + case task.FieldLocalUserShell: + return m.LocalUserShell() + case task.FieldLocalUserSkeleton: + return m.LocalUserSkeleton() + case task.FieldLocalUserSystem: + return m.LocalUserSystem() + case task.FieldLocalUserID: + return m.LocalUserID() + case task.FieldLocalUserIDMax: + return m.LocalUserIDMax() + case task.FieldLocalUserIDMin: + return m.LocalUserIDMin() + case task.FieldLocalUserSSHKeyBits: + return m.LocalUserSSHKeyBits() + case task.FieldLocalUserSSHKeyComment: + return m.LocalUserSSHKeyComment() + case task.FieldLocalUserSSHKeyFile: + return m.LocalUserSSHKeyFile() + case task.FieldLocalUserSSHKeyPassphrase: + return m.LocalUserSSHKeyPassphrase() + case task.FieldLocalUserSSHKeyType: + return m.LocalUserSSHKeyType() + case task.FieldLocalUserUmask: + return m.LocalUserUmask() + case task.FieldLocalGroupID: + return m.LocalGroupID() + case task.FieldLocalGroupName: + return m.LocalGroupName() + case task.FieldLocalGroupDescription: + return m.LocalGroupDescription() + case task.FieldLocalGroupSystem: + return m.LocalGroupSystem() + case task.FieldLocalGroupForce: + return m.LocalGroupForce() + case task.FieldLocalGroupMembers: + return m.LocalGroupMembers() + case task.FieldLocalGroupMembersToInclude: + return m.LocalGroupMembersToInclude() + case task.FieldLocalGroupMembersToExclude: + return m.LocalGroupMembersToExclude() + case task.FieldMsiProductid: + return m.MsiProductid() + case task.FieldMsiPath: + return m.MsiPath() + case task.FieldMsiArguments: + return m.MsiArguments() + case task.FieldMsiFileHash: + return m.MsiFileHash() + case task.FieldMsiFileHashAlg: + return m.MsiFileHashAlg() + case task.FieldMsiLogPath: + return m.MsiLogPath() + case task.FieldScript: + return m.Script() + case task.FieldScriptExecutable: + return m.ScriptExecutable() + case task.FieldScriptCreates: + return m.ScriptCreates() + case task.FieldScriptRun: + return m.ScriptRun() + case task.FieldAgentType: + return m.AgentType() + case task.FieldWhen: + return m.When() + case task.FieldBrewUpdate: + return m.BrewUpdate() + case task.FieldBrewUpgradeAll: + return m.BrewUpgradeAll() + case task.FieldBrewUpgradeOptions: + return m.BrewUpgradeOptions() + case task.FieldBrewInstallOptions: + return m.BrewInstallOptions() + case task.FieldBrewGreedy: + return m.BrewGreedy() + case task.FieldPackageVersion: + return m.PackageVersion() + case task.FieldAptAllowDowngrade: + return m.AptAllowDowngrade() + case task.FieldAptDeb: + return m.AptDeb() + case task.FieldAptDpkgOptions: + return m.AptDpkgOptions() + case task.FieldAptFailOnAutoremove: + return m.AptFailOnAutoremove() + case task.FieldAptForce: + return m.AptForce() + case task.FieldAptInstallRecommends: + return m.AptInstallRecommends() + case task.FieldAptName: + return m.AptName() + case task.FieldAptOnlyUpgrade: + return m.AptOnlyUpgrade() + case task.FieldAptPurge: + return m.AptPurge() + case task.FieldAptUpdateCache: + return m.AptUpdateCache() + case task.FieldAptUpgradeType: + return m.AptUpgradeType() + case task.FieldVersion: + return m.Version() + case task.FieldTenant: + return m.Tenant() + case task.FieldNetbirdGroups: + return m.NetbirdGroups() + case task.FieldNetbirdAllowExtraDNSLabels: + return m.NetbirdAllowExtraDNSLabels() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *TaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case task.FieldName: + return m.OldName(ctx) + case task.FieldType: + return m.OldType(ctx) + case task.FieldPackageID: + return m.OldPackageID(ctx) + case task.FieldPackageName: + return m.OldPackageName(ctx) + case task.FieldPackageLatest: + return m.OldPackageLatest(ctx) + case task.FieldRegistryKey: + return m.OldRegistryKey(ctx) + case task.FieldRegistryKeyValueName: + return m.OldRegistryKeyValueName(ctx) + case task.FieldRegistryKeyValueType: + return m.OldRegistryKeyValueType(ctx) + case task.FieldRegistryKeyValueData: + return m.OldRegistryKeyValueData(ctx) + case task.FieldRegistryHex: + return m.OldRegistryHex(ctx) + case task.FieldRegistryForce: + return m.OldRegistryForce(ctx) + case task.FieldLocalUserUsername: + return m.OldLocalUserUsername(ctx) + case task.FieldLocalUserDescription: + return m.OldLocalUserDescription(ctx) + case task.FieldLocalUserDisable: + return m.OldLocalUserDisable(ctx) + case task.FieldLocalUserFullname: + return m.OldLocalUserFullname(ctx) + case task.FieldLocalUserPassword: + return m.OldLocalUserPassword(ctx) + case task.FieldLocalUserPasswordChangeNotAllowed: + return m.OldLocalUserPasswordChangeNotAllowed(ctx) + case task.FieldLocalUserPasswordChangeRequired: + return m.OldLocalUserPasswordChangeRequired(ctx) + case task.FieldLocalUserPasswordNeverExpires: + return m.OldLocalUserPasswordNeverExpires(ctx) + case task.FieldLocalUserAppend: + return m.OldLocalUserAppend(ctx) + case task.FieldLocalUserCreateHome: + return m.OldLocalUserCreateHome(ctx) + case task.FieldLocalUserExpires: + return m.OldLocalUserExpires(ctx) + case task.FieldLocalUserForce: + return m.OldLocalUserForce(ctx) + case task.FieldLocalUserGenerateSSHKey: + return m.OldLocalUserGenerateSSHKey(ctx) + case task.FieldLocalUserGroup: + return m.OldLocalUserGroup(ctx) + case task.FieldLocalUserGroups: + return m.OldLocalUserGroups(ctx) + case task.FieldLocalUserHome: + return m.OldLocalUserHome(ctx) + case task.FieldLocalUserMoveHome: + return m.OldLocalUserMoveHome(ctx) + case task.FieldLocalUserNonunique: + return m.OldLocalUserNonunique(ctx) + case task.FieldLocalUserPasswordExpireAccountDisable: + return m.OldLocalUserPasswordExpireAccountDisable(ctx) + case task.FieldLocalUserPasswordExpireMax: + return m.OldLocalUserPasswordExpireMax(ctx) + case task.FieldLocalUserPasswordExpireMin: + return m.OldLocalUserPasswordExpireMin(ctx) + case task.FieldLocalUserPasswordExpireWarn: + return m.OldLocalUserPasswordExpireWarn(ctx) + case task.FieldLocalUserPasswordLock: + return m.OldLocalUserPasswordLock(ctx) + case task.FieldLocalUserSeuser: + return m.OldLocalUserSeuser(ctx) + case task.FieldLocalUserShell: + return m.OldLocalUserShell(ctx) + case task.FieldLocalUserSkeleton: + return m.OldLocalUserSkeleton(ctx) + case task.FieldLocalUserSystem: + return m.OldLocalUserSystem(ctx) + case task.FieldLocalUserID: + return m.OldLocalUserID(ctx) + case task.FieldLocalUserIDMax: + return m.OldLocalUserIDMax(ctx) + case task.FieldLocalUserIDMin: + return m.OldLocalUserIDMin(ctx) + case task.FieldLocalUserSSHKeyBits: + return m.OldLocalUserSSHKeyBits(ctx) + case task.FieldLocalUserSSHKeyComment: + return m.OldLocalUserSSHKeyComment(ctx) + case task.FieldLocalUserSSHKeyFile: + return m.OldLocalUserSSHKeyFile(ctx) + case task.FieldLocalUserSSHKeyPassphrase: + return m.OldLocalUserSSHKeyPassphrase(ctx) + case task.FieldLocalUserSSHKeyType: + return m.OldLocalUserSSHKeyType(ctx) + case task.FieldLocalUserUmask: + return m.OldLocalUserUmask(ctx) + case task.FieldLocalGroupID: + return m.OldLocalGroupID(ctx) + case task.FieldLocalGroupName: + return m.OldLocalGroupName(ctx) + case task.FieldLocalGroupDescription: + return m.OldLocalGroupDescription(ctx) + case task.FieldLocalGroupSystem: + return m.OldLocalGroupSystem(ctx) + case task.FieldLocalGroupForce: + return m.OldLocalGroupForce(ctx) + case task.FieldLocalGroupMembers: + return m.OldLocalGroupMembers(ctx) + case task.FieldLocalGroupMembersToInclude: + return m.OldLocalGroupMembersToInclude(ctx) + case task.FieldLocalGroupMembersToExclude: + return m.OldLocalGroupMembersToExclude(ctx) + case task.FieldMsiProductid: + return m.OldMsiProductid(ctx) + case task.FieldMsiPath: + return m.OldMsiPath(ctx) + case task.FieldMsiArguments: + return m.OldMsiArguments(ctx) + case task.FieldMsiFileHash: + return m.OldMsiFileHash(ctx) + case task.FieldMsiFileHashAlg: + return m.OldMsiFileHashAlg(ctx) + case task.FieldMsiLogPath: + return m.OldMsiLogPath(ctx) + case task.FieldScript: + return m.OldScript(ctx) + case task.FieldScriptExecutable: + return m.OldScriptExecutable(ctx) + case task.FieldScriptCreates: + return m.OldScriptCreates(ctx) + case task.FieldScriptRun: + return m.OldScriptRun(ctx) + case task.FieldAgentType: + return m.OldAgentType(ctx) + case task.FieldWhen: + return m.OldWhen(ctx) + case task.FieldBrewUpdate: + return m.OldBrewUpdate(ctx) + case task.FieldBrewUpgradeAll: + return m.OldBrewUpgradeAll(ctx) + case task.FieldBrewUpgradeOptions: + return m.OldBrewUpgradeOptions(ctx) + case task.FieldBrewInstallOptions: + return m.OldBrewInstallOptions(ctx) + case task.FieldBrewGreedy: + return m.OldBrewGreedy(ctx) + case task.FieldPackageVersion: + return m.OldPackageVersion(ctx) + case task.FieldAptAllowDowngrade: + return m.OldAptAllowDowngrade(ctx) + case task.FieldAptDeb: + return m.OldAptDeb(ctx) + case task.FieldAptDpkgOptions: + return m.OldAptDpkgOptions(ctx) + case task.FieldAptFailOnAutoremove: + return m.OldAptFailOnAutoremove(ctx) + case task.FieldAptForce: + return m.OldAptForce(ctx) + case task.FieldAptInstallRecommends: + return m.OldAptInstallRecommends(ctx) + case task.FieldAptName: + return m.OldAptName(ctx) + case task.FieldAptOnlyUpgrade: + return m.OldAptOnlyUpgrade(ctx) + case task.FieldAptPurge: + return m.OldAptPurge(ctx) + case task.FieldAptUpdateCache: + return m.OldAptUpdateCache(ctx) + case task.FieldAptUpgradeType: + return m.OldAptUpgradeType(ctx) + case task.FieldVersion: + return m.OldVersion(ctx) + case task.FieldTenant: + return m.OldTenant(ctx) + case task.FieldNetbirdGroups: + return m.OldNetbirdGroups(ctx) + case task.FieldNetbirdAllowExtraDNSLabels: + return m.OldNetbirdAllowExtraDNSLabels(ctx) + } + return nil, fmt.Errorf("unknown Task field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TaskMutation) SetField(name string, value ent.Value) error { + switch name { + case task.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case task.FieldType: + v, ok := value.(task.Type) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case task.FieldPackageID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPackageID(v) + return nil + case task.FieldPackageName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPackageName(v) + return nil + case task.FieldPackageLatest: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPackageLatest(v) + return nil + case task.FieldRegistryKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistryKey(v) + return nil + case task.FieldRegistryKeyValueName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistryKeyValueName(v) + return nil + case task.FieldRegistryKeyValueType: + v, ok := value.(task.RegistryKeyValueType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistryKeyValueType(v) + return nil + case task.FieldRegistryKeyValueData: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistryKeyValueData(v) + return nil + case task.FieldRegistryHex: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistryHex(v) + return nil + case task.FieldRegistryForce: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegistryForce(v) + return nil + case task.FieldLocalUserUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserUsername(v) + return nil + case task.FieldLocalUserDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserDescription(v) + return nil + case task.FieldLocalUserDisable: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserDisable(v) + return nil + case task.FieldLocalUserFullname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserFullname(v) + return nil + case task.FieldLocalUserPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPassword(v) + return nil + case task.FieldLocalUserPasswordChangeNotAllowed: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordChangeNotAllowed(v) + return nil + case task.FieldLocalUserPasswordChangeRequired: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordChangeRequired(v) + return nil + case task.FieldLocalUserPasswordNeverExpires: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordNeverExpires(v) + return nil + case task.FieldLocalUserAppend: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserAppend(v) + return nil + case task.FieldLocalUserCreateHome: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserCreateHome(v) + return nil + case task.FieldLocalUserExpires: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserExpires(v) + return nil + case task.FieldLocalUserForce: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserForce(v) + return nil + case task.FieldLocalUserGenerateSSHKey: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserGenerateSSHKey(v) + return nil + case task.FieldLocalUserGroup: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserGroup(v) + return nil + case task.FieldLocalUserGroups: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserGroups(v) + return nil + case task.FieldLocalUserHome: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserHome(v) + return nil + case task.FieldLocalUserMoveHome: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserMoveHome(v) + return nil + case task.FieldLocalUserNonunique: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserNonunique(v) + return nil + case task.FieldLocalUserPasswordExpireAccountDisable: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordExpireAccountDisable(v) + return nil + case task.FieldLocalUserPasswordExpireMax: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordExpireMax(v) + return nil + case task.FieldLocalUserPasswordExpireMin: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordExpireMin(v) + return nil + case task.FieldLocalUserPasswordExpireWarn: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordExpireWarn(v) + return nil + case task.FieldLocalUserPasswordLock: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserPasswordLock(v) + return nil + case task.FieldLocalUserSeuser: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSeuser(v) + return nil + case task.FieldLocalUserShell: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserShell(v) + return nil + case task.FieldLocalUserSkeleton: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSkeleton(v) + return nil + case task.FieldLocalUserSystem: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSystem(v) + return nil + case task.FieldLocalUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserID(v) + return nil + case task.FieldLocalUserIDMax: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserIDMax(v) + return nil + case task.FieldLocalUserIDMin: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserIDMin(v) + return nil + case task.FieldLocalUserSSHKeyBits: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSSHKeyBits(v) + return nil + case task.FieldLocalUserSSHKeyComment: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSSHKeyComment(v) + return nil + case task.FieldLocalUserSSHKeyFile: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSSHKeyFile(v) + return nil + case task.FieldLocalUserSSHKeyPassphrase: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSSHKeyPassphrase(v) + return nil + case task.FieldLocalUserSSHKeyType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserSSHKeyType(v) + return nil + case task.FieldLocalUserUmask: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalUserUmask(v) + return nil + case task.FieldLocalGroupID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupID(v) + return nil + case task.FieldLocalGroupName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupName(v) + return nil + case task.FieldLocalGroupDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupDescription(v) + return nil + case task.FieldLocalGroupSystem: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupSystem(v) + return nil + case task.FieldLocalGroupForce: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupForce(v) + return nil + case task.FieldLocalGroupMembers: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupMembers(v) + return nil + case task.FieldLocalGroupMembersToInclude: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupMembersToInclude(v) + return nil + case task.FieldLocalGroupMembersToExclude: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLocalGroupMembersToExclude(v) + return nil + case task.FieldMsiProductid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsiProductid(v) + return nil + case task.FieldMsiPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsiPath(v) + return nil + case task.FieldMsiArguments: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsiArguments(v) + return nil + case task.FieldMsiFileHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsiFileHash(v) + return nil + case task.FieldMsiFileHashAlg: + v, ok := value.(task.MsiFileHashAlg) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsiFileHashAlg(v) + return nil + case task.FieldMsiLogPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsiLogPath(v) + return nil + case task.FieldScript: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScript(v) + return nil + case task.FieldScriptExecutable: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScriptExecutable(v) + return nil + case task.FieldScriptCreates: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScriptCreates(v) + return nil + case task.FieldScriptRun: + v, ok := value.(task.ScriptRun) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScriptRun(v) + return nil + case task.FieldAgentType: + v, ok := value.(task.AgentType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAgentType(v) + return nil + case task.FieldWhen: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWhen(v) + return nil + case task.FieldBrewUpdate: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrewUpdate(v) + return nil + case task.FieldBrewUpgradeAll: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrewUpgradeAll(v) + return nil + case task.FieldBrewUpgradeOptions: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrewUpgradeOptions(v) + return nil + case task.FieldBrewInstallOptions: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrewInstallOptions(v) + return nil + case task.FieldBrewGreedy: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBrewGreedy(v) + return nil + case task.FieldPackageVersion: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPackageVersion(v) + return nil + case task.FieldAptAllowDowngrade: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptAllowDowngrade(v) + return nil + case task.FieldAptDeb: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptDeb(v) + return nil + case task.FieldAptDpkgOptions: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptDpkgOptions(v) + return nil + case task.FieldAptFailOnAutoremove: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptFailOnAutoremove(v) + return nil + case task.FieldAptForce: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptForce(v) + return nil + case task.FieldAptInstallRecommends: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptInstallRecommends(v) + return nil + case task.FieldAptName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptName(v) + return nil + case task.FieldAptOnlyUpgrade: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptOnlyUpgrade(v) + return nil + case task.FieldAptPurge: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptPurge(v) + return nil + case task.FieldAptUpdateCache: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptUpdateCache(v) + return nil + case task.FieldAptUpgradeType: + v, ok := value.(task.AptUpgradeType) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAptUpgradeType(v) + return nil + case task.FieldVersion: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersion(v) + return nil + case task.FieldTenant: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenant(v) + return nil + case task.FieldNetbirdGroups: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNetbirdGroups(v) + return nil + case task.FieldNetbirdAllowExtraDNSLabels: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNetbirdAllowExtraDNSLabels(v) + return nil } - return + return fmt.Errorf("unknown Task field %s", name) } -// TagsIDs returns the "tags" edge IDs in the mutation. -func (m *TaskMutation) TagsIDs() (ids []int) { - for id := range m.tags { - ids = append(ids, id) +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *TaskMutation) AddedFields() []string { + var fields []string + if m.addversion != nil { + fields = append(fields, task.FieldVersion) } - return -} - -// ResetTags resets all changes to the "tags" edge. -func (m *TaskMutation) ResetTags() { - m.tags = nil - m.clearedtags = false - m.removedtags = nil -} - -// SetProfileID sets the "profile" edge to the Profile entity by id. -func (m *TaskMutation) SetProfileID(id int) { - m.profile = &id -} - -// ClearProfile clears the "profile" edge to the Profile entity. -func (m *TaskMutation) ClearProfile() { - m.clearedprofile = true -} - -// ProfileCleared reports if the "profile" edge to the Profile entity was cleared. -func (m *TaskMutation) ProfileCleared() bool { - return m.clearedprofile -} - -// ProfileID returns the "profile" edge ID in the mutation. -func (m *TaskMutation) ProfileID() (id int, exists bool) { - if m.profile != nil { - return *m.profile, true + if m.addtenant != nil { + fields = append(fields, task.FieldTenant) } - return + return fields } -// ProfileIDs returns the "profile" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ProfileID instead. It exists only for internal usage by the builders. -func (m *TaskMutation) ProfileIDs() (ids []int) { - if id := m.profile; id != nil { - ids = append(ids, *id) +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *TaskMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case task.FieldVersion: + return m.AddedVersion() + case task.FieldTenant: + return m.AddedTenant() } - return -} - -// ResetProfile resets all changes to the "profile" edge. -func (m *TaskMutation) ResetProfile() { - m.profile = nil - m.clearedprofile = false -} - -// Where appends a list predicates to the TaskMutation builder. -func (m *TaskMutation) Where(ps ...predicate.Task) { - m.predicates = append(m.predicates, ps...) + return nil, false } -// WhereP appends storage-level predicates to the TaskMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *TaskMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Task, len(ps)) - for i := range ps { - p[i] = ps[i] +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TaskMutation) AddField(name string, value ent.Value) error { + switch name { + case task.FieldVersion: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVersion(v) + return nil + case task.FieldTenant: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenant(v) + return nil } - m.Where(p...) -} - -// Op returns the operation name. -func (m *TaskMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *TaskMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Task). -func (m *TaskMutation) Type() string { - return m.typ + return fmt.Errorf("unknown Task numeric field %s", name) } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *TaskMutation) Fields() []string { - fields := make([]string, 0, 88) - if m.name != nil { - fields = append(fields, task.FieldName) - } - if m._type != nil { - fields = append(fields, task.FieldType) - } - if m.package_id != nil { +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *TaskMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(task.FieldPackageID) { fields = append(fields, task.FieldPackageID) } - if m.package_name != nil { + if m.FieldCleared(task.FieldPackageName) { fields = append(fields, task.FieldPackageName) } - if m.package_latest != nil { + if m.FieldCleared(task.FieldPackageLatest) { fields = append(fields, task.FieldPackageLatest) } - if m.registry_key != nil { + if m.FieldCleared(task.FieldRegistryKey) { fields = append(fields, task.FieldRegistryKey) } - if m.registry_key_value_name != nil { + if m.FieldCleared(task.FieldRegistryKeyValueName) { fields = append(fields, task.FieldRegistryKeyValueName) } - if m.registry_key_value_type != nil { + if m.FieldCleared(task.FieldRegistryKeyValueType) { fields = append(fields, task.FieldRegistryKeyValueType) } - if m.registry_key_value_data != nil { + if m.FieldCleared(task.FieldRegistryKeyValueData) { fields = append(fields, task.FieldRegistryKeyValueData) } - if m.registry_hex != nil { + if m.FieldCleared(task.FieldRegistryHex) { fields = append(fields, task.FieldRegistryHex) } - if m.registry_force != nil { + if m.FieldCleared(task.FieldRegistryForce) { fields = append(fields, task.FieldRegistryForce) } - if m.local_user_username != nil { + if m.FieldCleared(task.FieldLocalUserUsername) { fields = append(fields, task.FieldLocalUserUsername) } - if m.local_user_description != nil { + if m.FieldCleared(task.FieldLocalUserDescription) { fields = append(fields, task.FieldLocalUserDescription) } - if m.local_user_disable != nil { + if m.FieldCleared(task.FieldLocalUserDisable) { fields = append(fields, task.FieldLocalUserDisable) } - if m.local_user_fullname != nil { + if m.FieldCleared(task.FieldLocalUserFullname) { fields = append(fields, task.FieldLocalUserFullname) } - if m.local_user_password != nil { + if m.FieldCleared(task.FieldLocalUserPassword) { fields = append(fields, task.FieldLocalUserPassword) } - if m.local_user_password_change_not_allowed != nil { + if m.FieldCleared(task.FieldLocalUserPasswordChangeNotAllowed) { fields = append(fields, task.FieldLocalUserPasswordChangeNotAllowed) } - if m.local_user_password_change_required != nil { + if m.FieldCleared(task.FieldLocalUserPasswordChangeRequired) { fields = append(fields, task.FieldLocalUserPasswordChangeRequired) } - if m.local_user_password_never_expires != nil { + if m.FieldCleared(task.FieldLocalUserPasswordNeverExpires) { fields = append(fields, task.FieldLocalUserPasswordNeverExpires) } - if m.local_user_append != nil { + if m.FieldCleared(task.FieldLocalUserAppend) { fields = append(fields, task.FieldLocalUserAppend) } - if m.local_user_create_home != nil { + if m.FieldCleared(task.FieldLocalUserCreateHome) { fields = append(fields, task.FieldLocalUserCreateHome) } - if m.local_user_expires != nil { + if m.FieldCleared(task.FieldLocalUserExpires) { fields = append(fields, task.FieldLocalUserExpires) } - if m.local_user_force != nil { + if m.FieldCleared(task.FieldLocalUserForce) { fields = append(fields, task.FieldLocalUserForce) } - if m.local_user_generate_ssh_key != nil { + if m.FieldCleared(task.FieldLocalUserGenerateSSHKey) { fields = append(fields, task.FieldLocalUserGenerateSSHKey) } - if m.local_user_group != nil { + if m.FieldCleared(task.FieldLocalUserGroup) { fields = append(fields, task.FieldLocalUserGroup) } - if m.local_user_groups != nil { + if m.FieldCleared(task.FieldLocalUserGroups) { fields = append(fields, task.FieldLocalUserGroups) } - if m.local_user_home != nil { + if m.FieldCleared(task.FieldLocalUserHome) { fields = append(fields, task.FieldLocalUserHome) } - if m.local_user_move_home != nil { + if m.FieldCleared(task.FieldLocalUserMoveHome) { fields = append(fields, task.FieldLocalUserMoveHome) } - if m.local_user_nonunique != nil { + if m.FieldCleared(task.FieldLocalUserNonunique) { fields = append(fields, task.FieldLocalUserNonunique) } - if m.local_user_password_expire_account_disable != nil { + if m.FieldCleared(task.FieldLocalUserPasswordExpireAccountDisable) { fields = append(fields, task.FieldLocalUserPasswordExpireAccountDisable) } - if m.local_user_password_expire_max != nil { + if m.FieldCleared(task.FieldLocalUserPasswordExpireMax) { fields = append(fields, task.FieldLocalUserPasswordExpireMax) } - if m.local_user_password_expire_min != nil { + if m.FieldCleared(task.FieldLocalUserPasswordExpireMin) { fields = append(fields, task.FieldLocalUserPasswordExpireMin) } - if m.local_user_password_expire_warn != nil { + if m.FieldCleared(task.FieldLocalUserPasswordExpireWarn) { fields = append(fields, task.FieldLocalUserPasswordExpireWarn) } - if m.local_user_password_lock != nil { + if m.FieldCleared(task.FieldLocalUserPasswordLock) { fields = append(fields, task.FieldLocalUserPasswordLock) } - if m.local_user_seuser != nil { + if m.FieldCleared(task.FieldLocalUserSeuser) { fields = append(fields, task.FieldLocalUserSeuser) } - if m.local_user_shell != nil { + if m.FieldCleared(task.FieldLocalUserShell) { fields = append(fields, task.FieldLocalUserShell) } - if m.local_user_skeleton != nil { + if m.FieldCleared(task.FieldLocalUserSkeleton) { fields = append(fields, task.FieldLocalUserSkeleton) } - if m.local_user_system != nil { + if m.FieldCleared(task.FieldLocalUserSystem) { fields = append(fields, task.FieldLocalUserSystem) } - if m.local_user_id != nil { + if m.FieldCleared(task.FieldLocalUserID) { fields = append(fields, task.FieldLocalUserID) } - if m.local_user_id_max != nil { + if m.FieldCleared(task.FieldLocalUserIDMax) { fields = append(fields, task.FieldLocalUserIDMax) } - if m.local_user_id_min != nil { + if m.FieldCleared(task.FieldLocalUserIDMin) { fields = append(fields, task.FieldLocalUserIDMin) } - if m.local_user_ssh_key_bits != nil { + if m.FieldCleared(task.FieldLocalUserSSHKeyBits) { fields = append(fields, task.FieldLocalUserSSHKeyBits) } - if m.local_user_ssh_key_comment != nil { + if m.FieldCleared(task.FieldLocalUserSSHKeyComment) { fields = append(fields, task.FieldLocalUserSSHKeyComment) } - if m.local_user_ssh_key_file != nil { + if m.FieldCleared(task.FieldLocalUserSSHKeyFile) { fields = append(fields, task.FieldLocalUserSSHKeyFile) } - if m.local_user_ssh_key_passphrase != nil { + if m.FieldCleared(task.FieldLocalUserSSHKeyPassphrase) { fields = append(fields, task.FieldLocalUserSSHKeyPassphrase) } - if m.local_user_ssh_key_type != nil { + if m.FieldCleared(task.FieldLocalUserSSHKeyType) { fields = append(fields, task.FieldLocalUserSSHKeyType) } - if m.local_user_umask != nil { + if m.FieldCleared(task.FieldLocalUserUmask) { fields = append(fields, task.FieldLocalUserUmask) } - if m.local_group_id != nil { + if m.FieldCleared(task.FieldLocalGroupID) { fields = append(fields, task.FieldLocalGroupID) } - if m.local_group_name != nil { + if m.FieldCleared(task.FieldLocalGroupName) { fields = append(fields, task.FieldLocalGroupName) } - if m.local_group_description != nil { + if m.FieldCleared(task.FieldLocalGroupDescription) { fields = append(fields, task.FieldLocalGroupDescription) } - if m.local_group_system != nil { + if m.FieldCleared(task.FieldLocalGroupSystem) { fields = append(fields, task.FieldLocalGroupSystem) } - if m.local_group_force != nil { + if m.FieldCleared(task.FieldLocalGroupForce) { fields = append(fields, task.FieldLocalGroupForce) } - if m.local_group_members != nil { + if m.FieldCleared(task.FieldLocalGroupMembers) { fields = append(fields, task.FieldLocalGroupMembers) } - if m.local_group_members_to_include != nil { + if m.FieldCleared(task.FieldLocalGroupMembersToInclude) { fields = append(fields, task.FieldLocalGroupMembersToInclude) } - if m.local_group_members_to_exclude != nil { + if m.FieldCleared(task.FieldLocalGroupMembersToExclude) { fields = append(fields, task.FieldLocalGroupMembersToExclude) } - if m.msi_productid != nil { + if m.FieldCleared(task.FieldMsiProductid) { fields = append(fields, task.FieldMsiProductid) } - if m.msi_path != nil { + if m.FieldCleared(task.FieldMsiPath) { fields = append(fields, task.FieldMsiPath) } - if m.msi_arguments != nil { + if m.FieldCleared(task.FieldMsiArguments) { fields = append(fields, task.FieldMsiArguments) } - if m.msi_file_hash != nil { + if m.FieldCleared(task.FieldMsiFileHash) { fields = append(fields, task.FieldMsiFileHash) } - if m.msi_file_hash_alg != nil { + if m.FieldCleared(task.FieldMsiFileHashAlg) { fields = append(fields, task.FieldMsiFileHashAlg) } - if m.msi_log_path != nil { + if m.FieldCleared(task.FieldMsiLogPath) { fields = append(fields, task.FieldMsiLogPath) } - if m.script != nil { + if m.FieldCleared(task.FieldScript) { fields = append(fields, task.FieldScript) } - if m.script_executable != nil { + if m.FieldCleared(task.FieldScriptExecutable) { fields = append(fields, task.FieldScriptExecutable) } - if m.script_creates != nil { + if m.FieldCleared(task.FieldScriptCreates) { fields = append(fields, task.FieldScriptCreates) } - if m.script_run != nil { + if m.FieldCleared(task.FieldScriptRun) { fields = append(fields, task.FieldScriptRun) } - if m.agent_type != nil { + if m.FieldCleared(task.FieldAgentType) { fields = append(fields, task.FieldAgentType) } - if m.when != nil { + if m.FieldCleared(task.FieldWhen) { fields = append(fields, task.FieldWhen) } - if m.brew_update != nil { + if m.FieldCleared(task.FieldBrewUpdate) { fields = append(fields, task.FieldBrewUpdate) } - if m.brew_upgrade_all != nil { + if m.FieldCleared(task.FieldBrewUpgradeAll) { fields = append(fields, task.FieldBrewUpgradeAll) } - if m.brew_upgrade_options != nil { + if m.FieldCleared(task.FieldBrewUpgradeOptions) { fields = append(fields, task.FieldBrewUpgradeOptions) } - if m.brew_install_options != nil { + if m.FieldCleared(task.FieldBrewInstallOptions) { fields = append(fields, task.FieldBrewInstallOptions) } - if m.brew_greedy != nil { + if m.FieldCleared(task.FieldBrewGreedy) { fields = append(fields, task.FieldBrewGreedy) } - if m.package_version != nil { + if m.FieldCleared(task.FieldPackageVersion) { fields = append(fields, task.FieldPackageVersion) } - if m.apt_allow_downgrade != nil { + if m.FieldCleared(task.FieldAptAllowDowngrade) { fields = append(fields, task.FieldAptAllowDowngrade) } - if m.apt_deb != nil { + if m.FieldCleared(task.FieldAptDeb) { fields = append(fields, task.FieldAptDeb) } - if m.apt_dpkg_options != nil { + if m.FieldCleared(task.FieldAptDpkgOptions) { fields = append(fields, task.FieldAptDpkgOptions) } - if m.apt_fail_on_autoremove != nil { + if m.FieldCleared(task.FieldAptFailOnAutoremove) { fields = append(fields, task.FieldAptFailOnAutoremove) } - if m.apt_force != nil { + if m.FieldCleared(task.FieldAptForce) { fields = append(fields, task.FieldAptForce) } - if m.apt_install_recommends != nil { + if m.FieldCleared(task.FieldAptInstallRecommends) { fields = append(fields, task.FieldAptInstallRecommends) } - if m.apt_name != nil { + if m.FieldCleared(task.FieldAptName) { fields = append(fields, task.FieldAptName) } - if m.apt_only_upgrade != nil { + if m.FieldCleared(task.FieldAptOnlyUpgrade) { fields = append(fields, task.FieldAptOnlyUpgrade) } - if m.apt_purge != nil { - fields = append(fields, task.FieldAptPurge) - } - if m.apt_update_cache != nil { - fields = append(fields, task.FieldAptUpdateCache) - } - if m.apt_upgrade_type != nil { - fields = append(fields, task.FieldAptUpgradeType) - } - if m.version != nil { - fields = append(fields, task.FieldVersion) - } - if m.tenant != nil { - fields = append(fields, task.FieldTenant) - } - if m.netbird_groups != nil { - fields = append(fields, task.FieldNetbirdGroups) - } - if m.netbird_allow_extra_dns_labels != nil { - fields = append(fields, task.FieldNetbirdAllowExtraDNSLabels) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *TaskMutation) Field(name string) (ent.Value, bool) { - switch name { - case task.FieldName: - return m.Name() - case task.FieldType: - return m.GetType() - case task.FieldPackageID: - return m.PackageID() - case task.FieldPackageName: - return m.PackageName() - case task.FieldPackageLatest: - return m.PackageLatest() - case task.FieldRegistryKey: - return m.RegistryKey() - case task.FieldRegistryKeyValueName: - return m.RegistryKeyValueName() - case task.FieldRegistryKeyValueType: - return m.RegistryKeyValueType() - case task.FieldRegistryKeyValueData: - return m.RegistryKeyValueData() - case task.FieldRegistryHex: - return m.RegistryHex() - case task.FieldRegistryForce: - return m.RegistryForce() - case task.FieldLocalUserUsername: - return m.LocalUserUsername() - case task.FieldLocalUserDescription: - return m.LocalUserDescription() - case task.FieldLocalUserDisable: - return m.LocalUserDisable() - case task.FieldLocalUserFullname: - return m.LocalUserFullname() - case task.FieldLocalUserPassword: - return m.LocalUserPassword() - case task.FieldLocalUserPasswordChangeNotAllowed: - return m.LocalUserPasswordChangeNotAllowed() - case task.FieldLocalUserPasswordChangeRequired: - return m.LocalUserPasswordChangeRequired() - case task.FieldLocalUserPasswordNeverExpires: - return m.LocalUserPasswordNeverExpires() - case task.FieldLocalUserAppend: - return m.LocalUserAppend() - case task.FieldLocalUserCreateHome: - return m.LocalUserCreateHome() - case task.FieldLocalUserExpires: - return m.LocalUserExpires() - case task.FieldLocalUserForce: - return m.LocalUserForce() - case task.FieldLocalUserGenerateSSHKey: - return m.LocalUserGenerateSSHKey() - case task.FieldLocalUserGroup: - return m.LocalUserGroup() - case task.FieldLocalUserGroups: - return m.LocalUserGroups() - case task.FieldLocalUserHome: - return m.LocalUserHome() - case task.FieldLocalUserMoveHome: - return m.LocalUserMoveHome() - case task.FieldLocalUserNonunique: - return m.LocalUserNonunique() - case task.FieldLocalUserPasswordExpireAccountDisable: - return m.LocalUserPasswordExpireAccountDisable() - case task.FieldLocalUserPasswordExpireMax: - return m.LocalUserPasswordExpireMax() - case task.FieldLocalUserPasswordExpireMin: - return m.LocalUserPasswordExpireMin() - case task.FieldLocalUserPasswordExpireWarn: - return m.LocalUserPasswordExpireWarn() - case task.FieldLocalUserPasswordLock: - return m.LocalUserPasswordLock() - case task.FieldLocalUserSeuser: - return m.LocalUserSeuser() - case task.FieldLocalUserShell: - return m.LocalUserShell() - case task.FieldLocalUserSkeleton: - return m.LocalUserSkeleton() - case task.FieldLocalUserSystem: - return m.LocalUserSystem() - case task.FieldLocalUserID: - return m.LocalUserID() - case task.FieldLocalUserIDMax: - return m.LocalUserIDMax() - case task.FieldLocalUserIDMin: - return m.LocalUserIDMin() - case task.FieldLocalUserSSHKeyBits: - return m.LocalUserSSHKeyBits() - case task.FieldLocalUserSSHKeyComment: - return m.LocalUserSSHKeyComment() - case task.FieldLocalUserSSHKeyFile: - return m.LocalUserSSHKeyFile() - case task.FieldLocalUserSSHKeyPassphrase: - return m.LocalUserSSHKeyPassphrase() - case task.FieldLocalUserSSHKeyType: - return m.LocalUserSSHKeyType() - case task.FieldLocalUserUmask: - return m.LocalUserUmask() - case task.FieldLocalGroupID: - return m.LocalGroupID() - case task.FieldLocalGroupName: - return m.LocalGroupName() - case task.FieldLocalGroupDescription: - return m.LocalGroupDescription() - case task.FieldLocalGroupSystem: - return m.LocalGroupSystem() - case task.FieldLocalGroupForce: - return m.LocalGroupForce() - case task.FieldLocalGroupMembers: - return m.LocalGroupMembers() - case task.FieldLocalGroupMembersToInclude: - return m.LocalGroupMembersToInclude() - case task.FieldLocalGroupMembersToExclude: - return m.LocalGroupMembersToExclude() - case task.FieldMsiProductid: - return m.MsiProductid() - case task.FieldMsiPath: - return m.MsiPath() - case task.FieldMsiArguments: - return m.MsiArguments() - case task.FieldMsiFileHash: - return m.MsiFileHash() - case task.FieldMsiFileHashAlg: - return m.MsiFileHashAlg() - case task.FieldMsiLogPath: - return m.MsiLogPath() - case task.FieldScript: - return m.Script() - case task.FieldScriptExecutable: - return m.ScriptExecutable() - case task.FieldScriptCreates: - return m.ScriptCreates() - case task.FieldScriptRun: - return m.ScriptRun() - case task.FieldAgentType: - return m.AgentType() - case task.FieldWhen: - return m.When() - case task.FieldBrewUpdate: - return m.BrewUpdate() - case task.FieldBrewUpgradeAll: - return m.BrewUpgradeAll() - case task.FieldBrewUpgradeOptions: - return m.BrewUpgradeOptions() - case task.FieldBrewInstallOptions: - return m.BrewInstallOptions() - case task.FieldBrewGreedy: - return m.BrewGreedy() - case task.FieldPackageVersion: - return m.PackageVersion() - case task.FieldAptAllowDowngrade: - return m.AptAllowDowngrade() - case task.FieldAptDeb: - return m.AptDeb() - case task.FieldAptDpkgOptions: - return m.AptDpkgOptions() - case task.FieldAptFailOnAutoremove: - return m.AptFailOnAutoremove() - case task.FieldAptForce: - return m.AptForce() - case task.FieldAptInstallRecommends: - return m.AptInstallRecommends() - case task.FieldAptName: - return m.AptName() - case task.FieldAptOnlyUpgrade: - return m.AptOnlyUpgrade() - case task.FieldAptPurge: - return m.AptPurge() - case task.FieldAptUpdateCache: - return m.AptUpdateCache() - case task.FieldAptUpgradeType: - return m.AptUpgradeType() - case task.FieldVersion: - return m.Version() - case task.FieldTenant: - return m.Tenant() - case task.FieldNetbirdGroups: - return m.NetbirdGroups() - case task.FieldNetbirdAllowExtraDNSLabels: - return m.NetbirdAllowExtraDNSLabels() - } - return nil, false + if m.FieldCleared(task.FieldAptPurge) { + fields = append(fields, task.FieldAptPurge) + } + if m.FieldCleared(task.FieldAptUpdateCache) { + fields = append(fields, task.FieldAptUpdateCache) + } + if m.FieldCleared(task.FieldAptUpgradeType) { + fields = append(fields, task.FieldAptUpgradeType) + } + if m.FieldCleared(task.FieldVersion) { + fields = append(fields, task.FieldVersion) + } + if m.FieldCleared(task.FieldTenant) { + fields = append(fields, task.FieldTenant) + } + if m.FieldCleared(task.FieldNetbirdGroups) { + fields = append(fields, task.FieldNetbirdGroups) + } + if m.FieldCleared(task.FieldNetbirdAllowExtraDNSLabels) { + fields = append(fields, task.FieldNetbirdAllowExtraDNSLabels) + } + return fields } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *TaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *TaskMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *TaskMutation) ClearField(name string) error { switch name { - case task.FieldName: - return m.OldName(ctx) - case task.FieldType: - return m.OldType(ctx) case task.FieldPackageID: - return m.OldPackageID(ctx) + m.ClearPackageID() + return nil case task.FieldPackageName: - return m.OldPackageName(ctx) + m.ClearPackageName() + return nil case task.FieldPackageLatest: - return m.OldPackageLatest(ctx) + m.ClearPackageLatest() + return nil case task.FieldRegistryKey: - return m.OldRegistryKey(ctx) + m.ClearRegistryKey() + return nil case task.FieldRegistryKeyValueName: - return m.OldRegistryKeyValueName(ctx) + m.ClearRegistryKeyValueName() + return nil case task.FieldRegistryKeyValueType: - return m.OldRegistryKeyValueType(ctx) + m.ClearRegistryKeyValueType() + return nil case task.FieldRegistryKeyValueData: - return m.OldRegistryKeyValueData(ctx) + m.ClearRegistryKeyValueData() + return nil case task.FieldRegistryHex: - return m.OldRegistryHex(ctx) + m.ClearRegistryHex() + return nil case task.FieldRegistryForce: - return m.OldRegistryForce(ctx) + m.ClearRegistryForce() + return nil case task.FieldLocalUserUsername: - return m.OldLocalUserUsername(ctx) + m.ClearLocalUserUsername() + return nil case task.FieldLocalUserDescription: - return m.OldLocalUserDescription(ctx) + m.ClearLocalUserDescription() + return nil case task.FieldLocalUserDisable: - return m.OldLocalUserDisable(ctx) + m.ClearLocalUserDisable() + return nil case task.FieldLocalUserFullname: - return m.OldLocalUserFullname(ctx) + m.ClearLocalUserFullname() + return nil case task.FieldLocalUserPassword: - return m.OldLocalUserPassword(ctx) + m.ClearLocalUserPassword() + return nil case task.FieldLocalUserPasswordChangeNotAllowed: - return m.OldLocalUserPasswordChangeNotAllowed(ctx) + m.ClearLocalUserPasswordChangeNotAllowed() + return nil case task.FieldLocalUserPasswordChangeRequired: - return m.OldLocalUserPasswordChangeRequired(ctx) + m.ClearLocalUserPasswordChangeRequired() + return nil case task.FieldLocalUserPasswordNeverExpires: - return m.OldLocalUserPasswordNeverExpires(ctx) + m.ClearLocalUserPasswordNeverExpires() + return nil case task.FieldLocalUserAppend: - return m.OldLocalUserAppend(ctx) + m.ClearLocalUserAppend() + return nil case task.FieldLocalUserCreateHome: - return m.OldLocalUserCreateHome(ctx) + m.ClearLocalUserCreateHome() + return nil case task.FieldLocalUserExpires: - return m.OldLocalUserExpires(ctx) + m.ClearLocalUserExpires() + return nil case task.FieldLocalUserForce: - return m.OldLocalUserForce(ctx) + m.ClearLocalUserForce() + return nil case task.FieldLocalUserGenerateSSHKey: - return m.OldLocalUserGenerateSSHKey(ctx) + m.ClearLocalUserGenerateSSHKey() + return nil case task.FieldLocalUserGroup: - return m.OldLocalUserGroup(ctx) + m.ClearLocalUserGroup() + return nil case task.FieldLocalUserGroups: - return m.OldLocalUserGroups(ctx) + m.ClearLocalUserGroups() + return nil case task.FieldLocalUserHome: - return m.OldLocalUserHome(ctx) + m.ClearLocalUserHome() + return nil case task.FieldLocalUserMoveHome: - return m.OldLocalUserMoveHome(ctx) + m.ClearLocalUserMoveHome() + return nil case task.FieldLocalUserNonunique: - return m.OldLocalUserNonunique(ctx) + m.ClearLocalUserNonunique() + return nil case task.FieldLocalUserPasswordExpireAccountDisable: - return m.OldLocalUserPasswordExpireAccountDisable(ctx) + m.ClearLocalUserPasswordExpireAccountDisable() + return nil case task.FieldLocalUserPasswordExpireMax: - return m.OldLocalUserPasswordExpireMax(ctx) + m.ClearLocalUserPasswordExpireMax() + return nil case task.FieldLocalUserPasswordExpireMin: - return m.OldLocalUserPasswordExpireMin(ctx) + m.ClearLocalUserPasswordExpireMin() + return nil case task.FieldLocalUserPasswordExpireWarn: - return m.OldLocalUserPasswordExpireWarn(ctx) + m.ClearLocalUserPasswordExpireWarn() + return nil case task.FieldLocalUserPasswordLock: - return m.OldLocalUserPasswordLock(ctx) + m.ClearLocalUserPasswordLock() + return nil case task.FieldLocalUserSeuser: - return m.OldLocalUserSeuser(ctx) + m.ClearLocalUserSeuser() + return nil case task.FieldLocalUserShell: - return m.OldLocalUserShell(ctx) + m.ClearLocalUserShell() + return nil case task.FieldLocalUserSkeleton: - return m.OldLocalUserSkeleton(ctx) + m.ClearLocalUserSkeleton() + return nil case task.FieldLocalUserSystem: - return m.OldLocalUserSystem(ctx) + m.ClearLocalUserSystem() + return nil case task.FieldLocalUserID: - return m.OldLocalUserID(ctx) + m.ClearLocalUserID() + return nil case task.FieldLocalUserIDMax: - return m.OldLocalUserIDMax(ctx) + m.ClearLocalUserIDMax() + return nil case task.FieldLocalUserIDMin: - return m.OldLocalUserIDMin(ctx) + m.ClearLocalUserIDMin() + return nil case task.FieldLocalUserSSHKeyBits: - return m.OldLocalUserSSHKeyBits(ctx) + m.ClearLocalUserSSHKeyBits() + return nil case task.FieldLocalUserSSHKeyComment: - return m.OldLocalUserSSHKeyComment(ctx) + m.ClearLocalUserSSHKeyComment() + return nil case task.FieldLocalUserSSHKeyFile: - return m.OldLocalUserSSHKeyFile(ctx) + m.ClearLocalUserSSHKeyFile() + return nil case task.FieldLocalUserSSHKeyPassphrase: - return m.OldLocalUserSSHKeyPassphrase(ctx) + m.ClearLocalUserSSHKeyPassphrase() + return nil case task.FieldLocalUserSSHKeyType: - return m.OldLocalUserSSHKeyType(ctx) + m.ClearLocalUserSSHKeyType() + return nil case task.FieldLocalUserUmask: - return m.OldLocalUserUmask(ctx) + m.ClearLocalUserUmask() + return nil case task.FieldLocalGroupID: - return m.OldLocalGroupID(ctx) + m.ClearLocalGroupID() + return nil case task.FieldLocalGroupName: - return m.OldLocalGroupName(ctx) + m.ClearLocalGroupName() + return nil case task.FieldLocalGroupDescription: - return m.OldLocalGroupDescription(ctx) + m.ClearLocalGroupDescription() + return nil case task.FieldLocalGroupSystem: - return m.OldLocalGroupSystem(ctx) + m.ClearLocalGroupSystem() + return nil case task.FieldLocalGroupForce: - return m.OldLocalGroupForce(ctx) + m.ClearLocalGroupForce() + return nil case task.FieldLocalGroupMembers: - return m.OldLocalGroupMembers(ctx) + m.ClearLocalGroupMembers() + return nil case task.FieldLocalGroupMembersToInclude: - return m.OldLocalGroupMembersToInclude(ctx) + m.ClearLocalGroupMembersToInclude() + return nil case task.FieldLocalGroupMembersToExclude: - return m.OldLocalGroupMembersToExclude(ctx) + m.ClearLocalGroupMembersToExclude() + return nil case task.FieldMsiProductid: - return m.OldMsiProductid(ctx) + m.ClearMsiProductid() + return nil case task.FieldMsiPath: - return m.OldMsiPath(ctx) + m.ClearMsiPath() + return nil case task.FieldMsiArguments: - return m.OldMsiArguments(ctx) + m.ClearMsiArguments() + return nil case task.FieldMsiFileHash: - return m.OldMsiFileHash(ctx) + m.ClearMsiFileHash() + return nil case task.FieldMsiFileHashAlg: - return m.OldMsiFileHashAlg(ctx) + m.ClearMsiFileHashAlg() + return nil case task.FieldMsiLogPath: - return m.OldMsiLogPath(ctx) + m.ClearMsiLogPath() + return nil case task.FieldScript: - return m.OldScript(ctx) + m.ClearScript() + return nil case task.FieldScriptExecutable: - return m.OldScriptExecutable(ctx) + m.ClearScriptExecutable() + return nil case task.FieldScriptCreates: - return m.OldScriptCreates(ctx) + m.ClearScriptCreates() + return nil case task.FieldScriptRun: - return m.OldScriptRun(ctx) + m.ClearScriptRun() + return nil case task.FieldAgentType: - return m.OldAgentType(ctx) + m.ClearAgentType() + return nil case task.FieldWhen: - return m.OldWhen(ctx) + m.ClearWhen() + return nil case task.FieldBrewUpdate: - return m.OldBrewUpdate(ctx) + m.ClearBrewUpdate() + return nil case task.FieldBrewUpgradeAll: - return m.OldBrewUpgradeAll(ctx) + m.ClearBrewUpgradeAll() + return nil case task.FieldBrewUpgradeOptions: - return m.OldBrewUpgradeOptions(ctx) + m.ClearBrewUpgradeOptions() + return nil case task.FieldBrewInstallOptions: - return m.OldBrewInstallOptions(ctx) + m.ClearBrewInstallOptions() + return nil case task.FieldBrewGreedy: - return m.OldBrewGreedy(ctx) + m.ClearBrewGreedy() + return nil case task.FieldPackageVersion: - return m.OldPackageVersion(ctx) + m.ClearPackageVersion() + return nil case task.FieldAptAllowDowngrade: - return m.OldAptAllowDowngrade(ctx) + m.ClearAptAllowDowngrade() + return nil case task.FieldAptDeb: - return m.OldAptDeb(ctx) + m.ClearAptDeb() + return nil case task.FieldAptDpkgOptions: - return m.OldAptDpkgOptions(ctx) + m.ClearAptDpkgOptions() + return nil case task.FieldAptFailOnAutoremove: - return m.OldAptFailOnAutoremove(ctx) + m.ClearAptFailOnAutoremove() + return nil case task.FieldAptForce: - return m.OldAptForce(ctx) + m.ClearAptForce() + return nil case task.FieldAptInstallRecommends: - return m.OldAptInstallRecommends(ctx) + m.ClearAptInstallRecommends() + return nil case task.FieldAptName: - return m.OldAptName(ctx) + m.ClearAptName() + return nil case task.FieldAptOnlyUpgrade: - return m.OldAptOnlyUpgrade(ctx) + m.ClearAptOnlyUpgrade() + return nil case task.FieldAptPurge: - return m.OldAptPurge(ctx) + m.ClearAptPurge() + return nil case task.FieldAptUpdateCache: - return m.OldAptUpdateCache(ctx) + m.ClearAptUpdateCache() + return nil case task.FieldAptUpgradeType: - return m.OldAptUpgradeType(ctx) + m.ClearAptUpgradeType() + return nil case task.FieldVersion: - return m.OldVersion(ctx) + m.ClearVersion() + return nil case task.FieldTenant: - return m.OldTenant(ctx) + m.ClearTenant() + return nil case task.FieldNetbirdGroups: - return m.OldNetbirdGroups(ctx) + m.ClearNetbirdGroups() + return nil case task.FieldNetbirdAllowExtraDNSLabels: - return m.OldNetbirdAllowExtraDNSLabels(ctx) + m.ClearNetbirdAllowExtraDNSLabels() + return nil } - return nil, fmt.Errorf("unknown Task field %s", name) + return fmt.Errorf("unknown Task nullable field %s", name) } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *TaskMutation) SetField(name string, value ent.Value) error { +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *TaskMutation) ResetField(name string) error { switch name { case task.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) + m.ResetName() return nil case task.FieldType: - v, ok := value.(task.Type) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) + m.ResetType() return nil case task.FieldPackageID: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPackageID(v) + m.ResetPackageID() return nil case task.FieldPackageName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPackageName(v) + m.ResetPackageName() return nil case task.FieldPackageLatest: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPackageLatest(v) + m.ResetPackageLatest() return nil case task.FieldRegistryKey: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistryKey(v) + m.ResetRegistryKey() return nil case task.FieldRegistryKeyValueName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistryKeyValueName(v) + m.ResetRegistryKeyValueName() return nil case task.FieldRegistryKeyValueType: - v, ok := value.(task.RegistryKeyValueType) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistryKeyValueType(v) + m.ResetRegistryKeyValueType() return nil case task.FieldRegistryKeyValueData: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistryKeyValueData(v) + m.ResetRegistryKeyValueData() return nil case task.FieldRegistryHex: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistryHex(v) + m.ResetRegistryHex() return nil case task.FieldRegistryForce: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegistryForce(v) + m.ResetRegistryForce() return nil case task.FieldLocalUserUsername: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserUsername(v) + m.ResetLocalUserUsername() return nil case task.FieldLocalUserDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserDescription(v) + m.ResetLocalUserDescription() return nil case task.FieldLocalUserDisable: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserDisable(v) + m.ResetLocalUserDisable() return nil case task.FieldLocalUserFullname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserFullname(v) + m.ResetLocalUserFullname() return nil case task.FieldLocalUserPassword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPassword(v) + m.ResetLocalUserPassword() return nil case task.FieldLocalUserPasswordChangeNotAllowed: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordChangeNotAllowed(v) + m.ResetLocalUserPasswordChangeNotAllowed() return nil case task.FieldLocalUserPasswordChangeRequired: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordChangeRequired(v) + m.ResetLocalUserPasswordChangeRequired() return nil case task.FieldLocalUserPasswordNeverExpires: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordNeverExpires(v) + m.ResetLocalUserPasswordNeverExpires() return nil case task.FieldLocalUserAppend: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserAppend(v) + m.ResetLocalUserAppend() return nil case task.FieldLocalUserCreateHome: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserCreateHome(v) + m.ResetLocalUserCreateHome() return nil case task.FieldLocalUserExpires: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserExpires(v) + m.ResetLocalUserExpires() return nil case task.FieldLocalUserForce: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserForce(v) + m.ResetLocalUserForce() return nil case task.FieldLocalUserGenerateSSHKey: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserGenerateSSHKey(v) + m.ResetLocalUserGenerateSSHKey() return nil case task.FieldLocalUserGroup: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserGroup(v) + m.ResetLocalUserGroup() return nil case task.FieldLocalUserGroups: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserGroups(v) + m.ResetLocalUserGroups() return nil case task.FieldLocalUserHome: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserHome(v) + m.ResetLocalUserHome() return nil case task.FieldLocalUserMoveHome: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserMoveHome(v) + m.ResetLocalUserMoveHome() return nil case task.FieldLocalUserNonunique: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserNonunique(v) + m.ResetLocalUserNonunique() return nil case task.FieldLocalUserPasswordExpireAccountDisable: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordExpireAccountDisable(v) + m.ResetLocalUserPasswordExpireAccountDisable() return nil case task.FieldLocalUserPasswordExpireMax: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordExpireMax(v) + m.ResetLocalUserPasswordExpireMax() return nil case task.FieldLocalUserPasswordExpireMin: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordExpireMin(v) + m.ResetLocalUserPasswordExpireMin() return nil case task.FieldLocalUserPasswordExpireWarn: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordExpireWarn(v) - return nil - case task.FieldLocalUserPasswordLock: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserPasswordLock(v) + m.ResetLocalUserPasswordExpireWarn() + return nil + case task.FieldLocalUserPasswordLock: + m.ResetLocalUserPasswordLock() return nil case task.FieldLocalUserSeuser: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSeuser(v) + m.ResetLocalUserSeuser() return nil case task.FieldLocalUserShell: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserShell(v) + m.ResetLocalUserShell() return nil case task.FieldLocalUserSkeleton: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSkeleton(v) + m.ResetLocalUserSkeleton() return nil case task.FieldLocalUserSystem: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSystem(v) + m.ResetLocalUserSystem() return nil case task.FieldLocalUserID: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserID(v) + m.ResetLocalUserID() return nil case task.FieldLocalUserIDMax: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserIDMax(v) + m.ResetLocalUserIDMax() return nil case task.FieldLocalUserIDMin: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserIDMin(v) + m.ResetLocalUserIDMin() return nil case task.FieldLocalUserSSHKeyBits: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSSHKeyBits(v) + m.ResetLocalUserSSHKeyBits() return nil case task.FieldLocalUserSSHKeyComment: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSSHKeyComment(v) + m.ResetLocalUserSSHKeyComment() return nil case task.FieldLocalUserSSHKeyFile: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSSHKeyFile(v) + m.ResetLocalUserSSHKeyFile() return nil case task.FieldLocalUserSSHKeyPassphrase: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSSHKeyPassphrase(v) + m.ResetLocalUserSSHKeyPassphrase() return nil case task.FieldLocalUserSSHKeyType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserSSHKeyType(v) + m.ResetLocalUserSSHKeyType() return nil case task.FieldLocalUserUmask: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalUserUmask(v) + m.ResetLocalUserUmask() return nil case task.FieldLocalGroupID: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupID(v) + m.ResetLocalGroupID() return nil case task.FieldLocalGroupName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupName(v) + m.ResetLocalGroupName() return nil case task.FieldLocalGroupDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupDescription(v) + m.ResetLocalGroupDescription() return nil case task.FieldLocalGroupSystem: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupSystem(v) + m.ResetLocalGroupSystem() return nil case task.FieldLocalGroupForce: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupForce(v) + m.ResetLocalGroupForce() return nil case task.FieldLocalGroupMembers: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupMembers(v) + m.ResetLocalGroupMembers() return nil case task.FieldLocalGroupMembersToInclude: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupMembersToInclude(v) + m.ResetLocalGroupMembersToInclude() return nil case task.FieldLocalGroupMembersToExclude: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLocalGroupMembersToExclude(v) + m.ResetLocalGroupMembersToExclude() return nil case task.FieldMsiProductid: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMsiProductid(v) + m.ResetMsiProductid() return nil case task.FieldMsiPath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMsiPath(v) + m.ResetMsiPath() return nil case task.FieldMsiArguments: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMsiArguments(v) + m.ResetMsiArguments() return nil case task.FieldMsiFileHash: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMsiFileHash(v) + m.ResetMsiFileHash() return nil case task.FieldMsiFileHashAlg: - v, ok := value.(task.MsiFileHashAlg) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMsiFileHashAlg(v) + m.ResetMsiFileHashAlg() return nil case task.FieldMsiLogPath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMsiLogPath(v) + m.ResetMsiLogPath() return nil case task.FieldScript: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetScript(v) + m.ResetScript() return nil case task.FieldScriptExecutable: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetScriptExecutable(v) + m.ResetScriptExecutable() return nil case task.FieldScriptCreates: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetScriptCreates(v) + m.ResetScriptCreates() return nil case task.FieldScriptRun: - v, ok := value.(task.ScriptRun) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetScriptRun(v) + m.ResetScriptRun() return nil case task.FieldAgentType: - v, ok := value.(task.AgentType) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAgentType(v) + m.ResetAgentType() return nil case task.FieldWhen: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetWhen(v) + m.ResetWhen() return nil case task.FieldBrewUpdate: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBrewUpdate(v) + m.ResetBrewUpdate() return nil case task.FieldBrewUpgradeAll: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBrewUpgradeAll(v) + m.ResetBrewUpgradeAll() return nil case task.FieldBrewUpgradeOptions: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBrewUpgradeOptions(v) + m.ResetBrewUpgradeOptions() return nil case task.FieldBrewInstallOptions: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBrewInstallOptions(v) + m.ResetBrewInstallOptions() return nil case task.FieldBrewGreedy: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBrewGreedy(v) + m.ResetBrewGreedy() return nil case task.FieldPackageVersion: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPackageVersion(v) + m.ResetPackageVersion() return nil case task.FieldAptAllowDowngrade: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptAllowDowngrade(v) + m.ResetAptAllowDowngrade() return nil case task.FieldAptDeb: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptDeb(v) + m.ResetAptDeb() return nil case task.FieldAptDpkgOptions: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptDpkgOptions(v) + m.ResetAptDpkgOptions() return nil case task.FieldAptFailOnAutoremove: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptFailOnAutoremove(v) + m.ResetAptFailOnAutoremove() return nil case task.FieldAptForce: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptForce(v) + m.ResetAptForce() return nil case task.FieldAptInstallRecommends: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptInstallRecommends(v) + m.ResetAptInstallRecommends() return nil case task.FieldAptName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptName(v) + m.ResetAptName() return nil case task.FieldAptOnlyUpgrade: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptOnlyUpgrade(v) + m.ResetAptOnlyUpgrade() return nil case task.FieldAptPurge: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptPurge(v) + m.ResetAptPurge() return nil case task.FieldAptUpdateCache: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptUpdateCache(v) + m.ResetAptUpdateCache() return nil case task.FieldAptUpgradeType: - v, ok := value.(task.AptUpgradeType) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAptUpgradeType(v) + m.ResetAptUpgradeType() return nil case task.FieldVersion: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVersion(v) + m.ResetVersion() return nil case task.FieldTenant: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTenant(v) + m.ResetTenant() return nil case task.FieldNetbirdGroups: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNetbirdGroups(v) + m.ResetNetbirdGroups() return nil case task.FieldNetbirdAllowExtraDNSLabels: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNetbirdAllowExtraDNSLabels(v) + m.ResetNetbirdAllowExtraDNSLabels() return nil } return fmt.Errorf("unknown Task field %s", name) } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *TaskMutation) AddedFields() []string { - var fields []string - if m.addversion != nil { - fields = append(fields, task.FieldVersion) +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *TaskMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.tags != nil { + edges = append(edges, task.EdgeTags) } - if m.addtenant != nil { - fields = append(fields, task.FieldTenant) + if m.profile != nil { + edges = append(edges, task.EdgeProfile) } - return fields + return edges } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *TaskMutation) AddedField(name string) (ent.Value, bool) { +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *TaskMutation) AddedIDs(name string) []ent.Value { switch name { - case task.FieldVersion: - return m.AddedVersion() - case task.FieldTenant: - return m.AddedTenant() + case task.EdgeTags: + ids := make([]ent.Value, 0, len(m.tags)) + for id := range m.tags { + ids = append(ids, id) + } + return ids + case task.EdgeProfile: + if id := m.profile; id != nil { + return []ent.Value{*id} + } } - return nil, false + return nil } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *TaskMutation) AddField(name string, value ent.Value) error { +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *TaskMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedtags != nil { + edges = append(edges, task.EdgeTags) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *TaskMutation) RemovedIDs(name string) []ent.Value { switch name { - case task.FieldVersion: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddVersion(v) - return nil - case task.FieldTenant: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) + case task.EdgeTags: + ids := make([]ent.Value, 0, len(m.removedtags)) + for id := range m.removedtags { + ids = append(ids, id) } - m.AddTenant(v) - return nil + return ids } - return fmt.Errorf("unknown Task numeric field %s", name) + return nil } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *TaskMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(task.FieldPackageID) { - fields = append(fields, task.FieldPackageID) - } - if m.FieldCleared(task.FieldPackageName) { - fields = append(fields, task.FieldPackageName) - } - if m.FieldCleared(task.FieldPackageLatest) { - fields = append(fields, task.FieldPackageLatest) - } - if m.FieldCleared(task.FieldRegistryKey) { - fields = append(fields, task.FieldRegistryKey) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *TaskMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedtags { + edges = append(edges, task.EdgeTags) } - if m.FieldCleared(task.FieldRegistryKeyValueName) { - fields = append(fields, task.FieldRegistryKeyValueName) + if m.clearedprofile { + edges = append(edges, task.EdgeProfile) } - if m.FieldCleared(task.FieldRegistryKeyValueType) { - fields = append(fields, task.FieldRegistryKeyValueType) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *TaskMutation) EdgeCleared(name string) bool { + switch name { + case task.EdgeTags: + return m.clearedtags + case task.EdgeProfile: + return m.clearedprofile } - if m.FieldCleared(task.FieldRegistryKeyValueData) { - fields = append(fields, task.FieldRegistryKeyValueData) + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *TaskMutation) ClearEdge(name string) error { + switch name { + case task.EdgeProfile: + m.ClearProfile() + return nil } - if m.FieldCleared(task.FieldRegistryHex) { - fields = append(fields, task.FieldRegistryHex) + return fmt.Errorf("unknown Task unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *TaskMutation) ResetEdge(name string) error { + switch name { + case task.EdgeTags: + m.ResetTags() + return nil + case task.EdgeProfile: + m.ResetProfile() + return nil } - if m.FieldCleared(task.FieldRegistryForce) { - fields = append(fields, task.FieldRegistryForce) + return fmt.Errorf("unknown Task edge %s", name) +} + +// TenantMutation represents an operation that mutates the Tenant nodes in the graph. +type TenantMutation struct { + config + op Op + typ string + id *int + description *string + is_default *bool + oidc_org_id *string + oidc_default_role *tenant.OidcDefaultRole + created *time.Time + modified *time.Time + clearedFields map[string]struct{} + sites map[int]struct{} + removedsites map[int]struct{} + clearedsites bool + settings *int + clearedsettings bool + tags map[int]struct{} + removedtags map[int]struct{} + clearedtags bool + metadata map[int]struct{} + removedmetadata map[int]struct{} + clearedmetadata bool + rustdesk map[int]struct{} + removedrustdesk map[int]struct{} + clearedrustdesk bool + netbird *int + clearednetbird bool + user_tenants map[int]struct{} + removeduser_tenants map[int]struct{} + cleareduser_tenants bool + enrollment_tokens map[int]struct{} + removedenrollment_tokens map[int]struct{} + clearedenrollment_tokens bool + done bool + oldValue func(context.Context) (*Tenant, error) + predicates []predicate.Tenant +} + +var _ ent.Mutation = (*TenantMutation)(nil) + +// tenantOption allows management of the mutation configuration using functional options. +type tenantOption func(*TenantMutation) + +// newTenantMutation creates new mutation for the Tenant entity. +func newTenantMutation(c config, op Op, opts ...tenantOption) *TenantMutation { + m := &TenantMutation{ + config: c, + op: op, + typ: TypeTenant, + clearedFields: make(map[string]struct{}), } - if m.FieldCleared(task.FieldLocalUserUsername) { - fields = append(fields, task.FieldLocalUserUsername) + for _, opt := range opts { + opt(m) } - if m.FieldCleared(task.FieldLocalUserDescription) { - fields = append(fields, task.FieldLocalUserDescription) + return m +} + +// withTenantID sets the ID field of the mutation. +func withTenantID(id int) tenantOption { + return func(m *TenantMutation) { + var ( + err error + once sync.Once + value *Tenant + ) + m.oldValue = func(ctx context.Context) (*Tenant, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Tenant.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - if m.FieldCleared(task.FieldLocalUserDisable) { - fields = append(fields, task.FieldLocalUserDisable) +} + +// withTenant sets the old Tenant of the mutation. +func withTenant(node *Tenant) tenantOption { + return func(m *TenantMutation) { + m.oldValue = func(context.Context) (*Tenant, error) { + return node, nil + } + m.id = &node.ID } - if m.FieldCleared(task.FieldLocalUserFullname) { - fields = append(fields, task.FieldLocalUserFullname) +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m TenantMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m TenantMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") } - if m.FieldCleared(task.FieldLocalUserPassword) { - fields = append(fields, task.FieldLocalUserPassword) + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *TenantMutation) ID() (id int, exists bool) { + if m.id == nil { + return } - if m.FieldCleared(task.FieldLocalUserPasswordChangeNotAllowed) { - fields = append(fields, task.FieldLocalUserPasswordChangeNotAllowed) + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *TenantMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Tenant.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } - if m.FieldCleared(task.FieldLocalUserPasswordChangeRequired) { - fields = append(fields, task.FieldLocalUserPasswordChangeRequired) +} + +// SetDescription sets the "description" field. +func (m *TenantMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *TenantMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return } - if m.FieldCleared(task.FieldLocalUserPasswordNeverExpires) { - fields = append(fields, task.FieldLocalUserPasswordNeverExpires) + return *v, true +} + +// OldDescription returns the old "description" field's value of the Tenant entity. +// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TenantMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } - if m.FieldCleared(task.FieldLocalUserAppend) { - fields = append(fields, task.FieldLocalUserAppend) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") } - if m.FieldCleared(task.FieldLocalUserCreateHome) { - fields = append(fields, task.FieldLocalUserCreateHome) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) } - if m.FieldCleared(task.FieldLocalUserExpires) { - fields = append(fields, task.FieldLocalUserExpires) + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *TenantMutation) ClearDescription() { + m.description = nil + m.clearedFields[tenant.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *TenantMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[tenant.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *TenantMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, tenant.FieldDescription) +} + +// SetIsDefault sets the "is_default" field. +func (m *TenantMutation) SetIsDefault(b bool) { + m.is_default = &b +} + +// IsDefault returns the value of the "is_default" field in the mutation. +func (m *TenantMutation) IsDefault() (r bool, exists bool) { + v := m.is_default + if v == nil { + return } - if m.FieldCleared(task.FieldLocalUserForce) { - fields = append(fields, task.FieldLocalUserForce) + return *v, true +} + +// OldIsDefault returns the old "is_default" field's value of the Tenant entity. +// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TenantMutation) OldIsDefault(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") } - if m.FieldCleared(task.FieldLocalUserGenerateSSHKey) { - fields = append(fields, task.FieldLocalUserGenerateSSHKey) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDefault requires an ID field in the mutation") } - if m.FieldCleared(task.FieldLocalUserGroup) { - fields = append(fields, task.FieldLocalUserGroup) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) } - if m.FieldCleared(task.FieldLocalUserGroups) { - fields = append(fields, task.FieldLocalUserGroups) + return oldValue.IsDefault, nil +} + +// ClearIsDefault clears the value of the "is_default" field. +func (m *TenantMutation) ClearIsDefault() { + m.is_default = nil + m.clearedFields[tenant.FieldIsDefault] = struct{}{} +} + +// IsDefaultCleared returns if the "is_default" field was cleared in this mutation. +func (m *TenantMutation) IsDefaultCleared() bool { + _, ok := m.clearedFields[tenant.FieldIsDefault] + return ok +} + +// ResetIsDefault resets all changes to the "is_default" field. +func (m *TenantMutation) ResetIsDefault() { + m.is_default = nil + delete(m.clearedFields, tenant.FieldIsDefault) +} + +// SetOidcOrgID sets the "oidc_org_id" field. +func (m *TenantMutation) SetOidcOrgID(s string) { + m.oidc_org_id = &s +} + +// OidcOrgID returns the value of the "oidc_org_id" field in the mutation. +func (m *TenantMutation) OidcOrgID() (r string, exists bool) { + v := m.oidc_org_id + if v == nil { + return } - if m.FieldCleared(task.FieldLocalUserHome) { - fields = append(fields, task.FieldLocalUserHome) + return *v, true +} + +// OldOidcOrgID returns the old "oidc_org_id" field's value of the Tenant entity. +// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TenantMutation) OldOidcOrgID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOidcOrgID is only allowed on UpdateOne operations") } - if m.FieldCleared(task.FieldLocalUserMoveHome) { - fields = append(fields, task.FieldLocalUserMoveHome) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOidcOrgID requires an ID field in the mutation") } - if m.FieldCleared(task.FieldLocalUserNonunique) { - fields = append(fields, task.FieldLocalUserNonunique) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOidcOrgID: %w", err) } - if m.FieldCleared(task.FieldLocalUserPasswordExpireAccountDisable) { - fields = append(fields, task.FieldLocalUserPasswordExpireAccountDisable) + return oldValue.OidcOrgID, nil +} + +// ClearOidcOrgID clears the value of the "oidc_org_id" field. +func (m *TenantMutation) ClearOidcOrgID() { + m.oidc_org_id = nil + m.clearedFields[tenant.FieldOidcOrgID] = struct{}{} +} + +// OidcOrgIDCleared returns if the "oidc_org_id" field was cleared in this mutation. +func (m *TenantMutation) OidcOrgIDCleared() bool { + _, ok := m.clearedFields[tenant.FieldOidcOrgID] + return ok +} + +// ResetOidcOrgID resets all changes to the "oidc_org_id" field. +func (m *TenantMutation) ResetOidcOrgID() { + m.oidc_org_id = nil + delete(m.clearedFields, tenant.FieldOidcOrgID) +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (m *TenantMutation) SetOidcDefaultRole(tdr tenant.OidcDefaultRole) { + m.oidc_default_role = &tdr +} + +// OidcDefaultRole returns the value of the "oidc_default_role" field in the mutation. +func (m *TenantMutation) OidcDefaultRole() (r tenant.OidcDefaultRole, exists bool) { + v := m.oidc_default_role + if v == nil { + return } - if m.FieldCleared(task.FieldLocalUserPasswordExpireMax) { - fields = append(fields, task.FieldLocalUserPasswordExpireMax) + return *v, true +} + +// OldOidcDefaultRole returns the old "oidc_default_role" field's value of the Tenant entity. +// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TenantMutation) OldOidcDefaultRole(ctx context.Context) (v tenant.OidcDefaultRole, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOidcDefaultRole is only allowed on UpdateOne operations") } - if m.FieldCleared(task.FieldLocalUserPasswordExpireMin) { - fields = append(fields, task.FieldLocalUserPasswordExpireMin) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOidcDefaultRole requires an ID field in the mutation") } - if m.FieldCleared(task.FieldLocalUserPasswordExpireWarn) { - fields = append(fields, task.FieldLocalUserPasswordExpireWarn) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOidcDefaultRole: %w", err) } - if m.FieldCleared(task.FieldLocalUserPasswordLock) { - fields = append(fields, task.FieldLocalUserPasswordLock) + return oldValue.OidcDefaultRole, nil +} + +// ClearOidcDefaultRole clears the value of the "oidc_default_role" field. +func (m *TenantMutation) ClearOidcDefaultRole() { + m.oidc_default_role = nil + m.clearedFields[tenant.FieldOidcDefaultRole] = struct{}{} +} + +// OidcDefaultRoleCleared returns if the "oidc_default_role" field was cleared in this mutation. +func (m *TenantMutation) OidcDefaultRoleCleared() bool { + _, ok := m.clearedFields[tenant.FieldOidcDefaultRole] + return ok +} + +// ResetOidcDefaultRole resets all changes to the "oidc_default_role" field. +func (m *TenantMutation) ResetOidcDefaultRole() { + m.oidc_default_role = nil + delete(m.clearedFields, tenant.FieldOidcDefaultRole) +} + +// SetCreated sets the "created" field. +func (m *TenantMutation) SetCreated(t time.Time) { + m.created = &t +} + +// Created returns the value of the "created" field in the mutation. +func (m *TenantMutation) Created() (r time.Time, exists bool) { + v := m.created + if v == nil { + return } - if m.FieldCleared(task.FieldLocalUserSeuser) { - fields = append(fields, task.FieldLocalUserSeuser) + return *v, true +} + +// OldCreated returns the old "created" field's value of the Tenant entity. +// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TenantMutation) OldCreated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreated is only allowed on UpdateOne operations") } - if m.FieldCleared(task.FieldLocalUserShell) { - fields = append(fields, task.FieldLocalUserShell) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreated requires an ID field in the mutation") } - if m.FieldCleared(task.FieldLocalUserSkeleton) { - fields = append(fields, task.FieldLocalUserSkeleton) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreated: %w", err) } - if m.FieldCleared(task.FieldLocalUserSystem) { - fields = append(fields, task.FieldLocalUserSystem) + return oldValue.Created, nil +} + +// ClearCreated clears the value of the "created" field. +func (m *TenantMutation) ClearCreated() { + m.created = nil + m.clearedFields[tenant.FieldCreated] = struct{}{} +} + +// CreatedCleared returns if the "created" field was cleared in this mutation. +func (m *TenantMutation) CreatedCleared() bool { + _, ok := m.clearedFields[tenant.FieldCreated] + return ok +} + +// ResetCreated resets all changes to the "created" field. +func (m *TenantMutation) ResetCreated() { + m.created = nil + delete(m.clearedFields, tenant.FieldCreated) +} + +// SetModified sets the "modified" field. +func (m *TenantMutation) SetModified(t time.Time) { + m.modified = &t +} + +// Modified returns the value of the "modified" field in the mutation. +func (m *TenantMutation) Modified() (r time.Time, exists bool) { + v := m.modified + if v == nil { + return } - if m.FieldCleared(task.FieldLocalUserID) { - fields = append(fields, task.FieldLocalUserID) + return *v, true +} + +// OldModified returns the old "modified" field's value of the Tenant entity. +// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *TenantMutation) OldModified(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModified is only allowed on UpdateOne operations") } - if m.FieldCleared(task.FieldLocalUserIDMax) { - fields = append(fields, task.FieldLocalUserIDMax) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModified requires an ID field in the mutation") } - if m.FieldCleared(task.FieldLocalUserIDMin) { - fields = append(fields, task.FieldLocalUserIDMin) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModified: %w", err) } - if m.FieldCleared(task.FieldLocalUserSSHKeyBits) { - fields = append(fields, task.FieldLocalUserSSHKeyBits) + return oldValue.Modified, nil +} + +// ClearModified clears the value of the "modified" field. +func (m *TenantMutation) ClearModified() { + m.modified = nil + m.clearedFields[tenant.FieldModified] = struct{}{} +} + +// ModifiedCleared returns if the "modified" field was cleared in this mutation. +func (m *TenantMutation) ModifiedCleared() bool { + _, ok := m.clearedFields[tenant.FieldModified] + return ok +} + +// ResetModified resets all changes to the "modified" field. +func (m *TenantMutation) ResetModified() { + m.modified = nil + delete(m.clearedFields, tenant.FieldModified) +} + +// AddSiteIDs adds the "sites" edge to the Site entity by ids. +func (m *TenantMutation) AddSiteIDs(ids ...int) { + if m.sites == nil { + m.sites = make(map[int]struct{}) } - if m.FieldCleared(task.FieldLocalUserSSHKeyComment) { - fields = append(fields, task.FieldLocalUserSSHKeyComment) + for i := range ids { + m.sites[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldLocalUserSSHKeyFile) { - fields = append(fields, task.FieldLocalUserSSHKeyFile) +} + +// ClearSites clears the "sites" edge to the Site entity. +func (m *TenantMutation) ClearSites() { + m.clearedsites = true +} + +// SitesCleared reports if the "sites" edge to the Site entity was cleared. +func (m *TenantMutation) SitesCleared() bool { + return m.clearedsites +} + +// RemoveSiteIDs removes the "sites" edge to the Site entity by IDs. +func (m *TenantMutation) RemoveSiteIDs(ids ...int) { + if m.removedsites == nil { + m.removedsites = make(map[int]struct{}) } - if m.FieldCleared(task.FieldLocalUserSSHKeyPassphrase) { - fields = append(fields, task.FieldLocalUserSSHKeyPassphrase) + for i := range ids { + delete(m.sites, ids[i]) + m.removedsites[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldLocalUserSSHKeyType) { - fields = append(fields, task.FieldLocalUserSSHKeyType) +} + +// RemovedSites returns the removed IDs of the "sites" edge to the Site entity. +func (m *TenantMutation) RemovedSitesIDs() (ids []int) { + for id := range m.removedsites { + ids = append(ids, id) } - if m.FieldCleared(task.FieldLocalUserUmask) { - fields = append(fields, task.FieldLocalUserUmask) + return +} + +// SitesIDs returns the "sites" edge IDs in the mutation. +func (m *TenantMutation) SitesIDs() (ids []int) { + for id := range m.sites { + ids = append(ids, id) } - if m.FieldCleared(task.FieldLocalGroupID) { - fields = append(fields, task.FieldLocalGroupID) + return +} + +// ResetSites resets all changes to the "sites" edge. +func (m *TenantMutation) ResetSites() { + m.sites = nil + m.clearedsites = false + m.removedsites = nil +} + +// SetSettingsID sets the "settings" edge to the Settings entity by id. +func (m *TenantMutation) SetSettingsID(id int) { + m.settings = &id +} + +// ClearSettings clears the "settings" edge to the Settings entity. +func (m *TenantMutation) ClearSettings() { + m.clearedsettings = true +} + +// SettingsCleared reports if the "settings" edge to the Settings entity was cleared. +func (m *TenantMutation) SettingsCleared() bool { + return m.clearedsettings +} + +// SettingsID returns the "settings" edge ID in the mutation. +func (m *TenantMutation) SettingsID() (id int, exists bool) { + if m.settings != nil { + return *m.settings, true } - if m.FieldCleared(task.FieldLocalGroupName) { - fields = append(fields, task.FieldLocalGroupName) + return +} + +// SettingsIDs returns the "settings" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// SettingsID instead. It exists only for internal usage by the builders. +func (m *TenantMutation) SettingsIDs() (ids []int) { + if id := m.settings; id != nil { + ids = append(ids, *id) } - if m.FieldCleared(task.FieldLocalGroupDescription) { - fields = append(fields, task.FieldLocalGroupDescription) + return +} + +// ResetSettings resets all changes to the "settings" edge. +func (m *TenantMutation) ResetSettings() { + m.settings = nil + m.clearedsettings = false +} + +// AddTagIDs adds the "tags" edge to the Tag entity by ids. +func (m *TenantMutation) AddTagIDs(ids ...int) { + if m.tags == nil { + m.tags = make(map[int]struct{}) } - if m.FieldCleared(task.FieldLocalGroupSystem) { - fields = append(fields, task.FieldLocalGroupSystem) + for i := range ids { + m.tags[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldLocalGroupForce) { - fields = append(fields, task.FieldLocalGroupForce) +} + +// ClearTags clears the "tags" edge to the Tag entity. +func (m *TenantMutation) ClearTags() { + m.clearedtags = true +} + +// TagsCleared reports if the "tags" edge to the Tag entity was cleared. +func (m *TenantMutation) TagsCleared() bool { + return m.clearedtags +} + +// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. +func (m *TenantMutation) RemoveTagIDs(ids ...int) { + if m.removedtags == nil { + m.removedtags = make(map[int]struct{}) } - if m.FieldCleared(task.FieldLocalGroupMembers) { - fields = append(fields, task.FieldLocalGroupMembers) + for i := range ids { + delete(m.tags, ids[i]) + m.removedtags[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldLocalGroupMembersToInclude) { - fields = append(fields, task.FieldLocalGroupMembersToInclude) +} + +// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. +func (m *TenantMutation) RemovedTagsIDs() (ids []int) { + for id := range m.removedtags { + ids = append(ids, id) } - if m.FieldCleared(task.FieldLocalGroupMembersToExclude) { - fields = append(fields, task.FieldLocalGroupMembersToExclude) + return +} + +// TagsIDs returns the "tags" edge IDs in the mutation. +func (m *TenantMutation) TagsIDs() (ids []int) { + for id := range m.tags { + ids = append(ids, id) } - if m.FieldCleared(task.FieldMsiProductid) { - fields = append(fields, task.FieldMsiProductid) + return +} + +// ResetTags resets all changes to the "tags" edge. +func (m *TenantMutation) ResetTags() { + m.tags = nil + m.clearedtags = false + m.removedtags = nil +} + +// AddMetadatumIDs adds the "metadata" edge to the OrgMetadata entity by ids. +func (m *TenantMutation) AddMetadatumIDs(ids ...int) { + if m.metadata == nil { + m.metadata = make(map[int]struct{}) } - if m.FieldCleared(task.FieldMsiPath) { - fields = append(fields, task.FieldMsiPath) + for i := range ids { + m.metadata[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldMsiArguments) { - fields = append(fields, task.FieldMsiArguments) +} + +// ClearMetadata clears the "metadata" edge to the OrgMetadata entity. +func (m *TenantMutation) ClearMetadata() { + m.clearedmetadata = true +} + +// MetadataCleared reports if the "metadata" edge to the OrgMetadata entity was cleared. +func (m *TenantMutation) MetadataCleared() bool { + return m.clearedmetadata +} + +// RemoveMetadatumIDs removes the "metadata" edge to the OrgMetadata entity by IDs. +func (m *TenantMutation) RemoveMetadatumIDs(ids ...int) { + if m.removedmetadata == nil { + m.removedmetadata = make(map[int]struct{}) } - if m.FieldCleared(task.FieldMsiFileHash) { - fields = append(fields, task.FieldMsiFileHash) + for i := range ids { + delete(m.metadata, ids[i]) + m.removedmetadata[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldMsiFileHashAlg) { - fields = append(fields, task.FieldMsiFileHashAlg) +} + +// RemovedMetadata returns the removed IDs of the "metadata" edge to the OrgMetadata entity. +func (m *TenantMutation) RemovedMetadataIDs() (ids []int) { + for id := range m.removedmetadata { + ids = append(ids, id) } - if m.FieldCleared(task.FieldMsiLogPath) { - fields = append(fields, task.FieldMsiLogPath) + return +} + +// MetadataIDs returns the "metadata" edge IDs in the mutation. +func (m *TenantMutation) MetadataIDs() (ids []int) { + for id := range m.metadata { + ids = append(ids, id) } - if m.FieldCleared(task.FieldScript) { - fields = append(fields, task.FieldScript) + return +} + +// ResetMetadata resets all changes to the "metadata" edge. +func (m *TenantMutation) ResetMetadata() { + m.metadata = nil + m.clearedmetadata = false + m.removedmetadata = nil +} + +// AddRustdeskIDs adds the "rustdesk" edge to the Rustdesk entity by ids. +func (m *TenantMutation) AddRustdeskIDs(ids ...int) { + if m.rustdesk == nil { + m.rustdesk = make(map[int]struct{}) } - if m.FieldCleared(task.FieldScriptExecutable) { - fields = append(fields, task.FieldScriptExecutable) + for i := range ids { + m.rustdesk[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldScriptCreates) { - fields = append(fields, task.FieldScriptCreates) +} + +// ClearRustdesk clears the "rustdesk" edge to the Rustdesk entity. +func (m *TenantMutation) ClearRustdesk() { + m.clearedrustdesk = true +} + +// RustdeskCleared reports if the "rustdesk" edge to the Rustdesk entity was cleared. +func (m *TenantMutation) RustdeskCleared() bool { + return m.clearedrustdesk +} + +// RemoveRustdeskIDs removes the "rustdesk" edge to the Rustdesk entity by IDs. +func (m *TenantMutation) RemoveRustdeskIDs(ids ...int) { + if m.removedrustdesk == nil { + m.removedrustdesk = make(map[int]struct{}) } - if m.FieldCleared(task.FieldScriptRun) { - fields = append(fields, task.FieldScriptRun) + for i := range ids { + delete(m.rustdesk, ids[i]) + m.removedrustdesk[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldAgentType) { - fields = append(fields, task.FieldAgentType) +} + +// RemovedRustdesk returns the removed IDs of the "rustdesk" edge to the Rustdesk entity. +func (m *TenantMutation) RemovedRustdeskIDs() (ids []int) { + for id := range m.removedrustdesk { + ids = append(ids, id) } - if m.FieldCleared(task.FieldWhen) { - fields = append(fields, task.FieldWhen) + return +} + +// RustdeskIDs returns the "rustdesk" edge IDs in the mutation. +func (m *TenantMutation) RustdeskIDs() (ids []int) { + for id := range m.rustdesk { + ids = append(ids, id) } - if m.FieldCleared(task.FieldBrewUpdate) { - fields = append(fields, task.FieldBrewUpdate) + return +} + +// ResetRustdesk resets all changes to the "rustdesk" edge. +func (m *TenantMutation) ResetRustdesk() { + m.rustdesk = nil + m.clearedrustdesk = false + m.removedrustdesk = nil +} + +// SetNetbirdID sets the "netbird" edge to the NetbirdSettings entity by id. +func (m *TenantMutation) SetNetbirdID(id int) { + m.netbird = &id +} + +// ClearNetbird clears the "netbird" edge to the NetbirdSettings entity. +func (m *TenantMutation) ClearNetbird() { + m.clearednetbird = true +} + +// NetbirdCleared reports if the "netbird" edge to the NetbirdSettings entity was cleared. +func (m *TenantMutation) NetbirdCleared() bool { + return m.clearednetbird +} + +// NetbirdID returns the "netbird" edge ID in the mutation. +func (m *TenantMutation) NetbirdID() (id int, exists bool) { + if m.netbird != nil { + return *m.netbird, true } - if m.FieldCleared(task.FieldBrewUpgradeAll) { - fields = append(fields, task.FieldBrewUpgradeAll) + return +} + +// NetbirdIDs returns the "netbird" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// NetbirdID instead. It exists only for internal usage by the builders. +func (m *TenantMutation) NetbirdIDs() (ids []int) { + if id := m.netbird; id != nil { + ids = append(ids, *id) } - if m.FieldCleared(task.FieldBrewUpgradeOptions) { - fields = append(fields, task.FieldBrewUpgradeOptions) + return +} + +// ResetNetbird resets all changes to the "netbird" edge. +func (m *TenantMutation) ResetNetbird() { + m.netbird = nil + m.clearednetbird = false +} + +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by ids. +func (m *TenantMutation) AddUserTenantIDs(ids ...int) { + if m.user_tenants == nil { + m.user_tenants = make(map[int]struct{}) } - if m.FieldCleared(task.FieldBrewInstallOptions) { - fields = append(fields, task.FieldBrewInstallOptions) + for i := range ids { + m.user_tenants[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldBrewGreedy) { - fields = append(fields, task.FieldBrewGreedy) +} + +// ClearUserTenants clears the "user_tenants" edge to the UserTenant entity. +func (m *TenantMutation) ClearUserTenants() { + m.cleareduser_tenants = true +} + +// UserTenantsCleared reports if the "user_tenants" edge to the UserTenant entity was cleared. +func (m *TenantMutation) UserTenantsCleared() bool { + return m.cleareduser_tenants +} + +// RemoveUserTenantIDs removes the "user_tenants" edge to the UserTenant entity by IDs. +func (m *TenantMutation) RemoveUserTenantIDs(ids ...int) { + if m.removeduser_tenants == nil { + m.removeduser_tenants = make(map[int]struct{}) } - if m.FieldCleared(task.FieldPackageVersion) { - fields = append(fields, task.FieldPackageVersion) + for i := range ids { + delete(m.user_tenants, ids[i]) + m.removeduser_tenants[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldAptAllowDowngrade) { - fields = append(fields, task.FieldAptAllowDowngrade) +} + +// RemovedUserTenants returns the removed IDs of the "user_tenants" edge to the UserTenant entity. +func (m *TenantMutation) RemovedUserTenantsIDs() (ids []int) { + for id := range m.removeduser_tenants { + ids = append(ids, id) } - if m.FieldCleared(task.FieldAptDeb) { - fields = append(fields, task.FieldAptDeb) + return +} + +// UserTenantsIDs returns the "user_tenants" edge IDs in the mutation. +func (m *TenantMutation) UserTenantsIDs() (ids []int) { + for id := range m.user_tenants { + ids = append(ids, id) } - if m.FieldCleared(task.FieldAptDpkgOptions) { - fields = append(fields, task.FieldAptDpkgOptions) + return +} + +// ResetUserTenants resets all changes to the "user_tenants" edge. +func (m *TenantMutation) ResetUserTenants() { + m.user_tenants = nil + m.cleareduser_tenants = false + m.removeduser_tenants = nil +} + +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by ids. +func (m *TenantMutation) AddEnrollmentTokenIDs(ids ...int) { + if m.enrollment_tokens == nil { + m.enrollment_tokens = make(map[int]struct{}) } - if m.FieldCleared(task.FieldAptFailOnAutoremove) { - fields = append(fields, task.FieldAptFailOnAutoremove) + for i := range ids { + m.enrollment_tokens[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldAptForce) { - fields = append(fields, task.FieldAptForce) +} + +// ClearEnrollmentTokens clears the "enrollment_tokens" edge to the EnrollmentToken entity. +func (m *TenantMutation) ClearEnrollmentTokens() { + m.clearedenrollment_tokens = true +} + +// EnrollmentTokensCleared reports if the "enrollment_tokens" edge to the EnrollmentToken entity was cleared. +func (m *TenantMutation) EnrollmentTokensCleared() bool { + return m.clearedenrollment_tokens +} + +// RemoveEnrollmentTokenIDs removes the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (m *TenantMutation) RemoveEnrollmentTokenIDs(ids ...int) { + if m.removedenrollment_tokens == nil { + m.removedenrollment_tokens = make(map[int]struct{}) } - if m.FieldCleared(task.FieldAptInstallRecommends) { - fields = append(fields, task.FieldAptInstallRecommends) + for i := range ids { + delete(m.enrollment_tokens, ids[i]) + m.removedenrollment_tokens[ids[i]] = struct{}{} } - if m.FieldCleared(task.FieldAptName) { - fields = append(fields, task.FieldAptName) +} + +// RemovedEnrollmentTokens returns the removed IDs of the "enrollment_tokens" edge to the EnrollmentToken entity. +func (m *TenantMutation) RemovedEnrollmentTokensIDs() (ids []int) { + for id := range m.removedenrollment_tokens { + ids = append(ids, id) } - if m.FieldCleared(task.FieldAptOnlyUpgrade) { - fields = append(fields, task.FieldAptOnlyUpgrade) + return +} + +// EnrollmentTokensIDs returns the "enrollment_tokens" edge IDs in the mutation. +func (m *TenantMutation) EnrollmentTokensIDs() (ids []int) { + for id := range m.enrollment_tokens { + ids = append(ids, id) } - if m.FieldCleared(task.FieldAptPurge) { - fields = append(fields, task.FieldAptPurge) + return +} + +// ResetEnrollmentTokens resets all changes to the "enrollment_tokens" edge. +func (m *TenantMutation) ResetEnrollmentTokens() { + m.enrollment_tokens = nil + m.clearedenrollment_tokens = false + m.removedenrollment_tokens = nil +} + +// Where appends a list predicates to the TenantMutation builder. +func (m *TenantMutation) Where(ps ...predicate.Tenant) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the TenantMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TenantMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Tenant, len(ps)) + for i := range ps { + p[i] = ps[i] } - if m.FieldCleared(task.FieldAptUpdateCache) { - fields = append(fields, task.FieldAptUpdateCache) + m.Where(p...) +} + +// Op returns the operation name. +func (m *TenantMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *TenantMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Tenant). +func (m *TenantMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *TenantMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.description != nil { + fields = append(fields, tenant.FieldDescription) } - if m.FieldCleared(task.FieldAptUpgradeType) { - fields = append(fields, task.FieldAptUpgradeType) + if m.is_default != nil { + fields = append(fields, tenant.FieldIsDefault) } - if m.FieldCleared(task.FieldVersion) { - fields = append(fields, task.FieldVersion) + if m.oidc_org_id != nil { + fields = append(fields, tenant.FieldOidcOrgID) } - if m.FieldCleared(task.FieldTenant) { - fields = append(fields, task.FieldTenant) + if m.oidc_default_role != nil { + fields = append(fields, tenant.FieldOidcDefaultRole) } - if m.FieldCleared(task.FieldNetbirdGroups) { - fields = append(fields, task.FieldNetbirdGroups) + if m.created != nil { + fields = append(fields, tenant.FieldCreated) } - if m.FieldCleared(task.FieldNetbirdAllowExtraDNSLabels) { - fields = append(fields, task.FieldNetbirdAllowExtraDNSLabels) + if m.modified != nil { + fields = append(fields, tenant.FieldModified) } return fields } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *TaskMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *TaskMutation) ClearField(name string) error { - switch name { - case task.FieldPackageID: - m.ClearPackageID() - return nil - case task.FieldPackageName: - m.ClearPackageName() - return nil - case task.FieldPackageLatest: - m.ClearPackageLatest() - return nil - case task.FieldRegistryKey: - m.ClearRegistryKey() - return nil - case task.FieldRegistryKeyValueName: - m.ClearRegistryKeyValueName() - return nil - case task.FieldRegistryKeyValueType: - m.ClearRegistryKeyValueType() - return nil - case task.FieldRegistryKeyValueData: - m.ClearRegistryKeyValueData() - return nil - case task.FieldRegistryHex: - m.ClearRegistryHex() - return nil - case task.FieldRegistryForce: - m.ClearRegistryForce() - return nil - case task.FieldLocalUserUsername: - m.ClearLocalUserUsername() - return nil - case task.FieldLocalUserDescription: - m.ClearLocalUserDescription() - return nil - case task.FieldLocalUserDisable: - m.ClearLocalUserDisable() - return nil - case task.FieldLocalUserFullname: - m.ClearLocalUserFullname() - return nil - case task.FieldLocalUserPassword: - m.ClearLocalUserPassword() - return nil - case task.FieldLocalUserPasswordChangeNotAllowed: - m.ClearLocalUserPasswordChangeNotAllowed() - return nil - case task.FieldLocalUserPasswordChangeRequired: - m.ClearLocalUserPasswordChangeRequired() - return nil - case task.FieldLocalUserPasswordNeverExpires: - m.ClearLocalUserPasswordNeverExpires() - return nil - case task.FieldLocalUserAppend: - m.ClearLocalUserAppend() - return nil - case task.FieldLocalUserCreateHome: - m.ClearLocalUserCreateHome() - return nil - case task.FieldLocalUserExpires: - m.ClearLocalUserExpires() - return nil - case task.FieldLocalUserForce: - m.ClearLocalUserForce() - return nil - case task.FieldLocalUserGenerateSSHKey: - m.ClearLocalUserGenerateSSHKey() - return nil - case task.FieldLocalUserGroup: - m.ClearLocalUserGroup() - return nil - case task.FieldLocalUserGroups: - m.ClearLocalUserGroups() - return nil - case task.FieldLocalUserHome: - m.ClearLocalUserHome() - return nil - case task.FieldLocalUserMoveHome: - m.ClearLocalUserMoveHome() - return nil - case task.FieldLocalUserNonunique: - m.ClearLocalUserNonunique() - return nil - case task.FieldLocalUserPasswordExpireAccountDisable: - m.ClearLocalUserPasswordExpireAccountDisable() - return nil - case task.FieldLocalUserPasswordExpireMax: - m.ClearLocalUserPasswordExpireMax() - return nil - case task.FieldLocalUserPasswordExpireMin: - m.ClearLocalUserPasswordExpireMin() - return nil - case task.FieldLocalUserPasswordExpireWarn: - m.ClearLocalUserPasswordExpireWarn() - return nil - case task.FieldLocalUserPasswordLock: - m.ClearLocalUserPasswordLock() - return nil - case task.FieldLocalUserSeuser: - m.ClearLocalUserSeuser() - return nil - case task.FieldLocalUserShell: - m.ClearLocalUserShell() - return nil - case task.FieldLocalUserSkeleton: - m.ClearLocalUserSkeleton() - return nil - case task.FieldLocalUserSystem: - m.ClearLocalUserSystem() - return nil - case task.FieldLocalUserID: - m.ClearLocalUserID() - return nil - case task.FieldLocalUserIDMax: - m.ClearLocalUserIDMax() - return nil - case task.FieldLocalUserIDMin: - m.ClearLocalUserIDMin() - return nil - case task.FieldLocalUserSSHKeyBits: - m.ClearLocalUserSSHKeyBits() - return nil - case task.FieldLocalUserSSHKeyComment: - m.ClearLocalUserSSHKeyComment() - return nil - case task.FieldLocalUserSSHKeyFile: - m.ClearLocalUserSSHKeyFile() - return nil - case task.FieldLocalUserSSHKeyPassphrase: - m.ClearLocalUserSSHKeyPassphrase() - return nil - case task.FieldLocalUserSSHKeyType: - m.ClearLocalUserSSHKeyType() - return nil - case task.FieldLocalUserUmask: - m.ClearLocalUserUmask() - return nil - case task.FieldLocalGroupID: - m.ClearLocalGroupID() - return nil - case task.FieldLocalGroupName: - m.ClearLocalGroupName() - return nil - case task.FieldLocalGroupDescription: - m.ClearLocalGroupDescription() - return nil - case task.FieldLocalGroupSystem: - m.ClearLocalGroupSystem() - return nil - case task.FieldLocalGroupForce: - m.ClearLocalGroupForce() - return nil - case task.FieldLocalGroupMembers: - m.ClearLocalGroupMembers() - return nil - case task.FieldLocalGroupMembersToInclude: - m.ClearLocalGroupMembersToInclude() - return nil - case task.FieldLocalGroupMembersToExclude: - m.ClearLocalGroupMembersToExclude() - return nil - case task.FieldMsiProductid: - m.ClearMsiProductid() - return nil - case task.FieldMsiPath: - m.ClearMsiPath() - return nil - case task.FieldMsiArguments: - m.ClearMsiArguments() - return nil - case task.FieldMsiFileHash: - m.ClearMsiFileHash() - return nil - case task.FieldMsiFileHashAlg: - m.ClearMsiFileHashAlg() - return nil - case task.FieldMsiLogPath: - m.ClearMsiLogPath() - return nil - case task.FieldScript: - m.ClearScript() - return nil - case task.FieldScriptExecutable: - m.ClearScriptExecutable() - return nil - case task.FieldScriptCreates: - m.ClearScriptCreates() - return nil - case task.FieldScriptRun: - m.ClearScriptRun() - return nil - case task.FieldAgentType: - m.ClearAgentType() - return nil - case task.FieldWhen: - m.ClearWhen() - return nil - case task.FieldBrewUpdate: - m.ClearBrewUpdate() - return nil - case task.FieldBrewUpgradeAll: - m.ClearBrewUpgradeAll() - return nil - case task.FieldBrewUpgradeOptions: - m.ClearBrewUpgradeOptions() - return nil - case task.FieldBrewInstallOptions: - m.ClearBrewInstallOptions() - return nil - case task.FieldBrewGreedy: - m.ClearBrewGreedy() - return nil - case task.FieldPackageVersion: - m.ClearPackageVersion() - return nil - case task.FieldAptAllowDowngrade: - m.ClearAptAllowDowngrade() - return nil - case task.FieldAptDeb: - m.ClearAptDeb() - return nil - case task.FieldAptDpkgOptions: - m.ClearAptDpkgOptions() - return nil - case task.FieldAptFailOnAutoremove: - m.ClearAptFailOnAutoremove() +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *TenantMutation) Field(name string) (ent.Value, bool) { + switch name { + case tenant.FieldDescription: + return m.Description() + case tenant.FieldIsDefault: + return m.IsDefault() + case tenant.FieldOidcOrgID: + return m.OidcOrgID() + case tenant.FieldOidcDefaultRole: + return m.OidcDefaultRole() + case tenant.FieldCreated: + return m.Created() + case tenant.FieldModified: + return m.Modified() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *TenantMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case tenant.FieldDescription: + return m.OldDescription(ctx) + case tenant.FieldIsDefault: + return m.OldIsDefault(ctx) + case tenant.FieldOidcOrgID: + return m.OldOidcOrgID(ctx) + case tenant.FieldOidcDefaultRole: + return m.OldOidcDefaultRole(ctx) + case tenant.FieldCreated: + return m.OldCreated(ctx) + case tenant.FieldModified: + return m.OldModified(ctx) + } + return nil, fmt.Errorf("unknown Tenant field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TenantMutation) SetField(name string, value ent.Value) error { + switch name { + case tenant.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) return nil - case task.FieldAptForce: - m.ClearAptForce() + case tenant.FieldIsDefault: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsDefault(v) return nil - case task.FieldAptInstallRecommends: - m.ClearAptInstallRecommends() + case tenant.FieldOidcOrgID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOidcOrgID(v) return nil - case task.FieldAptName: - m.ClearAptName() + case tenant.FieldOidcDefaultRole: + v, ok := value.(tenant.OidcDefaultRole) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOidcDefaultRole(v) return nil - case task.FieldAptOnlyUpgrade: - m.ClearAptOnlyUpgrade() + case tenant.FieldCreated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreated(v) return nil - case task.FieldAptPurge: - m.ClearAptPurge() + case tenant.FieldModified: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModified(v) return nil - case task.FieldAptUpdateCache: - m.ClearAptUpdateCache() + } + return fmt.Errorf("unknown Tenant field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *TenantMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *TenantMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *TenantMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Tenant numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *TenantMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(tenant.FieldDescription) { + fields = append(fields, tenant.FieldDescription) + } + if m.FieldCleared(tenant.FieldIsDefault) { + fields = append(fields, tenant.FieldIsDefault) + } + if m.FieldCleared(tenant.FieldOidcOrgID) { + fields = append(fields, tenant.FieldOidcOrgID) + } + if m.FieldCleared(tenant.FieldOidcDefaultRole) { + fields = append(fields, tenant.FieldOidcDefaultRole) + } + if m.FieldCleared(tenant.FieldCreated) { + fields = append(fields, tenant.FieldCreated) + } + if m.FieldCleared(tenant.FieldModified) { + fields = append(fields, tenant.FieldModified) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *TenantMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *TenantMutation) ClearField(name string) error { + switch name { + case tenant.FieldDescription: + m.ClearDescription() return nil - case task.FieldAptUpgradeType: - m.ClearAptUpgradeType() + case tenant.FieldIsDefault: + m.ClearIsDefault() return nil - case task.FieldVersion: - m.ClearVersion() + case tenant.FieldOidcOrgID: + m.ClearOidcOrgID() return nil - case task.FieldTenant: - m.ClearTenant() + case tenant.FieldOidcDefaultRole: + m.ClearOidcDefaultRole() return nil - case task.FieldNetbirdGroups: - m.ClearNetbirdGroups() + case tenant.FieldCreated: + m.ClearCreated() return nil - case task.FieldNetbirdAllowExtraDNSLabels: - m.ClearNetbirdAllowExtraDNSLabels() + case tenant.FieldModified: + m.ClearModified() return nil } - return fmt.Errorf("unknown Task nullable field %s", name) + return fmt.Errorf("unknown Tenant nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *TaskMutation) ResetField(name string) error { +func (m *TenantMutation) ResetField(name string) error { switch name { - case task.FieldName: - m.ResetName() - return nil - case task.FieldType: - m.ResetType() - return nil - case task.FieldPackageID: - m.ResetPackageID() - return nil - case task.FieldPackageName: - m.ResetPackageName() - return nil - case task.FieldPackageLatest: - m.ResetPackageLatest() - return nil - case task.FieldRegistryKey: - m.ResetRegistryKey() - return nil - case task.FieldRegistryKeyValueName: - m.ResetRegistryKeyValueName() - return nil - case task.FieldRegistryKeyValueType: - m.ResetRegistryKeyValueType() - return nil - case task.FieldRegistryKeyValueData: - m.ResetRegistryKeyValueData() - return nil - case task.FieldRegistryHex: - m.ResetRegistryHex() - return nil - case task.FieldRegistryForce: - m.ResetRegistryForce() - return nil - case task.FieldLocalUserUsername: - m.ResetLocalUserUsername() - return nil - case task.FieldLocalUserDescription: - m.ResetLocalUserDescription() - return nil - case task.FieldLocalUserDisable: - m.ResetLocalUserDisable() - return nil - case task.FieldLocalUserFullname: - m.ResetLocalUserFullname() - return nil - case task.FieldLocalUserPassword: - m.ResetLocalUserPassword() - return nil - case task.FieldLocalUserPasswordChangeNotAllowed: - m.ResetLocalUserPasswordChangeNotAllowed() - return nil - case task.FieldLocalUserPasswordChangeRequired: - m.ResetLocalUserPasswordChangeRequired() - return nil - case task.FieldLocalUserPasswordNeverExpires: - m.ResetLocalUserPasswordNeverExpires() - return nil - case task.FieldLocalUserAppend: - m.ResetLocalUserAppend() - return nil - case task.FieldLocalUserCreateHome: - m.ResetLocalUserCreateHome() - return nil - case task.FieldLocalUserExpires: - m.ResetLocalUserExpires() - return nil - case task.FieldLocalUserForce: - m.ResetLocalUserForce() - return nil - case task.FieldLocalUserGenerateSSHKey: - m.ResetLocalUserGenerateSSHKey() - return nil - case task.FieldLocalUserGroup: - m.ResetLocalUserGroup() - return nil - case task.FieldLocalUserGroups: - m.ResetLocalUserGroups() - return nil - case task.FieldLocalUserHome: - m.ResetLocalUserHome() - return nil - case task.FieldLocalUserMoveHome: - m.ResetLocalUserMoveHome() - return nil - case task.FieldLocalUserNonunique: - m.ResetLocalUserNonunique() - return nil - case task.FieldLocalUserPasswordExpireAccountDisable: - m.ResetLocalUserPasswordExpireAccountDisable() - return nil - case task.FieldLocalUserPasswordExpireMax: - m.ResetLocalUserPasswordExpireMax() - return nil - case task.FieldLocalUserPasswordExpireMin: - m.ResetLocalUserPasswordExpireMin() - return nil - case task.FieldLocalUserPasswordExpireWarn: - m.ResetLocalUserPasswordExpireWarn() - return nil - case task.FieldLocalUserPasswordLock: - m.ResetLocalUserPasswordLock() - return nil - case task.FieldLocalUserSeuser: - m.ResetLocalUserSeuser() - return nil - case task.FieldLocalUserShell: - m.ResetLocalUserShell() - return nil - case task.FieldLocalUserSkeleton: - m.ResetLocalUserSkeleton() - return nil - case task.FieldLocalUserSystem: - m.ResetLocalUserSystem() - return nil - case task.FieldLocalUserID: - m.ResetLocalUserID() - return nil - case task.FieldLocalUserIDMax: - m.ResetLocalUserIDMax() - return nil - case task.FieldLocalUserIDMin: - m.ResetLocalUserIDMin() - return nil - case task.FieldLocalUserSSHKeyBits: - m.ResetLocalUserSSHKeyBits() - return nil - case task.FieldLocalUserSSHKeyComment: - m.ResetLocalUserSSHKeyComment() - return nil - case task.FieldLocalUserSSHKeyFile: - m.ResetLocalUserSSHKeyFile() - return nil - case task.FieldLocalUserSSHKeyPassphrase: - m.ResetLocalUserSSHKeyPassphrase() - return nil - case task.FieldLocalUserSSHKeyType: - m.ResetLocalUserSSHKeyType() - return nil - case task.FieldLocalUserUmask: - m.ResetLocalUserUmask() - return nil - case task.FieldLocalGroupID: - m.ResetLocalGroupID() - return nil - case task.FieldLocalGroupName: - m.ResetLocalGroupName() - return nil - case task.FieldLocalGroupDescription: - m.ResetLocalGroupDescription() - return nil - case task.FieldLocalGroupSystem: - m.ResetLocalGroupSystem() - return nil - case task.FieldLocalGroupForce: - m.ResetLocalGroupForce() - return nil - case task.FieldLocalGroupMembers: - m.ResetLocalGroupMembers() - return nil - case task.FieldLocalGroupMembersToInclude: - m.ResetLocalGroupMembersToInclude() - return nil - case task.FieldLocalGroupMembersToExclude: - m.ResetLocalGroupMembersToExclude() - return nil - case task.FieldMsiProductid: - m.ResetMsiProductid() - return nil - case task.FieldMsiPath: - m.ResetMsiPath() - return nil - case task.FieldMsiArguments: - m.ResetMsiArguments() - return nil - case task.FieldMsiFileHash: - m.ResetMsiFileHash() - return nil - case task.FieldMsiFileHashAlg: - m.ResetMsiFileHashAlg() - return nil - case task.FieldMsiLogPath: - m.ResetMsiLogPath() - return nil - case task.FieldScript: - m.ResetScript() - return nil - case task.FieldScriptExecutable: - m.ResetScriptExecutable() - return nil - case task.FieldScriptCreates: - m.ResetScriptCreates() - return nil - case task.FieldScriptRun: - m.ResetScriptRun() - return nil - case task.FieldAgentType: - m.ResetAgentType() - return nil - case task.FieldWhen: - m.ResetWhen() - return nil - case task.FieldBrewUpdate: - m.ResetBrewUpdate() - return nil - case task.FieldBrewUpgradeAll: - m.ResetBrewUpgradeAll() - return nil - case task.FieldBrewUpgradeOptions: - m.ResetBrewUpgradeOptions() - return nil - case task.FieldBrewInstallOptions: - m.ResetBrewInstallOptions() - return nil - case task.FieldBrewGreedy: - m.ResetBrewGreedy() - return nil - case task.FieldPackageVersion: - m.ResetPackageVersion() - return nil - case task.FieldAptAllowDowngrade: - m.ResetAptAllowDowngrade() - return nil - case task.FieldAptDeb: - m.ResetAptDeb() - return nil - case task.FieldAptDpkgOptions: - m.ResetAptDpkgOptions() - return nil - case task.FieldAptFailOnAutoremove: - m.ResetAptFailOnAutoremove() - return nil - case task.FieldAptForce: - m.ResetAptForce() - return nil - case task.FieldAptInstallRecommends: - m.ResetAptInstallRecommends() - return nil - case task.FieldAptName: - m.ResetAptName() - return nil - case task.FieldAptOnlyUpgrade: - m.ResetAptOnlyUpgrade() - return nil - case task.FieldAptPurge: - m.ResetAptPurge() - return nil - case task.FieldAptUpdateCache: - m.ResetAptUpdateCache() + case tenant.FieldDescription: + m.ResetDescription() return nil - case task.FieldAptUpgradeType: - m.ResetAptUpgradeType() + case tenant.FieldIsDefault: + m.ResetIsDefault() return nil - case task.FieldVersion: - m.ResetVersion() + case tenant.FieldOidcOrgID: + m.ResetOidcOrgID() return nil - case task.FieldTenant: - m.ResetTenant() + case tenant.FieldOidcDefaultRole: + m.ResetOidcDefaultRole() return nil - case task.FieldNetbirdGroups: - m.ResetNetbirdGroups() + case tenant.FieldCreated: + m.ResetCreated() return nil - case task.FieldNetbirdAllowExtraDNSLabels: - m.ResetNetbirdAllowExtraDNSLabels() + case tenant.FieldModified: + m.ResetModified() return nil } - return fmt.Errorf("unknown Task field %s", name) + return fmt.Errorf("unknown Tenant field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *TaskMutation) AddedEdges() []string { - edges := make([]string, 0, 2) +func (m *TenantMutation) AddedEdges() []string { + edges := make([]string, 0, 8) + if m.sites != nil { + edges = append(edges, tenant.EdgeSites) + } + if m.settings != nil { + edges = append(edges, tenant.EdgeSettings) + } if m.tags != nil { - edges = append(edges, task.EdgeTags) + edges = append(edges, tenant.EdgeTags) } - if m.profile != nil { - edges = append(edges, task.EdgeProfile) + if m.metadata != nil { + edges = append(edges, tenant.EdgeMetadata) + } + if m.rustdesk != nil { + edges = append(edges, tenant.EdgeRustdesk) + } + if m.netbird != nil { + edges = append(edges, tenant.EdgeNetbird) + } + if m.user_tenants != nil { + edges = append(edges, tenant.EdgeUserTenants) + } + if m.enrollment_tokens != nil { + edges = append(edges, tenant.EdgeEnrollmentTokens) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *TaskMutation) AddedIDs(name string) []ent.Value { +func (m *TenantMutation) AddedIDs(name string) []ent.Value { switch name { - case task.EdgeTags: + case tenant.EdgeSites: + ids := make([]ent.Value, 0, len(m.sites)) + for id := range m.sites { + ids = append(ids, id) + } + return ids + case tenant.EdgeSettings: + if id := m.settings; id != nil { + return []ent.Value{*id} + } + case tenant.EdgeTags: ids := make([]ent.Value, 0, len(m.tags)) for id := range m.tags { ids = append(ids, id) } return ids - case task.EdgeProfile: - if id := m.profile; id != nil { + case tenant.EdgeMetadata: + ids := make([]ent.Value, 0, len(m.metadata)) + for id := range m.metadata { + ids = append(ids, id) + } + return ids + case tenant.EdgeRustdesk: + ids := make([]ent.Value, 0, len(m.rustdesk)) + for id := range m.rustdesk { + ids = append(ids, id) + } + return ids + case tenant.EdgeNetbird: + if id := m.netbird; id != nil { return []ent.Value{*id} } + case tenant.EdgeUserTenants: + ids := make([]ent.Value, 0, len(m.user_tenants)) + for id := range m.user_tenants { + ids = append(ids, id) + } + return ids + case tenant.EdgeEnrollmentTokens: + ids := make([]ent.Value, 0, len(m.enrollment_tokens)) + for id := range m.enrollment_tokens { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *TaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *TenantMutation) RemovedEdges() []string { + edges := make([]string, 0, 8) + if m.removedsites != nil { + edges = append(edges, tenant.EdgeSites) + } if m.removedtags != nil { - edges = append(edges, task.EdgeTags) + edges = append(edges, tenant.EdgeTags) + } + if m.removedmetadata != nil { + edges = append(edges, tenant.EdgeMetadata) + } + if m.removedrustdesk != nil { + edges = append(edges, tenant.EdgeRustdesk) + } + if m.removeduser_tenants != nil { + edges = append(edges, tenant.EdgeUserTenants) + } + if m.removedenrollment_tokens != nil { + edges = append(edges, tenant.EdgeEnrollmentTokens) } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *TaskMutation) RemovedIDs(name string) []ent.Value { +func (m *TenantMutation) RemovedIDs(name string) []ent.Value { switch name { - case task.EdgeTags: + case tenant.EdgeSites: + ids := make([]ent.Value, 0, len(m.removedsites)) + for id := range m.removedsites { + ids = append(ids, id) + } + return ids + case tenant.EdgeTags: ids := make([]ent.Value, 0, len(m.removedtags)) for id := range m.removedtags { ids = append(ids, id) } return ids + case tenant.EdgeMetadata: + ids := make([]ent.Value, 0, len(m.removedmetadata)) + for id := range m.removedmetadata { + ids = append(ids, id) + } + return ids + case tenant.EdgeRustdesk: + ids := make([]ent.Value, 0, len(m.removedrustdesk)) + for id := range m.removedrustdesk { + ids = append(ids, id) + } + return ids + case tenant.EdgeUserTenants: + ids := make([]ent.Value, 0, len(m.removeduser_tenants)) + for id := range m.removeduser_tenants { + ids = append(ids, id) + } + return ids + case tenant.EdgeEnrollmentTokens: + ids := make([]ent.Value, 0, len(m.removedenrollment_tokens)) + for id := range m.removedenrollment_tokens { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *TaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) +func (m *TenantMutation) ClearedEdges() []string { + edges := make([]string, 0, 8) + if m.clearedsites { + edges = append(edges, tenant.EdgeSites) + } + if m.clearedsettings { + edges = append(edges, tenant.EdgeSettings) + } if m.clearedtags { - edges = append(edges, task.EdgeTags) + edges = append(edges, tenant.EdgeTags) } - if m.clearedprofile { - edges = append(edges, task.EdgeProfile) + if m.clearedmetadata { + edges = append(edges, tenant.EdgeMetadata) + } + if m.clearedrustdesk { + edges = append(edges, tenant.EdgeRustdesk) + } + if m.clearednetbird { + edges = append(edges, tenant.EdgeNetbird) + } + if m.cleareduser_tenants { + edges = append(edges, tenant.EdgeUserTenants) + } + if m.clearedenrollment_tokens { + edges = append(edges, tenant.EdgeEnrollmentTokens) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *TaskMutation) EdgeCleared(name string) bool { +func (m *TenantMutation) EdgeCleared(name string) bool { switch name { - case task.EdgeTags: + case tenant.EdgeSites: + return m.clearedsites + case tenant.EdgeSettings: + return m.clearedsettings + case tenant.EdgeTags: return m.clearedtags - case task.EdgeProfile: - return m.clearedprofile + case tenant.EdgeMetadata: + return m.clearedmetadata + case tenant.EdgeRustdesk: + return m.clearedrustdesk + case tenant.EdgeNetbird: + return m.clearednetbird + case tenant.EdgeUserTenants: + return m.cleareduser_tenants + case tenant.EdgeEnrollmentTokens: + return m.clearedenrollment_tokens } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *TaskMutation) ClearEdge(name string) error { +func (m *TenantMutation) ClearEdge(name string) error { switch name { - case task.EdgeProfile: - m.ClearProfile() + case tenant.EdgeSettings: + m.ClearSettings() + return nil + case tenant.EdgeNetbird: + m.ClearNetbird() return nil } - return fmt.Errorf("unknown Task unique edge %s", name) + return fmt.Errorf("unknown Tenant unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *TaskMutation) ResetEdge(name string) error { +func (m *TenantMutation) ResetEdge(name string) error { switch name { - case task.EdgeTags: + case tenant.EdgeSites: + m.ResetSites() + return nil + case tenant.EdgeSettings: + m.ResetSettings() + return nil + case tenant.EdgeTags: m.ResetTags() return nil - case task.EdgeProfile: - m.ResetProfile() + case tenant.EdgeMetadata: + m.ResetMetadata() + return nil + case tenant.EdgeRustdesk: + m.ResetRustdesk() + return nil + case tenant.EdgeNetbird: + m.ResetNetbird() + return nil + case tenant.EdgeUserTenants: + m.ResetUserTenants() + return nil + case tenant.EdgeEnrollmentTokens: + m.ResetEnrollmentTokens() return nil } - return fmt.Errorf("unknown Task edge %s", name) + return fmt.Errorf("unknown Tenant edge %s", name) } -// TenantMutation represents an operation that mutates the Tenant nodes in the graph. -type TenantMutation struct { +// UpdateMutation represents an operation that mutates the Update nodes in the graph. +type UpdateMutation struct { config - op Op - typ string - id *int - description *string - is_default *bool - created *time.Time - modified *time.Time - clearedFields map[string]struct{} - sites map[int]struct{} - removedsites map[int]struct{} - clearedsites bool - settings *int - clearedsettings bool - tags map[int]struct{} - removedtags map[int]struct{} - clearedtags bool - metadata map[int]struct{} - removedmetadata map[int]struct{} - clearedmetadata bool - rustdesk map[int]struct{} - removedrustdesk map[int]struct{} - clearedrustdesk bool - netbird *int - clearednetbird bool - done bool - oldValue func(context.Context) (*Tenant, error) - predicates []predicate.Tenant + op Op + typ string + id *int + title *string + date *time.Time + support_url *string + clearedFields map[string]struct{} + owner *string + clearedowner bool + done bool + oldValue func(context.Context) (*Update, error) + predicates []predicate.Update } -var _ ent.Mutation = (*TenantMutation)(nil) +var _ ent.Mutation = (*UpdateMutation)(nil) -// tenantOption allows management of the mutation configuration using functional options. -type tenantOption func(*TenantMutation) +// updateOption allows management of the mutation configuration using functional options. +type updateOption func(*UpdateMutation) -// newTenantMutation creates new mutation for the Tenant entity. -func newTenantMutation(c config, op Op, opts ...tenantOption) *TenantMutation { - m := &TenantMutation{ +// newUpdateMutation creates new mutation for the Update entity. +func newUpdateMutation(c config, op Op, opts ...updateOption) *UpdateMutation { + m := &UpdateMutation{ config: c, op: op, - typ: TypeTenant, + typ: TypeUpdate, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -36661,20 +40260,20 @@ func newTenantMutation(c config, op Op, opts ...tenantOption) *TenantMutation { return m } -// withTenantID sets the ID field of the mutation. -func withTenantID(id int) tenantOption { - return func(m *TenantMutation) { +// withUpdateID sets the ID field of the mutation. +func withUpdateID(id int) updateOption { + return func(m *UpdateMutation) { var ( err error once sync.Once - value *Tenant + value *Update ) - m.oldValue = func(ctx context.Context) (*Tenant, error) { + m.oldValue = func(ctx context.Context) (*Update, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Tenant.Get(ctx, id) + value, err = m.Client().Update.Get(ctx, id) } }) return value, err @@ -36683,10 +40282,10 @@ func withTenantID(id int) tenantOption { } } -// withTenant sets the old Tenant of the mutation. -func withTenant(node *Tenant) tenantOption { - return func(m *TenantMutation) { - m.oldValue = func(context.Context) (*Tenant, error) { +// withUpdate sets the old Update of the mutation. +func withUpdate(node *Update) updateOption { + return func(m *UpdateMutation) { + m.oldValue = func(context.Context) (*Update, error) { return node, nil } m.id = &node.ID @@ -36695,7 +40294,7 @@ func withTenant(node *Tenant) tenantOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m TenantMutation) Client() *Client { +func (m UpdateMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -36703,7 +40302,7 @@ func (m TenantMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m TenantMutation) Tx() (*Tx, error) { +func (m UpdateMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -36714,7 +40313,7 @@ func (m TenantMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *TenantMutation) ID() (id int, exists bool) { +func (m *UpdateMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -36725,7 +40324,7 @@ func (m *TenantMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *TenantMutation) IDs(ctx context.Context) ([]int, error) { +func (m *UpdateMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -36734,511 +40333,181 @@ func (m *TenantMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Tenant.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Update.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetDescription sets the "description" field. -func (m *TenantMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *TenantMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Tenant entity. -// If the Tenant object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TenantMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ClearDescription clears the value of the "description" field. -func (m *TenantMutation) ClearDescription() { - m.description = nil - m.clearedFields[tenant.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *TenantMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[tenant.FieldDescription] - return ok -} - -// ResetDescription resets all changes to the "description" field. -func (m *TenantMutation) ResetDescription() { - m.description = nil - delete(m.clearedFields, tenant.FieldDescription) -} - -// SetIsDefault sets the "is_default" field. -func (m *TenantMutation) SetIsDefault(b bool) { - m.is_default = &b -} - -// IsDefault returns the value of the "is_default" field in the mutation. -func (m *TenantMutation) IsDefault() (r bool, exists bool) { - v := m.is_default - if v == nil { - return - } - return *v, true -} - -// OldIsDefault returns the old "is_default" field's value of the Tenant entity. -// If the Tenant object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TenantMutation) OldIsDefault(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsDefault requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) - } - return oldValue.IsDefault, nil -} - -// ClearIsDefault clears the value of the "is_default" field. -func (m *TenantMutation) ClearIsDefault() { - m.is_default = nil - m.clearedFields[tenant.FieldIsDefault] = struct{}{} -} - -// IsDefaultCleared returns if the "is_default" field was cleared in this mutation. -func (m *TenantMutation) IsDefaultCleared() bool { - _, ok := m.clearedFields[tenant.FieldIsDefault] - return ok -} - -// ResetIsDefault resets all changes to the "is_default" field. -func (m *TenantMutation) ResetIsDefault() { - m.is_default = nil - delete(m.clearedFields, tenant.FieldIsDefault) -} - -// SetCreated sets the "created" field. -func (m *TenantMutation) SetCreated(t time.Time) { - m.created = &t -} - -// Created returns the value of the "created" field in the mutation. -func (m *TenantMutation) Created() (r time.Time, exists bool) { - v := m.created - if v == nil { - return - } - return *v, true -} - -// OldCreated returns the old "created" field's value of the Tenant entity. -// If the Tenant object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TenantMutation) OldCreated(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreated is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreated requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreated: %w", err) - } - return oldValue.Created, nil -} - -// ClearCreated clears the value of the "created" field. -func (m *TenantMutation) ClearCreated() { - m.created = nil - m.clearedFields[tenant.FieldCreated] = struct{}{} -} - -// CreatedCleared returns if the "created" field was cleared in this mutation. -func (m *TenantMutation) CreatedCleared() bool { - _, ok := m.clearedFields[tenant.FieldCreated] - return ok -} - -// ResetCreated resets all changes to the "created" field. -func (m *TenantMutation) ResetCreated() { - m.created = nil - delete(m.clearedFields, tenant.FieldCreated) -} - -// SetModified sets the "modified" field. -func (m *TenantMutation) SetModified(t time.Time) { - m.modified = &t +// SetTitle sets the "title" field. +func (m *UpdateMutation) SetTitle(s string) { + m.title = &s } -// Modified returns the value of the "modified" field in the mutation. -func (m *TenantMutation) Modified() (r time.Time, exists bool) { - v := m.modified +// Title returns the value of the "title" field in the mutation. +func (m *UpdateMutation) Title() (r string, exists bool) { + v := m.title if v == nil { return } return *v, true } -// OldModified returns the old "modified" field's value of the Tenant entity. -// If the Tenant object wasn't provided to the builder, the object is fetched from the database. +// OldTitle returns the old "title" field's value of the Update entity. +// If the Update object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TenantMutation) OldModified(ctx context.Context) (v time.Time, err error) { +func (m *UpdateMutation) OldTitle(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModified is only allowed on UpdateOne operations") + return v, errors.New("OldTitle is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModified requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModified: %w", err) - } - return oldValue.Modified, nil -} - -// ClearModified clears the value of the "modified" field. -func (m *TenantMutation) ClearModified() { - m.modified = nil - m.clearedFields[tenant.FieldModified] = struct{}{} -} - -// ModifiedCleared returns if the "modified" field was cleared in this mutation. -func (m *TenantMutation) ModifiedCleared() bool { - _, ok := m.clearedFields[tenant.FieldModified] - return ok -} - -// ResetModified resets all changes to the "modified" field. -func (m *TenantMutation) ResetModified() { - m.modified = nil - delete(m.clearedFields, tenant.FieldModified) -} - -// AddSiteIDs adds the "sites" edge to the Site entity by ids. -func (m *TenantMutation) AddSiteIDs(ids ...int) { - if m.sites == nil { - m.sites = make(map[int]struct{}) - } - for i := range ids { - m.sites[ids[i]] = struct{}{} - } -} - -// ClearSites clears the "sites" edge to the Site entity. -func (m *TenantMutation) ClearSites() { - m.clearedsites = true -} - -// SitesCleared reports if the "sites" edge to the Site entity was cleared. -func (m *TenantMutation) SitesCleared() bool { - return m.clearedsites -} - -// RemoveSiteIDs removes the "sites" edge to the Site entity by IDs. -func (m *TenantMutation) RemoveSiteIDs(ids ...int) { - if m.removedsites == nil { - m.removedsites = make(map[int]struct{}) - } - for i := range ids { - delete(m.sites, ids[i]) - m.removedsites[ids[i]] = struct{}{} - } -} - -// RemovedSites returns the removed IDs of the "sites" edge to the Site entity. -func (m *TenantMutation) RemovedSitesIDs() (ids []int) { - for id := range m.removedsites { - ids = append(ids, id) - } - return -} - -// SitesIDs returns the "sites" edge IDs in the mutation. -func (m *TenantMutation) SitesIDs() (ids []int) { - for id := range m.sites { - ids = append(ids, id) - } - return -} - -// ResetSites resets all changes to the "sites" edge. -func (m *TenantMutation) ResetSites() { - m.sites = nil - m.clearedsites = false - m.removedsites = nil -} - -// SetSettingsID sets the "settings" edge to the Settings entity by id. -func (m *TenantMutation) SetSettingsID(id int) { - m.settings = &id -} - -// ClearSettings clears the "settings" edge to the Settings entity. -func (m *TenantMutation) ClearSettings() { - m.clearedsettings = true -} - -// SettingsCleared reports if the "settings" edge to the Settings entity was cleared. -func (m *TenantMutation) SettingsCleared() bool { - return m.clearedsettings -} - -// SettingsID returns the "settings" edge ID in the mutation. -func (m *TenantMutation) SettingsID() (id int, exists bool) { - if m.settings != nil { - return *m.settings, true - } - return -} - -// SettingsIDs returns the "settings" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// SettingsID instead. It exists only for internal usage by the builders. -func (m *TenantMutation) SettingsIDs() (ids []int) { - if id := m.settings; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetSettings resets all changes to the "settings" edge. -func (m *TenantMutation) ResetSettings() { - m.settings = nil - m.clearedsettings = false -} - -// AddTagIDs adds the "tags" edge to the Tag entity by ids. -func (m *TenantMutation) AddTagIDs(ids ...int) { - if m.tags == nil { - m.tags = make(map[int]struct{}) - } - for i := range ids { - m.tags[ids[i]] = struct{}{} - } -} - -// ClearTags clears the "tags" edge to the Tag entity. -func (m *TenantMutation) ClearTags() { - m.clearedtags = true -} - -// TagsCleared reports if the "tags" edge to the Tag entity was cleared. -func (m *TenantMutation) TagsCleared() bool { - return m.clearedtags -} - -// RemoveTagIDs removes the "tags" edge to the Tag entity by IDs. -func (m *TenantMutation) RemoveTagIDs(ids ...int) { - if m.removedtags == nil { - m.removedtags = make(map[int]struct{}) - } - for i := range ids { - delete(m.tags, ids[i]) - m.removedtags[ids[i]] = struct{}{} - } -} - -// RemovedTags returns the removed IDs of the "tags" edge to the Tag entity. -func (m *TenantMutation) RemovedTagsIDs() (ids []int) { - for id := range m.removedtags { - ids = append(ids, id) - } - return -} - -// TagsIDs returns the "tags" edge IDs in the mutation. -func (m *TenantMutation) TagsIDs() (ids []int) { - for id := range m.tags { - ids = append(ids, id) - } - return -} - -// ResetTags resets all changes to the "tags" edge. -func (m *TenantMutation) ResetTags() { - m.tags = nil - m.clearedtags = false - m.removedtags = nil -} - -// AddMetadatumIDs adds the "metadata" edge to the OrgMetadata entity by ids. -func (m *TenantMutation) AddMetadatumIDs(ids ...int) { - if m.metadata == nil { - m.metadata = make(map[int]struct{}) + return v, errors.New("OldTitle requires an ID field in the mutation") } - for i := range ids { - m.metadata[ids[i]] = struct{}{} + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTitle: %w", err) } + return oldValue.Title, nil } -// ClearMetadata clears the "metadata" edge to the OrgMetadata entity. -func (m *TenantMutation) ClearMetadata() { - m.clearedmetadata = true +// ResetTitle resets all changes to the "title" field. +func (m *UpdateMutation) ResetTitle() { + m.title = nil } -// MetadataCleared reports if the "metadata" edge to the OrgMetadata entity was cleared. -func (m *TenantMutation) MetadataCleared() bool { - return m.clearedmetadata +// SetDate sets the "date" field. +func (m *UpdateMutation) SetDate(t time.Time) { + m.date = &t } -// RemoveMetadatumIDs removes the "metadata" edge to the OrgMetadata entity by IDs. -func (m *TenantMutation) RemoveMetadatumIDs(ids ...int) { - if m.removedmetadata == nil { - m.removedmetadata = make(map[int]struct{}) - } - for i := range ids { - delete(m.metadata, ids[i]) - m.removedmetadata[ids[i]] = struct{}{} +// Date returns the value of the "date" field in the mutation. +func (m *UpdateMutation) Date() (r time.Time, exists bool) { + v := m.date + if v == nil { + return } + return *v, true } -// RemovedMetadata returns the removed IDs of the "metadata" edge to the OrgMetadata entity. -func (m *TenantMutation) RemovedMetadataIDs() (ids []int) { - for id := range m.removedmetadata { - ids = append(ids, id) +// OldDate returns the old "date" field's value of the Update entity. +// If the Update object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UpdateMutation) OldDate(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDate is only allowed on UpdateOne operations") } - return -} - -// MetadataIDs returns the "metadata" edge IDs in the mutation. -func (m *TenantMutation) MetadataIDs() (ids []int) { - for id := range m.metadata { - ids = append(ids, id) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDate requires an ID field in the mutation") } - return -} - -// ResetMetadata resets all changes to the "metadata" edge. -func (m *TenantMutation) ResetMetadata() { - m.metadata = nil - m.clearedmetadata = false - m.removedmetadata = nil + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDate: %w", err) + } + return oldValue.Date, nil } -// AddRustdeskIDs adds the "rustdesk" edge to the Rustdesk entity by ids. -func (m *TenantMutation) AddRustdeskIDs(ids ...int) { - if m.rustdesk == nil { - m.rustdesk = make(map[int]struct{}) - } - for i := range ids { - m.rustdesk[ids[i]] = struct{}{} - } +// ResetDate resets all changes to the "date" field. +func (m *UpdateMutation) ResetDate() { + m.date = nil } -// ClearRustdesk clears the "rustdesk" edge to the Rustdesk entity. -func (m *TenantMutation) ClearRustdesk() { - m.clearedrustdesk = true +// SetSupportURL sets the "support_url" field. +func (m *UpdateMutation) SetSupportURL(s string) { + m.support_url = &s } -// RustdeskCleared reports if the "rustdesk" edge to the Rustdesk entity was cleared. -func (m *TenantMutation) RustdeskCleared() bool { - return m.clearedrustdesk +// SupportURL returns the value of the "support_url" field in the mutation. +func (m *UpdateMutation) SupportURL() (r string, exists bool) { + v := m.support_url + if v == nil { + return + } + return *v, true } -// RemoveRustdeskIDs removes the "rustdesk" edge to the Rustdesk entity by IDs. -func (m *TenantMutation) RemoveRustdeskIDs(ids ...int) { - if m.removedrustdesk == nil { - m.removedrustdesk = make(map[int]struct{}) +// OldSupportURL returns the old "support_url" field's value of the Update entity. +// If the Update object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UpdateMutation) OldSupportURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSupportURL is only allowed on UpdateOne operations") } - for i := range ids { - delete(m.rustdesk, ids[i]) - m.removedrustdesk[ids[i]] = struct{}{} + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSupportURL requires an ID field in the mutation") } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSupportURL: %w", err) + } + return oldValue.SupportURL, nil } -// RemovedRustdesk returns the removed IDs of the "rustdesk" edge to the Rustdesk entity. -func (m *TenantMutation) RemovedRustdeskIDs() (ids []int) { - for id := range m.removedrustdesk { - ids = append(ids, id) - } - return +// ClearSupportURL clears the value of the "support_url" field. +func (m *UpdateMutation) ClearSupportURL() { + m.support_url = nil + m.clearedFields[update.FieldSupportURL] = struct{}{} } -// RustdeskIDs returns the "rustdesk" edge IDs in the mutation. -func (m *TenantMutation) RustdeskIDs() (ids []int) { - for id := range m.rustdesk { - ids = append(ids, id) - } - return +// SupportURLCleared returns if the "support_url" field was cleared in this mutation. +func (m *UpdateMutation) SupportURLCleared() bool { + _, ok := m.clearedFields[update.FieldSupportURL] + return ok } -// ResetRustdesk resets all changes to the "rustdesk" edge. -func (m *TenantMutation) ResetRustdesk() { - m.rustdesk = nil - m.clearedrustdesk = false - m.removedrustdesk = nil +// ResetSupportURL resets all changes to the "support_url" field. +func (m *UpdateMutation) ResetSupportURL() { + m.support_url = nil + delete(m.clearedFields, update.FieldSupportURL) } -// SetNetbirdID sets the "netbird" edge to the NetbirdSettings entity by id. -func (m *TenantMutation) SetNetbirdID(id int) { - m.netbird = &id +// SetOwnerID sets the "owner" edge to the Agent entity by id. +func (m *UpdateMutation) SetOwnerID(id string) { + m.owner = &id } -// ClearNetbird clears the "netbird" edge to the NetbirdSettings entity. -func (m *TenantMutation) ClearNetbird() { - m.clearednetbird = true +// ClearOwner clears the "owner" edge to the Agent entity. +func (m *UpdateMutation) ClearOwner() { + m.clearedowner = true } -// NetbirdCleared reports if the "netbird" edge to the NetbirdSettings entity was cleared. -func (m *TenantMutation) NetbirdCleared() bool { - return m.clearednetbird +// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. +func (m *UpdateMutation) OwnerCleared() bool { + return m.clearedowner } -// NetbirdID returns the "netbird" edge ID in the mutation. -func (m *TenantMutation) NetbirdID() (id int, exists bool) { - if m.netbird != nil { - return *m.netbird, true +// OwnerID returns the "owner" edge ID in the mutation. +func (m *UpdateMutation) OwnerID() (id string, exists bool) { + if m.owner != nil { + return *m.owner, true } return } -// NetbirdIDs returns the "netbird" edge IDs in the mutation. +// OwnerIDs returns the "owner" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// NetbirdID instead. It exists only for internal usage by the builders. -func (m *TenantMutation) NetbirdIDs() (ids []int) { - if id := m.netbird; id != nil { +// OwnerID instead. It exists only for internal usage by the builders. +func (m *UpdateMutation) OwnerIDs() (ids []string) { + if id := m.owner; id != nil { ids = append(ids, *id) } return } -// ResetNetbird resets all changes to the "netbird" edge. -func (m *TenantMutation) ResetNetbird() { - m.netbird = nil - m.clearednetbird = false +// ResetOwner resets all changes to the "owner" edge. +func (m *UpdateMutation) ResetOwner() { + m.owner = nil + m.clearedowner = false } -// Where appends a list predicates to the TenantMutation builder. -func (m *TenantMutation) Where(ps ...predicate.Tenant) { +// Where appends a list predicates to the UpdateMutation builder. +func (m *UpdateMutation) Where(ps ...predicate.Update) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the TenantMutation builder. Using this method, +// WhereP appends storage-level predicates to the UpdateMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *TenantMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Tenant, len(ps)) +func (m *UpdateMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Update, len(ps)) for i := range ps { p[i] = ps[i] } @@ -37246,36 +40515,33 @@ func (m *TenantMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *TenantMutation) Op() Op { +func (m *UpdateMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *TenantMutation) SetOp(op Op) { +func (m *UpdateMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Tenant). -func (m *TenantMutation) Type() string { +// Type returns the node type of this mutation (Update). +func (m *UpdateMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *TenantMutation) Fields() []string { - fields := make([]string, 0, 4) - if m.description != nil { - fields = append(fields, tenant.FieldDescription) - } - if m.is_default != nil { - fields = append(fields, tenant.FieldIsDefault) +func (m *UpdateMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.title != nil { + fields = append(fields, update.FieldTitle) } - if m.created != nil { - fields = append(fields, tenant.FieldCreated) + if m.date != nil { + fields = append(fields, update.FieldDate) } - if m.modified != nil { - fields = append(fields, tenant.FieldModified) + if m.support_url != nil { + fields = append(fields, update.FieldSupportURL) } return fields } @@ -37283,16 +40549,14 @@ func (m *TenantMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *TenantMutation) Field(name string) (ent.Value, bool) { +func (m *UpdateMutation) Field(name string) (ent.Value, bool) { switch name { - case tenant.FieldDescription: - return m.Description() - case tenant.FieldIsDefault: - return m.IsDefault() - case tenant.FieldCreated: - return m.Created() - case tenant.FieldModified: - return m.Modified() + case update.FieldTitle: + return m.Title() + case update.FieldDate: + return m.Date() + case update.FieldSupportURL: + return m.SupportURL() } return nil, false } @@ -37300,203 +40564,130 @@ func (m *TenantMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *TenantMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *UpdateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case tenant.FieldDescription: - return m.OldDescription(ctx) - case tenant.FieldIsDefault: - return m.OldIsDefault(ctx) - case tenant.FieldCreated: - return m.OldCreated(ctx) - case tenant.FieldModified: - return m.OldModified(ctx) + case update.FieldTitle: + return m.OldTitle(ctx) + case update.FieldDate: + return m.OldDate(ctx) + case update.FieldSupportURL: + return m.OldSupportURL(ctx) } - return nil, fmt.Errorf("unknown Tenant field %s", name) + return nil, fmt.Errorf("unknown Update field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *TenantMutation) SetField(name string, value ent.Value) error { +func (m *UpdateMutation) SetField(name string, value ent.Value) error { switch name { - case tenant.FieldDescription: + case update.FieldTitle: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDescription(v) - return nil - case tenant.FieldIsDefault: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIsDefault(v) + m.SetTitle(v) return nil - case tenant.FieldCreated: + case update.FieldDate: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreated(v) + m.SetDate(v) return nil - case tenant.FieldModified: - v, ok := value.(time.Time) + case update.FieldSupportURL: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetModified(v) + m.SetSupportURL(v) return nil } - return fmt.Errorf("unknown Tenant field %s", name) + return fmt.Errorf("unknown Update field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *TenantMutation) AddedFields() []string { +func (m *UpdateMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *TenantMutation) AddedField(name string) (ent.Value, bool) { +func (m *UpdateMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *TenantMutation) AddField(name string, value ent.Value) error { +func (m *UpdateMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown Tenant numeric field %s", name) + return fmt.Errorf("unknown Update numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *TenantMutation) ClearedFields() []string { +func (m *UpdateMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(tenant.FieldDescription) { - fields = append(fields, tenant.FieldDescription) - } - if m.FieldCleared(tenant.FieldIsDefault) { - fields = append(fields, tenant.FieldIsDefault) - } - if m.FieldCleared(tenant.FieldCreated) { - fields = append(fields, tenant.FieldCreated) - } - if m.FieldCleared(tenant.FieldModified) { - fields = append(fields, tenant.FieldModified) + if m.FieldCleared(update.FieldSupportURL) { + fields = append(fields, update.FieldSupportURL) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *TenantMutation) FieldCleared(name string) bool { +func (m *UpdateMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *TenantMutation) ClearField(name string) error { +func (m *UpdateMutation) ClearField(name string) error { switch name { - case tenant.FieldDescription: - m.ClearDescription() - return nil - case tenant.FieldIsDefault: - m.ClearIsDefault() - return nil - case tenant.FieldCreated: - m.ClearCreated() - return nil - case tenant.FieldModified: - m.ClearModified() + case update.FieldSupportURL: + m.ClearSupportURL() return nil } - return fmt.Errorf("unknown Tenant nullable field %s", name) + return fmt.Errorf("unknown Update nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *TenantMutation) ResetField(name string) error { +func (m *UpdateMutation) ResetField(name string) error { switch name { - case tenant.FieldDescription: - m.ResetDescription() - return nil - case tenant.FieldIsDefault: - m.ResetIsDefault() + case update.FieldTitle: + m.ResetTitle() return nil - case tenant.FieldCreated: - m.ResetCreated() + case update.FieldDate: + m.ResetDate() return nil - case tenant.FieldModified: - m.ResetModified() + case update.FieldSupportURL: + m.ResetSupportURL() return nil } - return fmt.Errorf("unknown Tenant field %s", name) + return fmt.Errorf("unknown Update field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *TenantMutation) AddedEdges() []string { - edges := make([]string, 0, 6) - if m.sites != nil { - edges = append(edges, tenant.EdgeSites) - } - if m.settings != nil { - edges = append(edges, tenant.EdgeSettings) - } - if m.tags != nil { - edges = append(edges, tenant.EdgeTags) - } - if m.metadata != nil { - edges = append(edges, tenant.EdgeMetadata) - } - if m.rustdesk != nil { - edges = append(edges, tenant.EdgeRustdesk) - } - if m.netbird != nil { - edges = append(edges, tenant.EdgeNetbird) +func (m *UpdateMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.owner != nil { + edges = append(edges, update.EdgeOwner) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *TenantMutation) AddedIDs(name string) []ent.Value { +func (m *UpdateMutation) AddedIDs(name string) []ent.Value { switch name { - case tenant.EdgeSites: - ids := make([]ent.Value, 0, len(m.sites)) - for id := range m.sites { - ids = append(ids, id) - } - return ids - case tenant.EdgeSettings: - if id := m.settings; id != nil { - return []ent.Value{*id} - } - case tenant.EdgeTags: - ids := make([]ent.Value, 0, len(m.tags)) - for id := range m.tags { - ids = append(ids, id) - } - return ids - case tenant.EdgeMetadata: - ids := make([]ent.Value, 0, len(m.metadata)) - for id := range m.metadata { - ids = append(ids, id) - } - return ids - case tenant.EdgeRustdesk: - ids := make([]ent.Value, 0, len(m.rustdesk)) - for id := range m.rustdesk { - ids = append(ids, id) - } - return ids - case tenant.EdgeNetbird: - if id := m.netbird; id != nil { + case update.EdgeOwner: + if id := m.owner; id != nil { return []ent.Value{*id} } } @@ -37504,167 +40695,115 @@ func (m *TenantMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *TenantMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) - if m.removedsites != nil { - edges = append(edges, tenant.EdgeSites) - } - if m.removedtags != nil { - edges = append(edges, tenant.EdgeTags) - } - if m.removedmetadata != nil { - edges = append(edges, tenant.EdgeMetadata) - } - if m.removedrustdesk != nil { - edges = append(edges, tenant.EdgeRustdesk) - } +func (m *UpdateMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *TenantMutation) RemovedIDs(name string) []ent.Value { - switch name { - case tenant.EdgeSites: - ids := make([]ent.Value, 0, len(m.removedsites)) - for id := range m.removedsites { - ids = append(ids, id) - } - return ids - case tenant.EdgeTags: - ids := make([]ent.Value, 0, len(m.removedtags)) - for id := range m.removedtags { - ids = append(ids, id) - } - return ids - case tenant.EdgeMetadata: - ids := make([]ent.Value, 0, len(m.removedmetadata)) - for id := range m.removedmetadata { - ids = append(ids, id) - } - return ids - case tenant.EdgeRustdesk: - ids := make([]ent.Value, 0, len(m.removedrustdesk)) - for id := range m.removedrustdesk { - ids = append(ids, id) - } - return ids - } +func (m *UpdateMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *TenantMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) - if m.clearedsites { - edges = append(edges, tenant.EdgeSites) - } - if m.clearedsettings { - edges = append(edges, tenant.EdgeSettings) - } - if m.clearedtags { - edges = append(edges, tenant.EdgeTags) - } - if m.clearedmetadata { - edges = append(edges, tenant.EdgeMetadata) - } - if m.clearedrustdesk { - edges = append(edges, tenant.EdgeRustdesk) - } - if m.clearednetbird { - edges = append(edges, tenant.EdgeNetbird) +func (m *UpdateMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedowner { + edges = append(edges, update.EdgeOwner) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *TenantMutation) EdgeCleared(name string) bool { +func (m *UpdateMutation) EdgeCleared(name string) bool { switch name { - case tenant.EdgeSites: - return m.clearedsites - case tenant.EdgeSettings: - return m.clearedsettings - case tenant.EdgeTags: - return m.clearedtags - case tenant.EdgeMetadata: - return m.clearedmetadata - case tenant.EdgeRustdesk: - return m.clearedrustdesk - case tenant.EdgeNetbird: - return m.clearednetbird + case update.EdgeOwner: + return m.clearedowner } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *TenantMutation) ClearEdge(name string) error { +func (m *UpdateMutation) ClearEdge(name string) error { switch name { - case tenant.EdgeSettings: - m.ClearSettings() - return nil - case tenant.EdgeNetbird: - m.ClearNetbird() + case update.EdgeOwner: + m.ClearOwner() return nil } - return fmt.Errorf("unknown Tenant unique edge %s", name) + return fmt.Errorf("unknown Update unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *TenantMutation) ResetEdge(name string) error { +func (m *UpdateMutation) ResetEdge(name string) error { switch name { - case tenant.EdgeSites: - m.ResetSites() - return nil - case tenant.EdgeSettings: - m.ResetSettings() - return nil - case tenant.EdgeTags: - m.ResetTags() - return nil - case tenant.EdgeMetadata: - m.ResetMetadata() - return nil - case tenant.EdgeRustdesk: - m.ResetRustdesk() - return nil - case tenant.EdgeNetbird: - m.ResetNetbird() + case update.EdgeOwner: + m.ResetOwner() return nil } - return fmt.Errorf("unknown Tenant edge %s", name) + return fmt.Errorf("unknown Update edge %s", name) } -// UpdateMutation represents an operation that mutates the Update nodes in the graph. -type UpdateMutation struct { +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { config - op Op - typ string - id *int - title *string - date *time.Time - support_url *string - clearedFields map[string]struct{} - owner *string - clearedowner bool - done bool - oldValue func(context.Context) (*Update, error) - predicates []predicate.Update + op Op + typ string + id *string + name *string + email *string + phone *string + country *string + email_verified *bool + register *string + cert_clear_password *string + expiry *time.Time + openid *bool + passwd *bool + use2fa *bool + created *time.Time + modified *time.Time + access_token *string + refresh_token *string + id_token *string + token_type *string + token_expiry *int + addtoken_expiry *int + hash *string + totp_secret *string + totp_secret_confirmed *bool + forgot_password_code *string + forgot_password_code_expires_at *time.Time + new_user_token *string + clearedFields map[string]struct{} + sessions map[string]struct{} + removedsessions map[string]struct{} + clearedsessions bool + recoverycodes map[int]struct{} + removedrecoverycodes map[int]struct{} + clearedrecoverycodes bool + user_tenants map[int]struct{} + removeduser_tenants map[int]struct{} + cleareduser_tenants bool + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User } -var _ ent.Mutation = (*UpdateMutation)(nil) +var _ ent.Mutation = (*UserMutation)(nil) -// updateOption allows management of the mutation configuration using functional options. -type updateOption func(*UpdateMutation) +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) -// newUpdateMutation creates new mutation for the Update entity. -func newUpdateMutation(c config, op Op, opts ...updateOption) *UpdateMutation { - m := &UpdateMutation{ +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ config: c, op: op, - typ: TypeUpdate, + typ: TypeUser, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -37673,20 +40812,20 @@ func newUpdateMutation(c config, op Op, opts ...updateOption) *UpdateMutation { return m } -// withUpdateID sets the ID field of the mutation. -func withUpdateID(id int) updateOption { - return func(m *UpdateMutation) { +// withUserID sets the ID field of the mutation. +func withUserID(id string) userOption { + return func(m *UserMutation) { var ( err error once sync.Once - value *Update + value *User ) - m.oldValue = func(ctx context.Context) (*Update, error) { + m.oldValue = func(ctx context.Context) (*User, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Update.Get(ctx, id) + value, err = m.Client().User.Get(ctx, id) } }) return value, err @@ -37695,10 +40834,10 @@ func withUpdateID(id int) updateOption { } } -// withUpdate sets the old Update of the mutation. -func withUpdate(node *Update) updateOption { - return func(m *UpdateMutation) { - m.oldValue = func(context.Context) (*Update, error) { +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, error) { return node, nil } m.id = &node.ID @@ -37707,7 +40846,7 @@ func withUpdate(node *Update) updateOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m UpdateMutation) Client() *Client { +func (m UserMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -37715,7 +40854,7 @@ func (m UpdateMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m UpdateMutation) Tx() (*Tx, error) { +func (m UserMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -37724,9 +40863,15 @@ func (m UpdateMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of User entities. +func (m *UserMutation) SetID(id string) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *UpdateMutation) ID() (id int, exists bool) { +func (m *UserMutation) ID() (id string, exists bool) { if m.id == nil { return } @@ -37737,1851 +40882,2566 @@ func (m *UpdateMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *UpdateMutation) IDs(ctx context.Context) ([]int, error) { +func (m *UserMutation) IDs(ctx context.Context) ([]string, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []string{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Update.Query().Where(m.predicates...).IDs(ctx) + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetTitle sets the "title" field. -func (m *UpdateMutation) SetTitle(s string) { - m.title = &s +// SetName sets the "name" field. +func (m *UserMutation) SetName(s string) { + m.name = &s } -// Title returns the value of the "title" field in the mutation. -func (m *UpdateMutation) Title() (r string, exists bool) { - v := m.title +// Name returns the value of the "name" field in the mutation. +func (m *UserMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldTitle returns the old "title" field's value of the Update entity. -// If the Update object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UpdateMutation) OldTitle(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTitle is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTitle requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTitle: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Title, nil + return oldValue.Name, nil } -// ResetTitle resets all changes to the "title" field. -func (m *UpdateMutation) ResetTitle() { - m.title = nil +// ResetName resets all changes to the "name" field. +func (m *UserMutation) ResetName() { + m.name = nil } -// SetDate sets the "date" field. -func (m *UpdateMutation) SetDate(t time.Time) { - m.date = &t +// SetEmail sets the "email" field. +func (m *UserMutation) SetEmail(s string) { + m.email = &s } -// Date returns the value of the "date" field in the mutation. -func (m *UpdateMutation) Date() (r time.Time, exists bool) { - v := m.date +// Email returns the value of the "email" field in the mutation. +func (m *UserMutation) Email() (r string, exists bool) { + v := m.email if v == nil { return } return *v, true } -// OldDate returns the old "date" field's value of the Update entity. -// If the Update object wasn't provided to the builder, the object is fetched from the database. +// OldEmail returns the old "email" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UpdateMutation) OldDate(ctx context.Context) (v time.Time, err error) { +func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDate is only allowed on UpdateOne operations") + return v, errors.New("OldEmail is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDate requires an ID field in the mutation") + return v, errors.New("OldEmail requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDate: %w", err) + return v, fmt.Errorf("querying old value for OldEmail: %w", err) } - return oldValue.Date, nil + return oldValue.Email, nil } -// ResetDate resets all changes to the "date" field. -func (m *UpdateMutation) ResetDate() { - m.date = nil +// ClearEmail clears the value of the "email" field. +func (m *UserMutation) ClearEmail() { + m.email = nil + m.clearedFields[user.FieldEmail] = struct{}{} } -// SetSupportURL sets the "support_url" field. -func (m *UpdateMutation) SetSupportURL(s string) { - m.support_url = &s +// EmailCleared returns if the "email" field was cleared in this mutation. +func (m *UserMutation) EmailCleared() bool { + _, ok := m.clearedFields[user.FieldEmail] + return ok } -// SupportURL returns the value of the "support_url" field in the mutation. -func (m *UpdateMutation) SupportURL() (r string, exists bool) { - v := m.support_url +// ResetEmail resets all changes to the "email" field. +func (m *UserMutation) ResetEmail() { + m.email = nil + delete(m.clearedFields, user.FieldEmail) +} + +// SetPhone sets the "phone" field. +func (m *UserMutation) SetPhone(s string) { + m.phone = &s +} + +// Phone returns the value of the "phone" field in the mutation. +func (m *UserMutation) Phone() (r string, exists bool) { + v := m.phone if v == nil { return } return *v, true } -// OldSupportURL returns the old "support_url" field's value of the Update entity. -// If the Update object wasn't provided to the builder, the object is fetched from the database. +// OldPhone returns the old "phone" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UpdateMutation) OldSupportURL(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSupportURL is only allowed on UpdateOne operations") + return v, errors.New("OldPhone is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSupportURL requires an ID field in the mutation") + return v, errors.New("OldPhone requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSupportURL: %w", err) + return v, fmt.Errorf("querying old value for OldPhone: %w", err) } - return oldValue.SupportURL, nil + return oldValue.Phone, nil } -// ClearSupportURL clears the value of the "support_url" field. -func (m *UpdateMutation) ClearSupportURL() { - m.support_url = nil - m.clearedFields[update.FieldSupportURL] = struct{}{} +// ClearPhone clears the value of the "phone" field. +func (m *UserMutation) ClearPhone() { + m.phone = nil + m.clearedFields[user.FieldPhone] = struct{}{} } -// SupportURLCleared returns if the "support_url" field was cleared in this mutation. -func (m *UpdateMutation) SupportURLCleared() bool { - _, ok := m.clearedFields[update.FieldSupportURL] +// PhoneCleared returns if the "phone" field was cleared in this mutation. +func (m *UserMutation) PhoneCleared() bool { + _, ok := m.clearedFields[user.FieldPhone] return ok } -// ResetSupportURL resets all changes to the "support_url" field. -func (m *UpdateMutation) ResetSupportURL() { - m.support_url = nil - delete(m.clearedFields, update.FieldSupportURL) +// ResetPhone resets all changes to the "phone" field. +func (m *UserMutation) ResetPhone() { + m.phone = nil + delete(m.clearedFields, user.FieldPhone) } -// SetOwnerID sets the "owner" edge to the Agent entity by id. -func (m *UpdateMutation) SetOwnerID(id string) { - m.owner = &id +// SetCountry sets the "country" field. +func (m *UserMutation) SetCountry(s string) { + m.country = &s } -// ClearOwner clears the "owner" edge to the Agent entity. -func (m *UpdateMutation) ClearOwner() { - m.clearedowner = true +// Country returns the value of the "country" field in the mutation. +func (m *UserMutation) Country() (r string, exists bool) { + v := m.country + if v == nil { + return + } + return *v, true } -// OwnerCleared reports if the "owner" edge to the Agent entity was cleared. -func (m *UpdateMutation) OwnerCleared() bool { - return m.clearedowner +// OldCountry returns the old "country" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCountry(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCountry is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCountry requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCountry: %w", err) + } + return oldValue.Country, nil } -// OwnerID returns the "owner" edge ID in the mutation. -func (m *UpdateMutation) OwnerID() (id string, exists bool) { - if m.owner != nil { - return *m.owner, true +// ClearCountry clears the value of the "country" field. +func (m *UserMutation) ClearCountry() { + m.country = nil + m.clearedFields[user.FieldCountry] = struct{}{} +} + +// CountryCleared returns if the "country" field was cleared in this mutation. +func (m *UserMutation) CountryCleared() bool { + _, ok := m.clearedFields[user.FieldCountry] + return ok +} + +// ResetCountry resets all changes to the "country" field. +func (m *UserMutation) ResetCountry() { + m.country = nil + delete(m.clearedFields, user.FieldCountry) +} + +// SetEmailVerified sets the "email_verified" field. +func (m *UserMutation) SetEmailVerified(b bool) { + m.email_verified = &b +} + +// EmailVerified returns the value of the "email_verified" field in the mutation. +func (m *UserMutation) EmailVerified() (r bool, exists bool) { + v := m.email_verified + if v == nil { + return } - return + return *v, true } -// OwnerIDs returns the "owner" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// OwnerID instead. It exists only for internal usage by the builders. -func (m *UpdateMutation) OwnerIDs() (ids []string) { - if id := m.owner; id != nil { - ids = append(ids, *id) +// OldEmailVerified returns the old "email_verified" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldEmailVerified(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmailVerified is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmailVerified requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmailVerified: %w", err) + } + return oldValue.EmailVerified, nil } -// ResetOwner resets all changes to the "owner" edge. -func (m *UpdateMutation) ResetOwner() { - m.owner = nil - m.clearedowner = false +// ResetEmailVerified resets all changes to the "email_verified" field. +func (m *UserMutation) ResetEmailVerified() { + m.email_verified = nil } -// Where appends a list predicates to the UpdateMutation builder. -func (m *UpdateMutation) Where(ps ...predicate.Update) { - m.predicates = append(m.predicates, ps...) +// SetRegister sets the "register" field. +func (m *UserMutation) SetRegister(s string) { + m.register = &s } -// WhereP appends storage-level predicates to the UpdateMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UpdateMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Update, len(ps)) - for i := range ps { - p[i] = ps[i] +// Register returns the value of the "register" field in the mutation. +func (m *UserMutation) Register() (r string, exists bool) { + v := m.register + if v == nil { + return } - m.Where(p...) + return *v, true } -// Op returns the operation name. -func (m *UpdateMutation) Op() Op { - return m.op +// OldRegister returns the old "register" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldRegister(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRegister is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRegister requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRegister: %w", err) + } + return oldValue.Register, nil } -// SetOp allows setting the mutation operation. -func (m *UpdateMutation) SetOp(op Op) { - m.op = op +// ResetRegister resets all changes to the "register" field. +func (m *UserMutation) ResetRegister() { + m.register = nil } -// Type returns the node type of this mutation (Update). -func (m *UpdateMutation) Type() string { - return m.typ +// SetCertClearPassword sets the "cert_clear_password" field. +func (m *UserMutation) SetCertClearPassword(s string) { + m.cert_clear_password = &s } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *UpdateMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.title != nil { - fields = append(fields, update.FieldTitle) +// CertClearPassword returns the value of the "cert_clear_password" field in the mutation. +func (m *UserMutation) CertClearPassword() (r string, exists bool) { + v := m.cert_clear_password + if v == nil { + return } - if m.date != nil { - fields = append(fields, update.FieldDate) + return *v, true +} + +// OldCertClearPassword returns the old "cert_clear_password" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCertClearPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCertClearPassword is only allowed on UpdateOne operations") } - if m.support_url != nil { - fields = append(fields, update.FieldSupportURL) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCertClearPassword requires an ID field in the mutation") } - return fields + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCertClearPassword: %w", err) + } + return oldValue.CertClearPassword, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *UpdateMutation) Field(name string) (ent.Value, bool) { - switch name { - case update.FieldTitle: - return m.Title() - case update.FieldDate: - return m.Date() - case update.FieldSupportURL: - return m.SupportURL() +// ClearCertClearPassword clears the value of the "cert_clear_password" field. +func (m *UserMutation) ClearCertClearPassword() { + m.cert_clear_password = nil + m.clearedFields[user.FieldCertClearPassword] = struct{}{} +} + +// CertClearPasswordCleared returns if the "cert_clear_password" field was cleared in this mutation. +func (m *UserMutation) CertClearPasswordCleared() bool { + _, ok := m.clearedFields[user.FieldCertClearPassword] + return ok +} + +// ResetCertClearPassword resets all changes to the "cert_clear_password" field. +func (m *UserMutation) ResetCertClearPassword() { + m.cert_clear_password = nil + delete(m.clearedFields, user.FieldCertClearPassword) +} + +// SetExpiry sets the "expiry" field. +func (m *UserMutation) SetExpiry(t time.Time) { + m.expiry = &t +} + +// Expiry returns the value of the "expiry" field in the mutation. +func (m *UserMutation) Expiry() (r time.Time, exists bool) { + v := m.expiry + if v == nil { + return } - return nil, false + return *v, true +} + +// OldExpiry returns the old "expiry" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExpiry is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExpiry requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExpiry: %w", err) + } + return oldValue.Expiry, nil +} + +// ClearExpiry clears the value of the "expiry" field. +func (m *UserMutation) ClearExpiry() { + m.expiry = nil + m.clearedFields[user.FieldExpiry] = struct{}{} +} + +// ExpiryCleared returns if the "expiry" field was cleared in this mutation. +func (m *UserMutation) ExpiryCleared() bool { + _, ok := m.clearedFields[user.FieldExpiry] + return ok +} + +// ResetExpiry resets all changes to the "expiry" field. +func (m *UserMutation) ResetExpiry() { + m.expiry = nil + delete(m.clearedFields, user.FieldExpiry) +} + +// SetOpenid sets the "openid" field. +func (m *UserMutation) SetOpenid(b bool) { + m.openid = &b +} + +// Openid returns the value of the "openid" field in the mutation. +func (m *UserMutation) Openid() (r bool, exists bool) { + v := m.openid + if v == nil { + return + } + return *v, true +} + +// OldOpenid returns the old "openid" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldOpenid(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOpenid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOpenid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOpenid: %w", err) + } + return oldValue.Openid, nil } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *UpdateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case update.FieldTitle: - return m.OldTitle(ctx) - case update.FieldDate: - return m.OldDate(ctx) - case update.FieldSupportURL: - return m.OldSupportURL(ctx) - } - return nil, fmt.Errorf("unknown Update field %s", name) +// ClearOpenid clears the value of the "openid" field. +func (m *UserMutation) ClearOpenid() { + m.openid = nil + m.clearedFields[user.FieldOpenid] = struct{}{} } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UpdateMutation) SetField(name string, value ent.Value) error { - switch name { - case update.FieldTitle: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTitle(v) - return nil - case update.FieldDate: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDate(v) - return nil - case update.FieldSupportURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSupportURL(v) - return nil - } - return fmt.Errorf("unknown Update field %s", name) +// OpenidCleared returns if the "openid" field was cleared in this mutation. +func (m *UserMutation) OpenidCleared() bool { + _, ok := m.clearedFields[user.FieldOpenid] + return ok } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *UpdateMutation) AddedFields() []string { - return nil +// ResetOpenid resets all changes to the "openid" field. +func (m *UserMutation) ResetOpenid() { + m.openid = nil + delete(m.clearedFields, user.FieldOpenid) } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *UpdateMutation) AddedField(name string) (ent.Value, bool) { - return nil, false +// SetPasswd sets the "passwd" field. +func (m *UserMutation) SetPasswd(b bool) { + m.passwd = &b } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UpdateMutation) AddField(name string, value ent.Value) error { - switch name { +// Passwd returns the value of the "passwd" field in the mutation. +func (m *UserMutation) Passwd() (r bool, exists bool) { + v := m.passwd + if v == nil { + return } - return fmt.Errorf("unknown Update numeric field %s", name) + return *v, true } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *UpdateMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(update.FieldSupportURL) { - fields = append(fields, update.FieldSupportURL) +// OldPasswd returns the old "passwd" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldPasswd(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPasswd is only allowed on UpdateOne operations") } - return fields + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPasswd requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPasswd: %w", err) + } + return oldValue.Passwd, nil } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *UpdateMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// ClearPasswd clears the value of the "passwd" field. +func (m *UserMutation) ClearPasswd() { + m.passwd = nil + m.clearedFields[user.FieldPasswd] = struct{}{} +} + +// PasswdCleared returns if the "passwd" field was cleared in this mutation. +func (m *UserMutation) PasswdCleared() bool { + _, ok := m.clearedFields[user.FieldPasswd] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *UpdateMutation) ClearField(name string) error { - switch name { - case update.FieldSupportURL: - m.ClearSupportURL() - return nil - } - return fmt.Errorf("unknown Update nullable field %s", name) +// ResetPasswd resets all changes to the "passwd" field. +func (m *UserMutation) ResetPasswd() { + m.passwd = nil + delete(m.clearedFields, user.FieldPasswd) } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *UpdateMutation) ResetField(name string) error { - switch name { - case update.FieldTitle: - m.ResetTitle() - return nil - case update.FieldDate: - m.ResetDate() - return nil - case update.FieldSupportURL: - m.ResetSupportURL() - return nil - } - return fmt.Errorf("unknown Update field %s", name) +// SetUse2fa sets the "use2fa" field. +func (m *UserMutation) SetUse2fa(b bool) { + m.use2fa = &b } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *UpdateMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.owner != nil { - edges = append(edges, update.EdgeOwner) +// Use2fa returns the value of the "use2fa" field in the mutation. +func (m *UserMutation) Use2fa() (r bool, exists bool) { + v := m.use2fa + if v == nil { + return } - return edges + return *v, true } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *UpdateMutation) AddedIDs(name string) []ent.Value { - switch name { - case update.EdgeOwner: - if id := m.owner; id != nil { - return []ent.Value{*id} - } +// OldUse2fa returns the old "use2fa" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUse2fa(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUse2fa is only allowed on UpdateOne operations") } - return nil + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUse2fa requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUse2fa: %w", err) + } + return oldValue.Use2fa, nil } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *UpdateMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges +// ClearUse2fa clears the value of the "use2fa" field. +func (m *UserMutation) ClearUse2fa() { + m.use2fa = nil + m.clearedFields[user.FieldUse2fa] = struct{}{} } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *UpdateMutation) RemovedIDs(name string) []ent.Value { - return nil +// Use2faCleared returns if the "use2fa" field was cleared in this mutation. +func (m *UserMutation) Use2faCleared() bool { + _, ok := m.clearedFields[user.FieldUse2fa] + return ok } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UpdateMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedowner { - edges = append(edges, update.EdgeOwner) - } - return edges +// ResetUse2fa resets all changes to the "use2fa" field. +func (m *UserMutation) ResetUse2fa() { + m.use2fa = nil + delete(m.clearedFields, user.FieldUse2fa) } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *UpdateMutation) EdgeCleared(name string) bool { - switch name { - case update.EdgeOwner: - return m.clearedowner - } - return false +// SetCreated sets the "created" field. +func (m *UserMutation) SetCreated(t time.Time) { + m.created = &t } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *UpdateMutation) ClearEdge(name string) error { - switch name { - case update.EdgeOwner: - m.ClearOwner() - return nil +// Created returns the value of the "created" field in the mutation. +func (m *UserMutation) Created() (r time.Time, exists bool) { + v := m.created + if v == nil { + return } - return fmt.Errorf("unknown Update unique edge %s", name) + return *v, true } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *UpdateMutation) ResetEdge(name string) error { - switch name { - case update.EdgeOwner: - m.ResetOwner() - return nil +// OldCreated returns the old "created" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCreated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreated is only allowed on UpdateOne operations") } - return fmt.Errorf("unknown Update edge %s", name) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreated requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreated: %w", err) + } + return oldValue.Created, nil } -// UserMutation represents an operation that mutates the User nodes in the graph. -type UserMutation struct { - config - op Op - typ string - id *string - name *string - email *string - phone *string - country *string - email_verified *bool - register *string - cert_clear_password *string - expiry *time.Time - openid *bool - passwd *bool - use2fa *bool - created *time.Time - modified *time.Time - access_token *string - refresh_token *string - id_token *string - token_type *string - token_expiry *int - addtoken_expiry *int - hash *string - totp_secret *string - totp_secret_confirmed *bool - forgot_password_code *string - forgot_password_code_expires_at *time.Time - new_user_token *string - clearedFields map[string]struct{} - sessions map[string]struct{} - removedsessions map[string]struct{} - clearedsessions bool - recoverycodes map[int]struct{} - removedrecoverycodes map[int]struct{} - clearedrecoverycodes bool - done bool - oldValue func(context.Context) (*User, error) - predicates []predicate.User +// ClearCreated clears the value of the "created" field. +func (m *UserMutation) ClearCreated() { + m.created = nil + m.clearedFields[user.FieldCreated] = struct{}{} } -var _ ent.Mutation = (*UserMutation)(nil) +// CreatedCleared returns if the "created" field was cleared in this mutation. +func (m *UserMutation) CreatedCleared() bool { + _, ok := m.clearedFields[user.FieldCreated] + return ok +} -// userOption allows management of the mutation configuration using functional options. -type userOption func(*UserMutation) +// ResetCreated resets all changes to the "created" field. +func (m *UserMutation) ResetCreated() { + m.created = nil + delete(m.clearedFields, user.FieldCreated) +} -// newUserMutation creates new mutation for the User entity. -func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { - m := &UserMutation{ - config: c, - op: op, - typ: TypeUser, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m +// SetModified sets the "modified" field. +func (m *UserMutation) SetModified(t time.Time) { + m.modified = &t } -// withUserID sets the ID field of the mutation. -func withUserID(id string) userOption { - return func(m *UserMutation) { - var ( - err error - once sync.Once - value *User - ) - m.oldValue = func(ctx context.Context) (*User, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().User.Get(ctx, id) - } - }) - return value, err - } - m.id = &id +// Modified returns the value of the "modified" field in the mutation. +func (m *UserMutation) Modified() (r time.Time, exists bool) { + v := m.modified + if v == nil { + return } + return *v, true } -// withUser sets the old User of the mutation. -func withUser(node *User) userOption { - return func(m *UserMutation) { - m.oldValue = func(context.Context) (*User, error) { - return node, nil - } - m.id = &node.ID +// OldModified returns the old "modified" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldModified(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModified is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModified requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModified: %w", err) } + return oldValue.Modified, nil } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client +// ClearModified clears the value of the "modified" field. +func (m *UserMutation) ClearModified() { + m.modified = nil + m.clearedFields[user.FieldModified] = struct{}{} } -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m UserMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil +// ModifiedCleared returns if the "modified" field was cleared in this mutation. +func (m *UserMutation) ModifiedCleared() bool { + _, ok := m.clearedFields[user.FieldModified] + return ok } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of User entities. -func (m *UserMutation) SetID(id string) { - m.id = &id +// ResetModified resets all changes to the "modified" field. +func (m *UserMutation) ResetModified() { + m.modified = nil + delete(m.clearedFields, user.FieldModified) } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserMutation) ID() (id string, exists bool) { - if m.id == nil { +// SetAccessToken sets the "access_token" field. +func (m *UserMutation) SetAccessToken(s string) { + m.access_token = &s +} + +// AccessToken returns the value of the "access_token" field in the mutation. +func (m *UserMutation) AccessToken() (r string, exists bool) { + v := m.access_token + if v == nil { return } - return *m.id, true + return *v, true } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().User.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// OldAccessToken returns the old "access_token" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldAccessToken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAccessToken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) } + return oldValue.AccessToken, nil } -// SetName sets the "name" field. -func (m *UserMutation) SetName(s string) { - m.name = &s +// ClearAccessToken clears the value of the "access_token" field. +func (m *UserMutation) ClearAccessToken() { + m.access_token = nil + m.clearedFields[user.FieldAccessToken] = struct{}{} } -// Name returns the value of the "name" field in the mutation. -func (m *UserMutation) Name() (r string, exists bool) { - v := m.name +// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. +func (m *UserMutation) AccessTokenCleared() bool { + _, ok := m.clearedFields[user.FieldAccessToken] + return ok +} + +// ResetAccessToken resets all changes to the "access_token" field. +func (m *UserMutation) ResetAccessToken() { + m.access_token = nil + delete(m.clearedFields, user.FieldAccessToken) +} + +// SetRefreshToken sets the "refresh_token" field. +func (m *UserMutation) SetRefreshToken(s string) { + m.refresh_token = &s +} + +// RefreshToken returns the value of the "refresh_token" field in the mutation. +func (m *UserMutation) RefreshToken() (r string, exists bool) { + v := m.refresh_token if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the User entity. +// OldRefreshToken returns the old "refresh_token" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldRefreshToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldRefreshToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldRefreshToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldRefreshToken: %w", err) } - return oldValue.Name, nil + return oldValue.RefreshToken, nil } -// ResetName resets all changes to the "name" field. -func (m *UserMutation) ResetName() { - m.name = nil +// ClearRefreshToken clears the value of the "refresh_token" field. +func (m *UserMutation) ClearRefreshToken() { + m.refresh_token = nil + m.clearedFields[user.FieldRefreshToken] = struct{}{} } -// SetEmail sets the "email" field. -func (m *UserMutation) SetEmail(s string) { - m.email = &s +// RefreshTokenCleared returns if the "refresh_token" field was cleared in this mutation. +func (m *UserMutation) RefreshTokenCleared() bool { + _, ok := m.clearedFields[user.FieldRefreshToken] + return ok +} + +// ResetRefreshToken resets all changes to the "refresh_token" field. +func (m *UserMutation) ResetRefreshToken() { + m.refresh_token = nil + delete(m.clearedFields, user.FieldRefreshToken) +} + +// SetIDToken sets the "id_token" field. +func (m *UserMutation) SetIDToken(s string) { + m.id_token = &s } -// Email returns the value of the "email" field in the mutation. -func (m *UserMutation) Email() (r string, exists bool) { - v := m.email +// IDToken returns the value of the "id_token" field in the mutation. +func (m *UserMutation) IDToken() (r string, exists bool) { + v := m.id_token if v == nil { return } return *v, true } -// OldEmail returns the old "email" field's value of the User entity. +// OldIDToken returns the old "id_token" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldIDToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEmail is only allowed on UpdateOne operations") + return v, errors.New("OldIDToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEmail requires an ID field in the mutation") + return v, errors.New("OldIDToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEmail: %w", err) + return v, fmt.Errorf("querying old value for OldIDToken: %w", err) } - return oldValue.Email, nil + return oldValue.IDToken, nil } -// ClearEmail clears the value of the "email" field. -func (m *UserMutation) ClearEmail() { - m.email = nil - m.clearedFields[user.FieldEmail] = struct{}{} +// ClearIDToken clears the value of the "id_token" field. +func (m *UserMutation) ClearIDToken() { + m.id_token = nil + m.clearedFields[user.FieldIDToken] = struct{}{} } -// EmailCleared returns if the "email" field was cleared in this mutation. -func (m *UserMutation) EmailCleared() bool { - _, ok := m.clearedFields[user.FieldEmail] +// IDTokenCleared returns if the "id_token" field was cleared in this mutation. +func (m *UserMutation) IDTokenCleared() bool { + _, ok := m.clearedFields[user.FieldIDToken] return ok } -// ResetEmail resets all changes to the "email" field. -func (m *UserMutation) ResetEmail() { - m.email = nil - delete(m.clearedFields, user.FieldEmail) +// ResetIDToken resets all changes to the "id_token" field. +func (m *UserMutation) ResetIDToken() { + m.id_token = nil + delete(m.clearedFields, user.FieldIDToken) } -// SetPhone sets the "phone" field. -func (m *UserMutation) SetPhone(s string) { - m.phone = &s +// SetTokenType sets the "token_type" field. +func (m *UserMutation) SetTokenType(s string) { + m.token_type = &s } -// Phone returns the value of the "phone" field in the mutation. -func (m *UserMutation) Phone() (r string, exists bool) { - v := m.phone +// TokenType returns the value of the "token_type" field in the mutation. +func (m *UserMutation) TokenType() (r string, exists bool) { + v := m.token_type if v == nil { return } return *v, true } -// OldPhone returns the old "phone" field's value of the User entity. +// OldTokenType returns the old "token_type" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldTokenType(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPhone is only allowed on UpdateOne operations") + return v, errors.New("OldTokenType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPhone requires an ID field in the mutation") + return v, errors.New("OldTokenType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPhone: %w", err) + return v, fmt.Errorf("querying old value for OldTokenType: %w", err) } - return oldValue.Phone, nil + return oldValue.TokenType, nil } -// ClearPhone clears the value of the "phone" field. -func (m *UserMutation) ClearPhone() { - m.phone = nil - m.clearedFields[user.FieldPhone] = struct{}{} +// ClearTokenType clears the value of the "token_type" field. +func (m *UserMutation) ClearTokenType() { + m.token_type = nil + m.clearedFields[user.FieldTokenType] = struct{}{} } -// PhoneCleared returns if the "phone" field was cleared in this mutation. -func (m *UserMutation) PhoneCleared() bool { - _, ok := m.clearedFields[user.FieldPhone] +// TokenTypeCleared returns if the "token_type" field was cleared in this mutation. +func (m *UserMutation) TokenTypeCleared() bool { + _, ok := m.clearedFields[user.FieldTokenType] return ok } -// ResetPhone resets all changes to the "phone" field. -func (m *UserMutation) ResetPhone() { - m.phone = nil - delete(m.clearedFields, user.FieldPhone) +// ResetTokenType resets all changes to the "token_type" field. +func (m *UserMutation) ResetTokenType() { + m.token_type = nil + delete(m.clearedFields, user.FieldTokenType) } -// SetCountry sets the "country" field. -func (m *UserMutation) SetCountry(s string) { - m.country = &s +// SetTokenExpiry sets the "token_expiry" field. +func (m *UserMutation) SetTokenExpiry(i int) { + m.token_expiry = &i + m.addtoken_expiry = nil } -// Country returns the value of the "country" field in the mutation. -func (m *UserMutation) Country() (r string, exists bool) { - v := m.country +// TokenExpiry returns the value of the "token_expiry" field in the mutation. +func (m *UserMutation) TokenExpiry() (r int, exists bool) { + v := m.token_expiry if v == nil { return } return *v, true } -// OldCountry returns the old "country" field's value of the User entity. +// OldTokenExpiry returns the old "token_expiry" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCountry(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldTokenExpiry(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCountry is only allowed on UpdateOne operations") + return v, errors.New("OldTokenExpiry is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCountry requires an ID field in the mutation") + return v, errors.New("OldTokenExpiry requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCountry: %w", err) + return v, fmt.Errorf("querying old value for OldTokenExpiry: %w", err) } - return oldValue.Country, nil + return oldValue.TokenExpiry, nil } -// ClearCountry clears the value of the "country" field. -func (m *UserMutation) ClearCountry() { - m.country = nil - m.clearedFields[user.FieldCountry] = struct{}{} +// AddTokenExpiry adds i to the "token_expiry" field. +func (m *UserMutation) AddTokenExpiry(i int) { + if m.addtoken_expiry != nil { + *m.addtoken_expiry += i + } else { + m.addtoken_expiry = &i + } } -// CountryCleared returns if the "country" field was cleared in this mutation. -func (m *UserMutation) CountryCleared() bool { - _, ok := m.clearedFields[user.FieldCountry] +// AddedTokenExpiry returns the value that was added to the "token_expiry" field in this mutation. +func (m *UserMutation) AddedTokenExpiry() (r int, exists bool) { + v := m.addtoken_expiry + if v == nil { + return + } + return *v, true +} + +// ClearTokenExpiry clears the value of the "token_expiry" field. +func (m *UserMutation) ClearTokenExpiry() { + m.token_expiry = nil + m.addtoken_expiry = nil + m.clearedFields[user.FieldTokenExpiry] = struct{}{} +} + +// TokenExpiryCleared returns if the "token_expiry" field was cleared in this mutation. +func (m *UserMutation) TokenExpiryCleared() bool { + _, ok := m.clearedFields[user.FieldTokenExpiry] return ok } -// ResetCountry resets all changes to the "country" field. -func (m *UserMutation) ResetCountry() { - m.country = nil - delete(m.clearedFields, user.FieldCountry) +// ResetTokenExpiry resets all changes to the "token_expiry" field. +func (m *UserMutation) ResetTokenExpiry() { + m.token_expiry = nil + m.addtoken_expiry = nil + delete(m.clearedFields, user.FieldTokenExpiry) } -// SetEmailVerified sets the "email_verified" field. -func (m *UserMutation) SetEmailVerified(b bool) { - m.email_verified = &b +// SetHash sets the "hash" field. +func (m *UserMutation) SetHash(s string) { + m.hash = &s } -// EmailVerified returns the value of the "email_verified" field in the mutation. -func (m *UserMutation) EmailVerified() (r bool, exists bool) { - v := m.email_verified +// Hash returns the value of the "hash" field in the mutation. +func (m *UserMutation) Hash() (r string, exists bool) { + v := m.hash if v == nil { return } return *v, true } -// OldEmailVerified returns the old "email_verified" field's value of the User entity. +// OldHash returns the old "hash" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldEmailVerified(ctx context.Context) (v bool, err error) { +func (m *UserMutation) OldHash(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEmailVerified is only allowed on UpdateOne operations") + return v, errors.New("OldHash is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEmailVerified requires an ID field in the mutation") + return v, errors.New("OldHash requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEmailVerified: %w", err) + return v, fmt.Errorf("querying old value for OldHash: %w", err) } - return oldValue.EmailVerified, nil + return oldValue.Hash, nil } -// ResetEmailVerified resets all changes to the "email_verified" field. -func (m *UserMutation) ResetEmailVerified() { - m.email_verified = nil +// ClearHash clears the value of the "hash" field. +func (m *UserMutation) ClearHash() { + m.hash = nil + m.clearedFields[user.FieldHash] = struct{}{} } -// SetRegister sets the "register" field. -func (m *UserMutation) SetRegister(s string) { - m.register = &s +// HashCleared returns if the "hash" field was cleared in this mutation. +func (m *UserMutation) HashCleared() bool { + _, ok := m.clearedFields[user.FieldHash] + return ok } -// Register returns the value of the "register" field in the mutation. -func (m *UserMutation) Register() (r string, exists bool) { - v := m.register +// ResetHash resets all changes to the "hash" field. +func (m *UserMutation) ResetHash() { + m.hash = nil + delete(m.clearedFields, user.FieldHash) +} + +// SetTotpSecret sets the "totp_secret" field. +func (m *UserMutation) SetTotpSecret(s string) { + m.totp_secret = &s +} + +// TotpSecret returns the value of the "totp_secret" field in the mutation. +func (m *UserMutation) TotpSecret() (r string, exists bool) { + v := m.totp_secret if v == nil { return } return *v, true } -// OldRegister returns the old "register" field's value of the User entity. +// OldTotpSecret returns the old "totp_secret" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldRegister(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldTotpSecret(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegister is only allowed on UpdateOne operations") + return v, errors.New("OldTotpSecret is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegister requires an ID field in the mutation") + return v, errors.New("OldTotpSecret requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRegister: %w", err) + return v, fmt.Errorf("querying old value for OldTotpSecret: %w", err) } - return oldValue.Register, nil + return oldValue.TotpSecret, nil } -// ResetRegister resets all changes to the "register" field. -func (m *UserMutation) ResetRegister() { - m.register = nil +// ClearTotpSecret clears the value of the "totp_secret" field. +func (m *UserMutation) ClearTotpSecret() { + m.totp_secret = nil + m.clearedFields[user.FieldTotpSecret] = struct{}{} } -// SetCertClearPassword sets the "cert_clear_password" field. -func (m *UserMutation) SetCertClearPassword(s string) { - m.cert_clear_password = &s +// TotpSecretCleared returns if the "totp_secret" field was cleared in this mutation. +func (m *UserMutation) TotpSecretCleared() bool { + _, ok := m.clearedFields[user.FieldTotpSecret] + return ok } -// CertClearPassword returns the value of the "cert_clear_password" field in the mutation. -func (m *UserMutation) CertClearPassword() (r string, exists bool) { - v := m.cert_clear_password +// ResetTotpSecret resets all changes to the "totp_secret" field. +func (m *UserMutation) ResetTotpSecret() { + m.totp_secret = nil + delete(m.clearedFields, user.FieldTotpSecret) +} + +// SetTotpSecretConfirmed sets the "totp_secret_confirmed" field. +func (m *UserMutation) SetTotpSecretConfirmed(b bool) { + m.totp_secret_confirmed = &b +} + +// TotpSecretConfirmed returns the value of the "totp_secret_confirmed" field in the mutation. +func (m *UserMutation) TotpSecretConfirmed() (r bool, exists bool) { + v := m.totp_secret_confirmed if v == nil { return } return *v, true } -// OldCertClearPassword returns the old "cert_clear_password" field's value of the User entity. +// OldTotpSecretConfirmed returns the old "totp_secret_confirmed" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCertClearPassword(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldTotpSecretConfirmed(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCertClearPassword is only allowed on UpdateOne operations") + return v, errors.New("OldTotpSecretConfirmed is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCertClearPassword requires an ID field in the mutation") + return v, errors.New("OldTotpSecretConfirmed requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCertClearPassword: %w", err) + return v, fmt.Errorf("querying old value for OldTotpSecretConfirmed: %w", err) } - return oldValue.CertClearPassword, nil + return oldValue.TotpSecretConfirmed, nil } -// ClearCertClearPassword clears the value of the "cert_clear_password" field. -func (m *UserMutation) ClearCertClearPassword() { - m.cert_clear_password = nil - m.clearedFields[user.FieldCertClearPassword] = struct{}{} +// ClearTotpSecretConfirmed clears the value of the "totp_secret_confirmed" field. +func (m *UserMutation) ClearTotpSecretConfirmed() { + m.totp_secret_confirmed = nil + m.clearedFields[user.FieldTotpSecretConfirmed] = struct{}{} } -// CertClearPasswordCleared returns if the "cert_clear_password" field was cleared in this mutation. -func (m *UserMutation) CertClearPasswordCleared() bool { - _, ok := m.clearedFields[user.FieldCertClearPassword] +// TotpSecretConfirmedCleared returns if the "totp_secret_confirmed" field was cleared in this mutation. +func (m *UserMutation) TotpSecretConfirmedCleared() bool { + _, ok := m.clearedFields[user.FieldTotpSecretConfirmed] return ok } -// ResetCertClearPassword resets all changes to the "cert_clear_password" field. -func (m *UserMutation) ResetCertClearPassword() { - m.cert_clear_password = nil - delete(m.clearedFields, user.FieldCertClearPassword) +// ResetTotpSecretConfirmed resets all changes to the "totp_secret_confirmed" field. +func (m *UserMutation) ResetTotpSecretConfirmed() { + m.totp_secret_confirmed = nil + delete(m.clearedFields, user.FieldTotpSecretConfirmed) } -// SetExpiry sets the "expiry" field. -func (m *UserMutation) SetExpiry(t time.Time) { - m.expiry = &t +// SetForgotPasswordCode sets the "forgot_password_code" field. +func (m *UserMutation) SetForgotPasswordCode(s string) { + m.forgot_password_code = &s } -// Expiry returns the value of the "expiry" field in the mutation. -func (m *UserMutation) Expiry() (r time.Time, exists bool) { - v := m.expiry +// ForgotPasswordCode returns the value of the "forgot_password_code" field in the mutation. +func (m *UserMutation) ForgotPasswordCode() (r string, exists bool) { + v := m.forgot_password_code if v == nil { return } return *v, true } -// OldExpiry returns the old "expiry" field's value of the User entity. +// OldForgotPasswordCode returns the old "forgot_password_code" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { +func (m *UserMutation) OldForgotPasswordCode(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExpiry is only allowed on UpdateOne operations") + return v, errors.New("OldForgotPasswordCode is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExpiry requires an ID field in the mutation") + return v, errors.New("OldForgotPasswordCode requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExpiry: %w", err) + return v, fmt.Errorf("querying old value for OldForgotPasswordCode: %w", err) } - return oldValue.Expiry, nil + return oldValue.ForgotPasswordCode, nil } -// ClearExpiry clears the value of the "expiry" field. -func (m *UserMutation) ClearExpiry() { - m.expiry = nil - m.clearedFields[user.FieldExpiry] = struct{}{} +// ClearForgotPasswordCode clears the value of the "forgot_password_code" field. +func (m *UserMutation) ClearForgotPasswordCode() { + m.forgot_password_code = nil + m.clearedFields[user.FieldForgotPasswordCode] = struct{}{} } -// ExpiryCleared returns if the "expiry" field was cleared in this mutation. -func (m *UserMutation) ExpiryCleared() bool { - _, ok := m.clearedFields[user.FieldExpiry] +// ForgotPasswordCodeCleared returns if the "forgot_password_code" field was cleared in this mutation. +func (m *UserMutation) ForgotPasswordCodeCleared() bool { + _, ok := m.clearedFields[user.FieldForgotPasswordCode] return ok } -// ResetExpiry resets all changes to the "expiry" field. -func (m *UserMutation) ResetExpiry() { - m.expiry = nil - delete(m.clearedFields, user.FieldExpiry) +// ResetForgotPasswordCode resets all changes to the "forgot_password_code" field. +func (m *UserMutation) ResetForgotPasswordCode() { + m.forgot_password_code = nil + delete(m.clearedFields, user.FieldForgotPasswordCode) } -// SetOpenid sets the "openid" field. -func (m *UserMutation) SetOpenid(b bool) { - m.openid = &b +// SetForgotPasswordCodeExpiresAt sets the "forgot_password_code_expires_at" field. +func (m *UserMutation) SetForgotPasswordCodeExpiresAt(t time.Time) { + m.forgot_password_code_expires_at = &t } -// Openid returns the value of the "openid" field in the mutation. -func (m *UserMutation) Openid() (r bool, exists bool) { - v := m.openid +// ForgotPasswordCodeExpiresAt returns the value of the "forgot_password_code_expires_at" field in the mutation. +func (m *UserMutation) ForgotPasswordCodeExpiresAt() (r time.Time, exists bool) { + v := m.forgot_password_code_expires_at if v == nil { return } return *v, true } -// OldOpenid returns the old "openid" field's value of the User entity. +// OldForgotPasswordCodeExpiresAt returns the old "forgot_password_code_expires_at" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldOpenid(ctx context.Context) (v bool, err error) { +func (m *UserMutation) OldForgotPasswordCodeExpiresAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOpenid is only allowed on UpdateOne operations") + return v, errors.New("OldForgotPasswordCodeExpiresAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOpenid requires an ID field in the mutation") + return v, errors.New("OldForgotPasswordCodeExpiresAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOpenid: %w", err) + return v, fmt.Errorf("querying old value for OldForgotPasswordCodeExpiresAt: %w", err) } - return oldValue.Openid, nil + return oldValue.ForgotPasswordCodeExpiresAt, nil } -// ClearOpenid clears the value of the "openid" field. -func (m *UserMutation) ClearOpenid() { - m.openid = nil - m.clearedFields[user.FieldOpenid] = struct{}{} +// ClearForgotPasswordCodeExpiresAt clears the value of the "forgot_password_code_expires_at" field. +func (m *UserMutation) ClearForgotPasswordCodeExpiresAt() { + m.forgot_password_code_expires_at = nil + m.clearedFields[user.FieldForgotPasswordCodeExpiresAt] = struct{}{} } -// OpenidCleared returns if the "openid" field was cleared in this mutation. -func (m *UserMutation) OpenidCleared() bool { - _, ok := m.clearedFields[user.FieldOpenid] +// ForgotPasswordCodeExpiresAtCleared returns if the "forgot_password_code_expires_at" field was cleared in this mutation. +func (m *UserMutation) ForgotPasswordCodeExpiresAtCleared() bool { + _, ok := m.clearedFields[user.FieldForgotPasswordCodeExpiresAt] return ok } -// ResetOpenid resets all changes to the "openid" field. -func (m *UserMutation) ResetOpenid() { - m.openid = nil - delete(m.clearedFields, user.FieldOpenid) +// ResetForgotPasswordCodeExpiresAt resets all changes to the "forgot_password_code_expires_at" field. +func (m *UserMutation) ResetForgotPasswordCodeExpiresAt() { + m.forgot_password_code_expires_at = nil + delete(m.clearedFields, user.FieldForgotPasswordCodeExpiresAt) } -// SetPasswd sets the "passwd" field. -func (m *UserMutation) SetPasswd(b bool) { - m.passwd = &b +// SetNewUserToken sets the "new_user_token" field. +func (m *UserMutation) SetNewUserToken(s string) { + m.new_user_token = &s } -// Passwd returns the value of the "passwd" field in the mutation. -func (m *UserMutation) Passwd() (r bool, exists bool) { - v := m.passwd +// NewUserToken returns the value of the "new_user_token" field in the mutation. +func (m *UserMutation) NewUserToken() (r string, exists bool) { + v := m.new_user_token if v == nil { return } return *v, true } -// OldPasswd returns the old "passwd" field's value of the User entity. +// OldNewUserToken returns the old "new_user_token" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPasswd(ctx context.Context) (v bool, err error) { +func (m *UserMutation) OldNewUserToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPasswd is only allowed on UpdateOne operations") + return v, errors.New("OldNewUserToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPasswd requires an ID field in the mutation") + return v, errors.New("OldNewUserToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPasswd: %w", err) + return v, fmt.Errorf("querying old value for OldNewUserToken: %w", err) } - return oldValue.Passwd, nil + return oldValue.NewUserToken, nil } -// ClearPasswd clears the value of the "passwd" field. -func (m *UserMutation) ClearPasswd() { - m.passwd = nil - m.clearedFields[user.FieldPasswd] = struct{}{} +// ClearNewUserToken clears the value of the "new_user_token" field. +func (m *UserMutation) ClearNewUserToken() { + m.new_user_token = nil + m.clearedFields[user.FieldNewUserToken] = struct{}{} } -// PasswdCleared returns if the "passwd" field was cleared in this mutation. -func (m *UserMutation) PasswdCleared() bool { - _, ok := m.clearedFields[user.FieldPasswd] +// NewUserTokenCleared returns if the "new_user_token" field was cleared in this mutation. +func (m *UserMutation) NewUserTokenCleared() bool { + _, ok := m.clearedFields[user.FieldNewUserToken] return ok } -// ResetPasswd resets all changes to the "passwd" field. -func (m *UserMutation) ResetPasswd() { - m.passwd = nil - delete(m.clearedFields, user.FieldPasswd) +// ResetNewUserToken resets all changes to the "new_user_token" field. +func (m *UserMutation) ResetNewUserToken() { + m.new_user_token = nil + delete(m.clearedFields, user.FieldNewUserToken) } -// SetUse2fa sets the "use2fa" field. -func (m *UserMutation) SetUse2fa(b bool) { - m.use2fa = &b +// AddSessionIDs adds the "sessions" edge to the Sessions entity by ids. +func (m *UserMutation) AddSessionIDs(ids ...string) { + if m.sessions == nil { + m.sessions = make(map[string]struct{}) + } + for i := range ids { + m.sessions[ids[i]] = struct{}{} + } } -// Use2fa returns the value of the "use2fa" field in the mutation. -func (m *UserMutation) Use2fa() (r bool, exists bool) { - v := m.use2fa - if v == nil { - return +// ClearSessions clears the "sessions" edge to the Sessions entity. +func (m *UserMutation) ClearSessions() { + m.clearedsessions = true +} + +// SessionsCleared reports if the "sessions" edge to the Sessions entity was cleared. +func (m *UserMutation) SessionsCleared() bool { + return m.clearedsessions +} + +// RemoveSessionIDs removes the "sessions" edge to the Sessions entity by IDs. +func (m *UserMutation) RemoveSessionIDs(ids ...string) { + if m.removedsessions == nil { + m.removedsessions = make(map[string]struct{}) + } + for i := range ids { + delete(m.sessions, ids[i]) + m.removedsessions[ids[i]] = struct{}{} } - return *v, true } -// OldUse2fa returns the old "use2fa" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUse2fa(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUse2fa is only allowed on UpdateOne operations") +// RemovedSessions returns the removed IDs of the "sessions" edge to the Sessions entity. +func (m *UserMutation) RemovedSessionsIDs() (ids []string) { + for id := range m.removedsessions { + ids = append(ids, id) + } + return +} + +// SessionsIDs returns the "sessions" edge IDs in the mutation. +func (m *UserMutation) SessionsIDs() (ids []string) { + for id := range m.sessions { + ids = append(ids, id) + } + return +} + +// ResetSessions resets all changes to the "sessions" edge. +func (m *UserMutation) ResetSessions() { + m.sessions = nil + m.clearedsessions = false + m.removedsessions = nil +} + +// AddRecoverycodeIDs adds the "recoverycodes" edge to the RecoveryCode entity by ids. +func (m *UserMutation) AddRecoverycodeIDs(ids ...int) { + if m.recoverycodes == nil { + m.recoverycodes = make(map[int]struct{}) + } + for i := range ids { + m.recoverycodes[ids[i]] = struct{}{} + } +} + +// ClearRecoverycodes clears the "recoverycodes" edge to the RecoveryCode entity. +func (m *UserMutation) ClearRecoverycodes() { + m.clearedrecoverycodes = true +} + +// RecoverycodesCleared reports if the "recoverycodes" edge to the RecoveryCode entity was cleared. +func (m *UserMutation) RecoverycodesCleared() bool { + return m.clearedrecoverycodes +} + +// RemoveRecoverycodeIDs removes the "recoverycodes" edge to the RecoveryCode entity by IDs. +func (m *UserMutation) RemoveRecoverycodeIDs(ids ...int) { + if m.removedrecoverycodes == nil { + m.removedrecoverycodes = make(map[int]struct{}) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUse2fa requires an ID field in the mutation") + for i := range ids { + delete(m.recoverycodes, ids[i]) + m.removedrecoverycodes[ids[i]] = struct{}{} } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUse2fa: %w", err) +} + +// RemovedRecoverycodes returns the removed IDs of the "recoverycodes" edge to the RecoveryCode entity. +func (m *UserMutation) RemovedRecoverycodesIDs() (ids []int) { + for id := range m.removedrecoverycodes { + ids = append(ids, id) } - return oldValue.Use2fa, nil + return } -// ClearUse2fa clears the value of the "use2fa" field. -func (m *UserMutation) ClearUse2fa() { - m.use2fa = nil - m.clearedFields[user.FieldUse2fa] = struct{}{} +// RecoverycodesIDs returns the "recoverycodes" edge IDs in the mutation. +func (m *UserMutation) RecoverycodesIDs() (ids []int) { + for id := range m.recoverycodes { + ids = append(ids, id) + } + return } -// Use2faCleared returns if the "use2fa" field was cleared in this mutation. -func (m *UserMutation) Use2faCleared() bool { - _, ok := m.clearedFields[user.FieldUse2fa] - return ok +// ResetRecoverycodes resets all changes to the "recoverycodes" edge. +func (m *UserMutation) ResetRecoverycodes() { + m.recoverycodes = nil + m.clearedrecoverycodes = false + m.removedrecoverycodes = nil } -// ResetUse2fa resets all changes to the "use2fa" field. -func (m *UserMutation) ResetUse2fa() { - m.use2fa = nil - delete(m.clearedFields, user.FieldUse2fa) +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by ids. +func (m *UserMutation) AddUserTenantIDs(ids ...int) { + if m.user_tenants == nil { + m.user_tenants = make(map[int]struct{}) + } + for i := range ids { + m.user_tenants[ids[i]] = struct{}{} + } } -// SetCreated sets the "created" field. -func (m *UserMutation) SetCreated(t time.Time) { - m.created = &t +// ClearUserTenants clears the "user_tenants" edge to the UserTenant entity. +func (m *UserMutation) ClearUserTenants() { + m.cleareduser_tenants = true } -// Created returns the value of the "created" field in the mutation. -func (m *UserMutation) Created() (r time.Time, exists bool) { - v := m.created - if v == nil { - return - } - return *v, true +// UserTenantsCleared reports if the "user_tenants" edge to the UserTenant entity was cleared. +func (m *UserMutation) UserTenantsCleared() bool { + return m.cleareduser_tenants } -// OldCreated returns the old "created" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCreated(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreated is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreated requires an ID field in the mutation") +// RemoveUserTenantIDs removes the "user_tenants" edge to the UserTenant entity by IDs. +func (m *UserMutation) RemoveUserTenantIDs(ids ...int) { + if m.removeduser_tenants == nil { + m.removeduser_tenants = make(map[int]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreated: %w", err) + for i := range ids { + delete(m.user_tenants, ids[i]) + m.removeduser_tenants[ids[i]] = struct{}{} } - return oldValue.Created, nil } -// ClearCreated clears the value of the "created" field. -func (m *UserMutation) ClearCreated() { - m.created = nil - m.clearedFields[user.FieldCreated] = struct{}{} +// RemovedUserTenants returns the removed IDs of the "user_tenants" edge to the UserTenant entity. +func (m *UserMutation) RemovedUserTenantsIDs() (ids []int) { + for id := range m.removeduser_tenants { + ids = append(ids, id) + } + return } -// CreatedCleared returns if the "created" field was cleared in this mutation. -func (m *UserMutation) CreatedCleared() bool { - _, ok := m.clearedFields[user.FieldCreated] - return ok +// UserTenantsIDs returns the "user_tenants" edge IDs in the mutation. +func (m *UserMutation) UserTenantsIDs() (ids []int) { + for id := range m.user_tenants { + ids = append(ids, id) + } + return } -// ResetCreated resets all changes to the "created" field. -func (m *UserMutation) ResetCreated() { - m.created = nil - delete(m.clearedFields, user.FieldCreated) +// ResetUserTenants resets all changes to the "user_tenants" edge. +func (m *UserMutation) ResetUserTenants() { + m.user_tenants = nil + m.cleareduser_tenants = false + m.removeduser_tenants = nil } -// SetModified sets the "modified" field. -func (m *UserMutation) SetModified(t time.Time) { - m.modified = &t +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) } -// Modified returns the value of the "modified" field in the mutation. -func (m *UserMutation) Modified() (r time.Time, exists bool) { - v := m.modified - if v == nil { - return +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] } - return *v, true + m.Where(p...) } -// OldModified returns the old "modified" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldModified(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModified is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModified requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModified: %w", err) - } - return oldValue.Modified, nil +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op } -// ClearModified clears the value of the "modified" field. -func (m *UserMutation) ClearModified() { - m.modified = nil - m.clearedFields[user.FieldModified] = struct{}{} +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op } -// ModifiedCleared returns if the "modified" field was cleared in this mutation. -func (m *UserMutation) ModifiedCleared() bool { - _, ok := m.clearedFields[user.FieldModified] - return ok +// Type returns the node type of this mutation (User). +func (m *UserMutation) Type() string { + return m.typ } -// ResetModified resets all changes to the "modified" field. -func (m *UserMutation) ResetModified() { - m.modified = nil - delete(m.clearedFields, user.FieldModified) +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserMutation) Fields() []string { + fields := make([]string, 0, 24) + if m.name != nil { + fields = append(fields, user.FieldName) + } + if m.email != nil { + fields = append(fields, user.FieldEmail) + } + if m.phone != nil { + fields = append(fields, user.FieldPhone) + } + if m.country != nil { + fields = append(fields, user.FieldCountry) + } + if m.email_verified != nil { + fields = append(fields, user.FieldEmailVerified) + } + if m.register != nil { + fields = append(fields, user.FieldRegister) + } + if m.cert_clear_password != nil { + fields = append(fields, user.FieldCertClearPassword) + } + if m.expiry != nil { + fields = append(fields, user.FieldExpiry) + } + if m.openid != nil { + fields = append(fields, user.FieldOpenid) + } + if m.passwd != nil { + fields = append(fields, user.FieldPasswd) + } + if m.use2fa != nil { + fields = append(fields, user.FieldUse2fa) + } + if m.created != nil { + fields = append(fields, user.FieldCreated) + } + if m.modified != nil { + fields = append(fields, user.FieldModified) + } + if m.access_token != nil { + fields = append(fields, user.FieldAccessToken) + } + if m.refresh_token != nil { + fields = append(fields, user.FieldRefreshToken) + } + if m.id_token != nil { + fields = append(fields, user.FieldIDToken) + } + if m.token_type != nil { + fields = append(fields, user.FieldTokenType) + } + if m.token_expiry != nil { + fields = append(fields, user.FieldTokenExpiry) + } + if m.hash != nil { + fields = append(fields, user.FieldHash) + } + if m.totp_secret != nil { + fields = append(fields, user.FieldTotpSecret) + } + if m.totp_secret_confirmed != nil { + fields = append(fields, user.FieldTotpSecretConfirmed) + } + if m.forgot_password_code != nil { + fields = append(fields, user.FieldForgotPasswordCode) + } + if m.forgot_password_code_expires_at != nil { + fields = append(fields, user.FieldForgotPasswordCodeExpiresAt) + } + if m.new_user_token != nil { + fields = append(fields, user.FieldNewUserToken) + } + return fields } -// SetAccessToken sets the "access_token" field. -func (m *UserMutation) SetAccessToken(s string) { - m.access_token = &s +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldName: + return m.Name() + case user.FieldEmail: + return m.Email() + case user.FieldPhone: + return m.Phone() + case user.FieldCountry: + return m.Country() + case user.FieldEmailVerified: + return m.EmailVerified() + case user.FieldRegister: + return m.Register() + case user.FieldCertClearPassword: + return m.CertClearPassword() + case user.FieldExpiry: + return m.Expiry() + case user.FieldOpenid: + return m.Openid() + case user.FieldPasswd: + return m.Passwd() + case user.FieldUse2fa: + return m.Use2fa() + case user.FieldCreated: + return m.Created() + case user.FieldModified: + return m.Modified() + case user.FieldAccessToken: + return m.AccessToken() + case user.FieldRefreshToken: + return m.RefreshToken() + case user.FieldIDToken: + return m.IDToken() + case user.FieldTokenType: + return m.TokenType() + case user.FieldTokenExpiry: + return m.TokenExpiry() + case user.FieldHash: + return m.Hash() + case user.FieldTotpSecret: + return m.TotpSecret() + case user.FieldTotpSecretConfirmed: + return m.TotpSecretConfirmed() + case user.FieldForgotPasswordCode: + return m.ForgotPasswordCode() + case user.FieldForgotPasswordCodeExpiresAt: + return m.ForgotPasswordCodeExpiresAt() + case user.FieldNewUserToken: + return m.NewUserToken() + } + return nil, false } -// AccessToken returns the value of the "access_token" field in the mutation. -func (m *UserMutation) AccessToken() (r string, exists bool) { - v := m.access_token - if v == nil { - return +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldName: + return m.OldName(ctx) + case user.FieldEmail: + return m.OldEmail(ctx) + case user.FieldPhone: + return m.OldPhone(ctx) + case user.FieldCountry: + return m.OldCountry(ctx) + case user.FieldEmailVerified: + return m.OldEmailVerified(ctx) + case user.FieldRegister: + return m.OldRegister(ctx) + case user.FieldCertClearPassword: + return m.OldCertClearPassword(ctx) + case user.FieldExpiry: + return m.OldExpiry(ctx) + case user.FieldOpenid: + return m.OldOpenid(ctx) + case user.FieldPasswd: + return m.OldPasswd(ctx) + case user.FieldUse2fa: + return m.OldUse2fa(ctx) + case user.FieldCreated: + return m.OldCreated(ctx) + case user.FieldModified: + return m.OldModified(ctx) + case user.FieldAccessToken: + return m.OldAccessToken(ctx) + case user.FieldRefreshToken: + return m.OldRefreshToken(ctx) + case user.FieldIDToken: + return m.OldIDToken(ctx) + case user.FieldTokenType: + return m.OldTokenType(ctx) + case user.FieldTokenExpiry: + return m.OldTokenExpiry(ctx) + case user.FieldHash: + return m.OldHash(ctx) + case user.FieldTotpSecret: + return m.OldTotpSecret(ctx) + case user.FieldTotpSecretConfirmed: + return m.OldTotpSecretConfirmed(ctx) + case user.FieldForgotPasswordCode: + return m.OldForgotPasswordCode(ctx) + case user.FieldForgotPasswordCodeExpiresAt: + return m.OldForgotPasswordCodeExpiresAt(ctx) + case user.FieldNewUserToken: + return m.OldNewUserToken(ctx) } - return *v, true + return nil, fmt.Errorf("unknown User field %s", name) } -// OldAccessToken returns the old "access_token" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldAccessToken(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAccessToken requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case user.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case user.FieldPhone: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPhone(v) + return nil + case user.FieldCountry: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCountry(v) + return nil + case user.FieldEmailVerified: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmailVerified(v) + return nil + case user.FieldRegister: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRegister(v) + return nil + case user.FieldCertClearPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCertClearPassword(v) + return nil + case user.FieldExpiry: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExpiry(v) + return nil + case user.FieldOpenid: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOpenid(v) + return nil + case user.FieldPasswd: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPasswd(v) + return nil + case user.FieldUse2fa: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUse2fa(v) + return nil + case user.FieldCreated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreated(v) + return nil + case user.FieldModified: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModified(v) + return nil + case user.FieldAccessToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAccessToken(v) + return nil + case user.FieldRefreshToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefreshToken(v) + return nil + case user.FieldIDToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIDToken(v) + return nil + case user.FieldTokenType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTokenType(v) + return nil + case user.FieldTokenExpiry: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTokenExpiry(v) + return nil + case user.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + case user.FieldTotpSecret: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTotpSecret(v) + return nil + case user.FieldTotpSecretConfirmed: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTotpSecretConfirmed(v) + return nil + case user.FieldForgotPasswordCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetForgotPasswordCode(v) + return nil + case user.FieldForgotPasswordCodeExpiresAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetForgotPasswordCodeExpiresAt(v) + return nil + case user.FieldNewUserToken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNewUserToken(v) + return nil } - return oldValue.AccessToken, nil -} - -// ClearAccessToken clears the value of the "access_token" field. -func (m *UserMutation) ClearAccessToken() { - m.access_token = nil - m.clearedFields[user.FieldAccessToken] = struct{}{} -} - -// AccessTokenCleared returns if the "access_token" field was cleared in this mutation. -func (m *UserMutation) AccessTokenCleared() bool { - _, ok := m.clearedFields[user.FieldAccessToken] - return ok + return fmt.Errorf("unknown User field %s", name) } -// ResetAccessToken resets all changes to the "access_token" field. -func (m *UserMutation) ResetAccessToken() { - m.access_token = nil - delete(m.clearedFields, user.FieldAccessToken) +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + var fields []string + if m.addtoken_expiry != nil { + fields = append(fields, user.FieldTokenExpiry) + } + return fields } -// SetRefreshToken sets the "refresh_token" field. -func (m *UserMutation) SetRefreshToken(s string) { - m.refresh_token = &s +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case user.FieldTokenExpiry: + return m.AddedTokenExpiry() + } + return nil, false } -// RefreshToken returns the value of the "refresh_token" field in the mutation. -func (m *UserMutation) RefreshToken() (r string, exists bool) { - v := m.refresh_token - if v == nil { - return +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) AddField(name string, value ent.Value) error { + switch name { + case user.FieldTokenExpiry: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTokenExpiry(v) + return nil } - return *v, true + return fmt.Errorf("unknown User numeric field %s", name) } -// OldRefreshToken returns the old "refresh_token" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldRefreshToken(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRefreshToken is only allowed on UpdateOne operations") +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(user.FieldEmail) { + fields = append(fields, user.FieldEmail) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRefreshToken requires an ID field in the mutation") + if m.FieldCleared(user.FieldPhone) { + fields = append(fields, user.FieldPhone) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRefreshToken: %w", err) + if m.FieldCleared(user.FieldCountry) { + fields = append(fields, user.FieldCountry) } - return oldValue.RefreshToken, nil -} - -// ClearRefreshToken clears the value of the "refresh_token" field. -func (m *UserMutation) ClearRefreshToken() { - m.refresh_token = nil - m.clearedFields[user.FieldRefreshToken] = struct{}{} + if m.FieldCleared(user.FieldCertClearPassword) { + fields = append(fields, user.FieldCertClearPassword) + } + if m.FieldCleared(user.FieldExpiry) { + fields = append(fields, user.FieldExpiry) + } + if m.FieldCleared(user.FieldOpenid) { + fields = append(fields, user.FieldOpenid) + } + if m.FieldCleared(user.FieldPasswd) { + fields = append(fields, user.FieldPasswd) + } + if m.FieldCleared(user.FieldUse2fa) { + fields = append(fields, user.FieldUse2fa) + } + if m.FieldCleared(user.FieldCreated) { + fields = append(fields, user.FieldCreated) + } + if m.FieldCleared(user.FieldModified) { + fields = append(fields, user.FieldModified) + } + if m.FieldCleared(user.FieldAccessToken) { + fields = append(fields, user.FieldAccessToken) + } + if m.FieldCleared(user.FieldRefreshToken) { + fields = append(fields, user.FieldRefreshToken) + } + if m.FieldCleared(user.FieldIDToken) { + fields = append(fields, user.FieldIDToken) + } + if m.FieldCleared(user.FieldTokenType) { + fields = append(fields, user.FieldTokenType) + } + if m.FieldCleared(user.FieldTokenExpiry) { + fields = append(fields, user.FieldTokenExpiry) + } + if m.FieldCleared(user.FieldHash) { + fields = append(fields, user.FieldHash) + } + if m.FieldCleared(user.FieldTotpSecret) { + fields = append(fields, user.FieldTotpSecret) + } + if m.FieldCleared(user.FieldTotpSecretConfirmed) { + fields = append(fields, user.FieldTotpSecretConfirmed) + } + if m.FieldCleared(user.FieldForgotPasswordCode) { + fields = append(fields, user.FieldForgotPasswordCode) + } + if m.FieldCleared(user.FieldForgotPasswordCodeExpiresAt) { + fields = append(fields, user.FieldForgotPasswordCodeExpiresAt) + } + if m.FieldCleared(user.FieldNewUserToken) { + fields = append(fields, user.FieldNewUserToken) + } + return fields } -// RefreshTokenCleared returns if the "refresh_token" field was cleared in this mutation. -func (m *UserMutation) RefreshTokenCleared() bool { - _, ok := m.clearedFields[user.FieldRefreshToken] +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] return ok } -// ResetRefreshToken resets all changes to the "refresh_token" field. -func (m *UserMutation) ResetRefreshToken() { - m.refresh_token = nil - delete(m.clearedFields, user.FieldRefreshToken) -} - -// SetIDToken sets the "id_token" field. -func (m *UserMutation) SetIDToken(s string) { - m.id_token = &s +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserMutation) ClearField(name string) error { + switch name { + case user.FieldEmail: + m.ClearEmail() + return nil + case user.FieldPhone: + m.ClearPhone() + return nil + case user.FieldCountry: + m.ClearCountry() + return nil + case user.FieldCertClearPassword: + m.ClearCertClearPassword() + return nil + case user.FieldExpiry: + m.ClearExpiry() + return nil + case user.FieldOpenid: + m.ClearOpenid() + return nil + case user.FieldPasswd: + m.ClearPasswd() + return nil + case user.FieldUse2fa: + m.ClearUse2fa() + return nil + case user.FieldCreated: + m.ClearCreated() + return nil + case user.FieldModified: + m.ClearModified() + return nil + case user.FieldAccessToken: + m.ClearAccessToken() + return nil + case user.FieldRefreshToken: + m.ClearRefreshToken() + return nil + case user.FieldIDToken: + m.ClearIDToken() + return nil + case user.FieldTokenType: + m.ClearTokenType() + return nil + case user.FieldTokenExpiry: + m.ClearTokenExpiry() + return nil + case user.FieldHash: + m.ClearHash() + return nil + case user.FieldTotpSecret: + m.ClearTotpSecret() + return nil + case user.FieldTotpSecretConfirmed: + m.ClearTotpSecretConfirmed() + return nil + case user.FieldForgotPasswordCode: + m.ClearForgotPasswordCode() + return nil + case user.FieldForgotPasswordCodeExpiresAt: + m.ClearForgotPasswordCodeExpiresAt() + return nil + case user.FieldNewUserToken: + m.ClearNewUserToken() + return nil + } + return fmt.Errorf("unknown User nullable field %s", name) } -// IDToken returns the value of the "id_token" field in the mutation. -func (m *UserMutation) IDToken() (r string, exists bool) { - v := m.id_token - if v == nil { - return +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserMutation) ResetField(name string) error { + switch name { + case user.FieldName: + m.ResetName() + return nil + case user.FieldEmail: + m.ResetEmail() + return nil + case user.FieldPhone: + m.ResetPhone() + return nil + case user.FieldCountry: + m.ResetCountry() + return nil + case user.FieldEmailVerified: + m.ResetEmailVerified() + return nil + case user.FieldRegister: + m.ResetRegister() + return nil + case user.FieldCertClearPassword: + m.ResetCertClearPassword() + return nil + case user.FieldExpiry: + m.ResetExpiry() + return nil + case user.FieldOpenid: + m.ResetOpenid() + return nil + case user.FieldPasswd: + m.ResetPasswd() + return nil + case user.FieldUse2fa: + m.ResetUse2fa() + return nil + case user.FieldCreated: + m.ResetCreated() + return nil + case user.FieldModified: + m.ResetModified() + return nil + case user.FieldAccessToken: + m.ResetAccessToken() + return nil + case user.FieldRefreshToken: + m.ResetRefreshToken() + return nil + case user.FieldIDToken: + m.ResetIDToken() + return nil + case user.FieldTokenType: + m.ResetTokenType() + return nil + case user.FieldTokenExpiry: + m.ResetTokenExpiry() + return nil + case user.FieldHash: + m.ResetHash() + return nil + case user.FieldTotpSecret: + m.ResetTotpSecret() + return nil + case user.FieldTotpSecretConfirmed: + m.ResetTotpSecretConfirmed() + return nil + case user.FieldForgotPasswordCode: + m.ResetForgotPasswordCode() + return nil + case user.FieldForgotPasswordCodeExpiresAt: + m.ResetForgotPasswordCodeExpiresAt() + return nil + case user.FieldNewUserToken: + m.ResetNewUserToken() + return nil } - return *v, true + return fmt.Errorf("unknown User field %s", name) } -// OldIDToken returns the old "id_token" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldIDToken(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIDToken is only allowed on UpdateOne operations") +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 3) + if m.sessions != nil { + edges = append(edges, user.EdgeSessions) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIDToken requires an ID field in the mutation") + if m.recoverycodes != nil { + edges = append(edges, user.EdgeRecoverycodes) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIDToken: %w", err) + if m.user_tenants != nil { + edges = append(edges, user.EdgeUserTenants) } - return oldValue.IDToken, nil -} - -// ClearIDToken clears the value of the "id_token" field. -func (m *UserMutation) ClearIDToken() { - m.id_token = nil - m.clearedFields[user.FieldIDToken] = struct{}{} -} - -// IDTokenCleared returns if the "id_token" field was cleared in this mutation. -func (m *UserMutation) IDTokenCleared() bool { - _, ok := m.clearedFields[user.FieldIDToken] - return ok + return edges } -// ResetIDToken resets all changes to the "id_token" field. -func (m *UserMutation) ResetIDToken() { - m.id_token = nil - delete(m.clearedFields, user.FieldIDToken) +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + switch name { + case user.EdgeSessions: + ids := make([]ent.Value, 0, len(m.sessions)) + for id := range m.sessions { + ids = append(ids, id) + } + return ids + case user.EdgeRecoverycodes: + ids := make([]ent.Value, 0, len(m.recoverycodes)) + for id := range m.recoverycodes { + ids = append(ids, id) + } + return ids + case user.EdgeUserTenants: + ids := make([]ent.Value, 0, len(m.user_tenants)) + for id := range m.user_tenants { + ids = append(ids, id) + } + return ids + } + return nil } -// SetTokenType sets the "token_type" field. -func (m *UserMutation) SetTokenType(s string) { - m.token_type = &s +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 3) + if m.removedsessions != nil { + edges = append(edges, user.EdgeSessions) + } + if m.removedrecoverycodes != nil { + edges = append(edges, user.EdgeRecoverycodes) + } + if m.removeduser_tenants != nil { + edges = append(edges, user.EdgeUserTenants) + } + return edges } -// TokenType returns the value of the "token_type" field in the mutation. -func (m *UserMutation) TokenType() (r string, exists bool) { - v := m.token_type - if v == nil { - return +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + switch name { + case user.EdgeSessions: + ids := make([]ent.Value, 0, len(m.removedsessions)) + for id := range m.removedsessions { + ids = append(ids, id) + } + return ids + case user.EdgeRecoverycodes: + ids := make([]ent.Value, 0, len(m.removedrecoverycodes)) + for id := range m.removedrecoverycodes { + ids = append(ids, id) + } + return ids + case user.EdgeUserTenants: + ids := make([]ent.Value, 0, len(m.removeduser_tenants)) + for id := range m.removeduser_tenants { + ids = append(ids, id) + } + return ids } - return *v, true + return nil } -// OldTokenType returns the old "token_type" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldTokenType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTokenType is only allowed on UpdateOne operations") +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 3) + if m.clearedsessions { + edges = append(edges, user.EdgeSessions) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTokenType requires an ID field in the mutation") + if m.clearedrecoverycodes { + edges = append(edges, user.EdgeRecoverycodes) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTokenType: %w", err) + if m.cleareduser_tenants { + edges = append(edges, user.EdgeUserTenants) } - return oldValue.TokenType, nil + return edges } -// ClearTokenType clears the value of the "token_type" field. -func (m *UserMutation) ClearTokenType() { - m.token_type = nil - m.clearedFields[user.FieldTokenType] = struct{}{} +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + switch name { + case user.EdgeSessions: + return m.clearedsessions + case user.EdgeRecoverycodes: + return m.clearedrecoverycodes + case user.EdgeUserTenants: + return m.cleareduser_tenants + } + return false } -// TokenTypeCleared returns if the "token_type" field was cleared in this mutation. -func (m *UserMutation) TokenTypeCleared() bool { - _, ok := m.clearedFields[user.FieldTokenType] - return ok +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown User unique edge %s", name) } -// ResetTokenType resets all changes to the "token_type" field. -func (m *UserMutation) ResetTokenType() { - m.token_type = nil - delete(m.clearedFields, user.FieldTokenType) +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserMutation) ResetEdge(name string) error { + switch name { + case user.EdgeSessions: + m.ResetSessions() + return nil + case user.EdgeRecoverycodes: + m.ResetRecoverycodes() + return nil + case user.EdgeUserTenants: + m.ResetUserTenants() + return nil + } + return fmt.Errorf("unknown User edge %s", name) } -// SetTokenExpiry sets the "token_expiry" field. -func (m *UserMutation) SetTokenExpiry(i int) { - m.token_expiry = &i - m.addtoken_expiry = nil +// UserTenantMutation represents an operation that mutates the UserTenant nodes in the graph. +type UserTenantMutation struct { + config + op Op + typ string + id *int + role *usertenant.Role + is_default *bool + created *time.Time + modified *time.Time + clearedFields map[string]struct{} + user *string + cleareduser bool + tenant *int + clearedtenant bool + done bool + oldValue func(context.Context) (*UserTenant, error) + predicates []predicate.UserTenant } -// TokenExpiry returns the value of the "token_expiry" field in the mutation. -func (m *UserMutation) TokenExpiry() (r int, exists bool) { - v := m.token_expiry - if v == nil { - return - } - return *v, true -} +var _ ent.Mutation = (*UserTenantMutation)(nil) -// OldTokenExpiry returns the old "token_expiry" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldTokenExpiry(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTokenExpiry is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTokenExpiry requires an ID field in the mutation") +// usertenantOption allows management of the mutation configuration using functional options. +type usertenantOption func(*UserTenantMutation) + +// newUserTenantMutation creates new mutation for the UserTenant entity. +func newUserTenantMutation(c config, op Op, opts ...usertenantOption) *UserTenantMutation { + m := &UserTenantMutation{ + config: c, + op: op, + typ: TypeUserTenant, + clearedFields: make(map[string]struct{}), } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTokenExpiry: %w", err) + for _, opt := range opts { + opt(m) } - return oldValue.TokenExpiry, nil + return m } -// AddTokenExpiry adds i to the "token_expiry" field. -func (m *UserMutation) AddTokenExpiry(i int) { - if m.addtoken_expiry != nil { - *m.addtoken_expiry += i - } else { - m.addtoken_expiry = &i +// withUserTenantID sets the ID field of the mutation. +func withUserTenantID(id int) usertenantOption { + return func(m *UserTenantMutation) { + var ( + err error + once sync.Once + value *UserTenant + ) + m.oldValue = func(ctx context.Context) (*UserTenant, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserTenant.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } } -// AddedTokenExpiry returns the value that was added to the "token_expiry" field in this mutation. -func (m *UserMutation) AddedTokenExpiry() (r int, exists bool) { - v := m.addtoken_expiry - if v == nil { - return +// withUserTenant sets the old UserTenant of the mutation. +func withUserTenant(node *UserTenant) usertenantOption { + return func(m *UserTenantMutation) { + m.oldValue = func(context.Context) (*UserTenant, error) { + return node, nil + } + m.id = &node.ID } - return *v, true } -// ClearTokenExpiry clears the value of the "token_expiry" field. -func (m *UserMutation) ClearTokenExpiry() { - m.token_expiry = nil - m.addtoken_expiry = nil - m.clearedFields[user.FieldTokenExpiry] = struct{}{} +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserTenantMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// TokenExpiryCleared returns if the "token_expiry" field was cleared in this mutation. -func (m *UserMutation) TokenExpiryCleared() bool { - _, ok := m.clearedFields[user.FieldTokenExpiry] - return ok +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserTenantMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// ResetTokenExpiry resets all changes to the "token_expiry" field. -func (m *UserMutation) ResetTokenExpiry() { - m.token_expiry = nil - m.addtoken_expiry = nil - delete(m.clearedFields, user.FieldTokenExpiry) +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserTenantMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// SetHash sets the "hash" field. -func (m *UserMutation) SetHash(s string) { - m.hash = &s +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserTenantMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserTenant.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// Hash returns the value of the "hash" field in the mutation. -func (m *UserMutation) Hash() (r string, exists bool) { - v := m.hash +// SetUserID sets the "user_id" field. +func (m *UserTenantMutation) SetUserID(s string) { + m.user = &s +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserTenantMutation) UserID() (r string, exists bool) { + v := m.user if v == nil { return } return *v, true } -// OldHash returns the old "hash" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the UserTenant entity. +// If the UserTenant object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldHash(ctx context.Context) (v string, err error) { +func (m *UserTenantMutation) OldUserID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldHash is only allowed on UpdateOne operations") + return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldHash requires an ID field in the mutation") + return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldHash: %w", err) + return v, fmt.Errorf("querying old value for OldUserID: %w", err) } - return oldValue.Hash, nil -} - -// ClearHash clears the value of the "hash" field. -func (m *UserMutation) ClearHash() { - m.hash = nil - m.clearedFields[user.FieldHash] = struct{}{} -} - -// HashCleared returns if the "hash" field was cleared in this mutation. -func (m *UserMutation) HashCleared() bool { - _, ok := m.clearedFields[user.FieldHash] - return ok + return oldValue.UserID, nil } -// ResetHash resets all changes to the "hash" field. -func (m *UserMutation) ResetHash() { - m.hash = nil - delete(m.clearedFields, user.FieldHash) +// ResetUserID resets all changes to the "user_id" field. +func (m *UserTenantMutation) ResetUserID() { + m.user = nil } -// SetTotpSecret sets the "totp_secret" field. -func (m *UserMutation) SetTotpSecret(s string) { - m.totp_secret = &s +// SetTenantID sets the "tenant_id" field. +func (m *UserTenantMutation) SetTenantID(i int) { + m.tenant = &i } -// TotpSecret returns the value of the "totp_secret" field in the mutation. -func (m *UserMutation) TotpSecret() (r string, exists bool) { - v := m.totp_secret +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *UserTenantMutation) TenantID() (r int, exists bool) { + v := m.tenant if v == nil { return } return *v, true } -// OldTotpSecret returns the old "totp_secret" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldTenantID returns the old "tenant_id" field's value of the UserTenant entity. +// If the UserTenant object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldTotpSecret(ctx context.Context) (v string, err error) { +func (m *UserTenantMutation) OldTenantID(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTotpSecret is only allowed on UpdateOne operations") + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTotpSecret requires an ID field in the mutation") + return v, errors.New("OldTenantID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTotpSecret: %w", err) + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) } - return oldValue.TotpSecret, nil -} - -// ClearTotpSecret clears the value of the "totp_secret" field. -func (m *UserMutation) ClearTotpSecret() { - m.totp_secret = nil - m.clearedFields[user.FieldTotpSecret] = struct{}{} -} - -// TotpSecretCleared returns if the "totp_secret" field was cleared in this mutation. -func (m *UserMutation) TotpSecretCleared() bool { - _, ok := m.clearedFields[user.FieldTotpSecret] - return ok + return oldValue.TenantID, nil } -// ResetTotpSecret resets all changes to the "totp_secret" field. -func (m *UserMutation) ResetTotpSecret() { - m.totp_secret = nil - delete(m.clearedFields, user.FieldTotpSecret) +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *UserTenantMutation) ResetTenantID() { + m.tenant = nil } -// SetTotpSecretConfirmed sets the "totp_secret_confirmed" field. -func (m *UserMutation) SetTotpSecretConfirmed(b bool) { - m.totp_secret_confirmed = &b +// SetRole sets the "role" field. +func (m *UserTenantMutation) SetRole(u usertenant.Role) { + m.role = &u } -// TotpSecretConfirmed returns the value of the "totp_secret_confirmed" field in the mutation. -func (m *UserMutation) TotpSecretConfirmed() (r bool, exists bool) { - v := m.totp_secret_confirmed +// Role returns the value of the "role" field in the mutation. +func (m *UserTenantMutation) Role() (r usertenant.Role, exists bool) { + v := m.role if v == nil { return } return *v, true } -// OldTotpSecretConfirmed returns the old "totp_secret_confirmed" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldRole returns the old "role" field's value of the UserTenant entity. +// If the UserTenant object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldTotpSecretConfirmed(ctx context.Context) (v bool, err error) { +func (m *UserTenantMutation) OldRole(ctx context.Context) (v usertenant.Role, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTotpSecretConfirmed is only allowed on UpdateOne operations") + return v, errors.New("OldRole is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTotpSecretConfirmed requires an ID field in the mutation") + return v, errors.New("OldRole requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTotpSecretConfirmed: %w", err) + return v, fmt.Errorf("querying old value for OldRole: %w", err) } - return oldValue.TotpSecretConfirmed, nil -} - -// ClearTotpSecretConfirmed clears the value of the "totp_secret_confirmed" field. -func (m *UserMutation) ClearTotpSecretConfirmed() { - m.totp_secret_confirmed = nil - m.clearedFields[user.FieldTotpSecretConfirmed] = struct{}{} -} - -// TotpSecretConfirmedCleared returns if the "totp_secret_confirmed" field was cleared in this mutation. -func (m *UserMutation) TotpSecretConfirmedCleared() bool { - _, ok := m.clearedFields[user.FieldTotpSecretConfirmed] - return ok + return oldValue.Role, nil } -// ResetTotpSecretConfirmed resets all changes to the "totp_secret_confirmed" field. -func (m *UserMutation) ResetTotpSecretConfirmed() { - m.totp_secret_confirmed = nil - delete(m.clearedFields, user.FieldTotpSecretConfirmed) +// ResetRole resets all changes to the "role" field. +func (m *UserTenantMutation) ResetRole() { + m.role = nil } -// SetForgotPasswordCode sets the "forgot_password_code" field. -func (m *UserMutation) SetForgotPasswordCode(s string) { - m.forgot_password_code = &s +// SetIsDefault sets the "is_default" field. +func (m *UserTenantMutation) SetIsDefault(b bool) { + m.is_default = &b } -// ForgotPasswordCode returns the value of the "forgot_password_code" field in the mutation. -func (m *UserMutation) ForgotPasswordCode() (r string, exists bool) { - v := m.forgot_password_code +// IsDefault returns the value of the "is_default" field in the mutation. +func (m *UserTenantMutation) IsDefault() (r bool, exists bool) { + v := m.is_default if v == nil { return } return *v, true } -// OldForgotPasswordCode returns the old "forgot_password_code" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldIsDefault returns the old "is_default" field's value of the UserTenant entity. +// If the UserTenant object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldForgotPasswordCode(ctx context.Context) (v string, err error) { +func (m *UserTenantMutation) OldIsDefault(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldForgotPasswordCode is only allowed on UpdateOne operations") + return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldForgotPasswordCode requires an ID field in the mutation") + return v, errors.New("OldIsDefault requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldForgotPasswordCode: %w", err) + return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) } - return oldValue.ForgotPasswordCode, nil -} - -// ClearForgotPasswordCode clears the value of the "forgot_password_code" field. -func (m *UserMutation) ClearForgotPasswordCode() { - m.forgot_password_code = nil - m.clearedFields[user.FieldForgotPasswordCode] = struct{}{} -} - -// ForgotPasswordCodeCleared returns if the "forgot_password_code" field was cleared in this mutation. -func (m *UserMutation) ForgotPasswordCodeCleared() bool { - _, ok := m.clearedFields[user.FieldForgotPasswordCode] - return ok + return oldValue.IsDefault, nil } -// ResetForgotPasswordCode resets all changes to the "forgot_password_code" field. -func (m *UserMutation) ResetForgotPasswordCode() { - m.forgot_password_code = nil - delete(m.clearedFields, user.FieldForgotPasswordCode) +// ResetIsDefault resets all changes to the "is_default" field. +func (m *UserTenantMutation) ResetIsDefault() { + m.is_default = nil } -// SetForgotPasswordCodeExpiresAt sets the "forgot_password_code_expires_at" field. -func (m *UserMutation) SetForgotPasswordCodeExpiresAt(t time.Time) { - m.forgot_password_code_expires_at = &t +// SetCreated sets the "created" field. +func (m *UserTenantMutation) SetCreated(t time.Time) { + m.created = &t } -// ForgotPasswordCodeExpiresAt returns the value of the "forgot_password_code_expires_at" field in the mutation. -func (m *UserMutation) ForgotPasswordCodeExpiresAt() (r time.Time, exists bool) { - v := m.forgot_password_code_expires_at +// Created returns the value of the "created" field in the mutation. +func (m *UserTenantMutation) Created() (r time.Time, exists bool) { + v := m.created if v == nil { return } return *v, true } -// OldForgotPasswordCodeExpiresAt returns the old "forgot_password_code_expires_at" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldCreated returns the old "created" field's value of the UserTenant entity. +// If the UserTenant object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldForgotPasswordCodeExpiresAt(ctx context.Context) (v time.Time, err error) { +func (m *UserTenantMutation) OldCreated(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldForgotPasswordCodeExpiresAt is only allowed on UpdateOne operations") + return v, errors.New("OldCreated is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldForgotPasswordCodeExpiresAt requires an ID field in the mutation") + return v, errors.New("OldCreated requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldForgotPasswordCodeExpiresAt: %w", err) + return v, fmt.Errorf("querying old value for OldCreated: %w", err) } - return oldValue.ForgotPasswordCodeExpiresAt, nil + return oldValue.Created, nil } -// ClearForgotPasswordCodeExpiresAt clears the value of the "forgot_password_code_expires_at" field. -func (m *UserMutation) ClearForgotPasswordCodeExpiresAt() { - m.forgot_password_code_expires_at = nil - m.clearedFields[user.FieldForgotPasswordCodeExpiresAt] = struct{}{} +// ClearCreated clears the value of the "created" field. +func (m *UserTenantMutation) ClearCreated() { + m.created = nil + m.clearedFields[usertenant.FieldCreated] = struct{}{} } -// ForgotPasswordCodeExpiresAtCleared returns if the "forgot_password_code_expires_at" field was cleared in this mutation. -func (m *UserMutation) ForgotPasswordCodeExpiresAtCleared() bool { - _, ok := m.clearedFields[user.FieldForgotPasswordCodeExpiresAt] +// CreatedCleared returns if the "created" field was cleared in this mutation. +func (m *UserTenantMutation) CreatedCleared() bool { + _, ok := m.clearedFields[usertenant.FieldCreated] return ok } -// ResetForgotPasswordCodeExpiresAt resets all changes to the "forgot_password_code_expires_at" field. -func (m *UserMutation) ResetForgotPasswordCodeExpiresAt() { - m.forgot_password_code_expires_at = nil - delete(m.clearedFields, user.FieldForgotPasswordCodeExpiresAt) +// ResetCreated resets all changes to the "created" field. +func (m *UserTenantMutation) ResetCreated() { + m.created = nil + delete(m.clearedFields, usertenant.FieldCreated) } -// SetNewUserToken sets the "new_user_token" field. -func (m *UserMutation) SetNewUserToken(s string) { - m.new_user_token = &s +// SetModified sets the "modified" field. +func (m *UserTenantMutation) SetModified(t time.Time) { + m.modified = &t } -// NewUserToken returns the value of the "new_user_token" field in the mutation. -func (m *UserMutation) NewUserToken() (r string, exists bool) { - v := m.new_user_token +// Modified returns the value of the "modified" field in the mutation. +func (m *UserTenantMutation) Modified() (r time.Time, exists bool) { + v := m.modified if v == nil { return } return *v, true } -// OldNewUserToken returns the old "new_user_token" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldModified returns the old "modified" field's value of the UserTenant entity. +// If the UserTenant object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldNewUserToken(ctx context.Context) (v string, err error) { +func (m *UserTenantMutation) OldModified(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNewUserToken is only allowed on UpdateOne operations") + return v, errors.New("OldModified is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNewUserToken requires an ID field in the mutation") + return v, errors.New("OldModified requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNewUserToken: %w", err) + return v, fmt.Errorf("querying old value for OldModified: %w", err) } - return oldValue.NewUserToken, nil + return oldValue.Modified, nil } -// ClearNewUserToken clears the value of the "new_user_token" field. -func (m *UserMutation) ClearNewUserToken() { - m.new_user_token = nil - m.clearedFields[user.FieldNewUserToken] = struct{}{} +// ClearModified clears the value of the "modified" field. +func (m *UserTenantMutation) ClearModified() { + m.modified = nil + m.clearedFields[usertenant.FieldModified] = struct{}{} } -// NewUserTokenCleared returns if the "new_user_token" field was cleared in this mutation. -func (m *UserMutation) NewUserTokenCleared() bool { - _, ok := m.clearedFields[user.FieldNewUserToken] +// ModifiedCleared returns if the "modified" field was cleared in this mutation. +func (m *UserTenantMutation) ModifiedCleared() bool { + _, ok := m.clearedFields[usertenant.FieldModified] return ok } -// ResetNewUserToken resets all changes to the "new_user_token" field. -func (m *UserMutation) ResetNewUserToken() { - m.new_user_token = nil - delete(m.clearedFields, user.FieldNewUserToken) -} - -// AddSessionIDs adds the "sessions" edge to the Sessions entity by ids. -func (m *UserMutation) AddSessionIDs(ids ...string) { - if m.sessions == nil { - m.sessions = make(map[string]struct{}) - } - for i := range ids { - m.sessions[ids[i]] = struct{}{} - } -} - -// ClearSessions clears the "sessions" edge to the Sessions entity. -func (m *UserMutation) ClearSessions() { - m.clearedsessions = true -} - -// SessionsCleared reports if the "sessions" edge to the Sessions entity was cleared. -func (m *UserMutation) SessionsCleared() bool { - return m.clearedsessions +// ResetModified resets all changes to the "modified" field. +func (m *UserTenantMutation) ResetModified() { + m.modified = nil + delete(m.clearedFields, usertenant.FieldModified) } -// RemoveSessionIDs removes the "sessions" edge to the Sessions entity by IDs. -func (m *UserMutation) RemoveSessionIDs(ids ...string) { - if m.removedsessions == nil { - m.removedsessions = make(map[string]struct{}) - } - for i := range ids { - delete(m.sessions, ids[i]) - m.removedsessions[ids[i]] = struct{}{} - } +// ClearUser clears the "user" edge to the User entity. +func (m *UserTenantMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[usertenant.FieldUserID] = struct{}{} } -// RemovedSessions returns the removed IDs of the "sessions" edge to the Sessions entity. -func (m *UserMutation) RemovedSessionsIDs() (ids []string) { - for id := range m.removedsessions { - ids = append(ids, id) - } - return +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserTenantMutation) UserCleared() bool { + return m.cleareduser } -// SessionsIDs returns the "sessions" edge IDs in the mutation. -func (m *UserMutation) SessionsIDs() (ids []string) { - for id := range m.sessions { - ids = append(ids, id) +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserTenantMutation) UserIDs() (ids []string) { + if id := m.user; id != nil { + ids = append(ids, *id) } return } -// ResetSessions resets all changes to the "sessions" edge. -func (m *UserMutation) ResetSessions() { - m.sessions = nil - m.clearedsessions = false - m.removedsessions = nil -} - -// AddRecoverycodeIDs adds the "recoverycodes" edge to the RecoveryCode entity by ids. -func (m *UserMutation) AddRecoverycodeIDs(ids ...int) { - if m.recoverycodes == nil { - m.recoverycodes = make(map[int]struct{}) - } - for i := range ids { - m.recoverycodes[ids[i]] = struct{}{} - } -} - -// ClearRecoverycodes clears the "recoverycodes" edge to the RecoveryCode entity. -func (m *UserMutation) ClearRecoverycodes() { - m.clearedrecoverycodes = true -} - -// RecoverycodesCleared reports if the "recoverycodes" edge to the RecoveryCode entity was cleared. -func (m *UserMutation) RecoverycodesCleared() bool { - return m.clearedrecoverycodes +// ResetUser resets all changes to the "user" edge. +func (m *UserTenantMutation) ResetUser() { + m.user = nil + m.cleareduser = false } -// RemoveRecoverycodeIDs removes the "recoverycodes" edge to the RecoveryCode entity by IDs. -func (m *UserMutation) RemoveRecoverycodeIDs(ids ...int) { - if m.removedrecoverycodes == nil { - m.removedrecoverycodes = make(map[int]struct{}) - } - for i := range ids { - delete(m.recoverycodes, ids[i]) - m.removedrecoverycodes[ids[i]] = struct{}{} - } +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (m *UserTenantMutation) ClearTenant() { + m.clearedtenant = true + m.clearedFields[usertenant.FieldTenantID] = struct{}{} } -// RemovedRecoverycodes returns the removed IDs of the "recoverycodes" edge to the RecoveryCode entity. -func (m *UserMutation) RemovedRecoverycodesIDs() (ids []int) { - for id := range m.removedrecoverycodes { - ids = append(ids, id) - } - return +// TenantCleared reports if the "tenant" edge to the Tenant entity was cleared. +func (m *UserTenantMutation) TenantCleared() bool { + return m.clearedtenant } -// RecoverycodesIDs returns the "recoverycodes" edge IDs in the mutation. -func (m *UserMutation) RecoverycodesIDs() (ids []int) { - for id := range m.recoverycodes { - ids = append(ids, id) +// TenantIDs returns the "tenant" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TenantID instead. It exists only for internal usage by the builders. +func (m *UserTenantMutation) TenantIDs() (ids []int) { + if id := m.tenant; id != nil { + ids = append(ids, *id) } return } -// ResetRecoverycodes resets all changes to the "recoverycodes" edge. -func (m *UserMutation) ResetRecoverycodes() { - m.recoverycodes = nil - m.clearedrecoverycodes = false - m.removedrecoverycodes = nil +// ResetTenant resets all changes to the "tenant" edge. +func (m *UserTenantMutation) ResetTenant() { + m.tenant = nil + m.clearedtenant = false } -// Where appends a list predicates to the UserMutation builder. -func (m *UserMutation) Where(ps ...predicate.User) { +// Where appends a list predicates to the UserTenantMutation builder. +func (m *UserTenantMutation) Where(ps ...predicate.UserTenant) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// WhereP appends storage-level predicates to the UserTenantMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.User, len(ps)) +func (m *UserTenantMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserTenant, len(ps)) for i := range ps { p[i] = ps[i] } @@ -39589,153 +43449,63 @@ func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *UserMutation) Op() Op { +func (m *UserTenantMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *UserMutation) SetOp(op Op) { +func (m *UserTenantMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (User). -func (m *UserMutation) Type() string { +// Type returns the node type of this mutation (UserTenant). +func (m *UserTenantMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 24) - if m.name != nil { - fields = append(fields, user.FieldName) - } - if m.email != nil { - fields = append(fields, user.FieldEmail) - } - if m.phone != nil { - fields = append(fields, user.FieldPhone) - } - if m.country != nil { - fields = append(fields, user.FieldCountry) - } - if m.email_verified != nil { - fields = append(fields, user.FieldEmailVerified) - } - if m.register != nil { - fields = append(fields, user.FieldRegister) - } - if m.cert_clear_password != nil { - fields = append(fields, user.FieldCertClearPassword) - } - if m.expiry != nil { - fields = append(fields, user.FieldExpiry) - } - if m.openid != nil { - fields = append(fields, user.FieldOpenid) - } - if m.passwd != nil { - fields = append(fields, user.FieldPasswd) - } - if m.use2fa != nil { - fields = append(fields, user.FieldUse2fa) - } - if m.created != nil { - fields = append(fields, user.FieldCreated) - } - if m.modified != nil { - fields = append(fields, user.FieldModified) - } - if m.access_token != nil { - fields = append(fields, user.FieldAccessToken) - } - if m.refresh_token != nil { - fields = append(fields, user.FieldRefreshToken) - } - if m.id_token != nil { - fields = append(fields, user.FieldIDToken) - } - if m.token_type != nil { - fields = append(fields, user.FieldTokenType) - } - if m.token_expiry != nil { - fields = append(fields, user.FieldTokenExpiry) - } - if m.hash != nil { - fields = append(fields, user.FieldHash) - } - if m.totp_secret != nil { - fields = append(fields, user.FieldTotpSecret) - } - if m.totp_secret_confirmed != nil { - fields = append(fields, user.FieldTotpSecretConfirmed) - } - if m.forgot_password_code != nil { - fields = append(fields, user.FieldForgotPasswordCode) - } - if m.forgot_password_code_expires_at != nil { - fields = append(fields, user.FieldForgotPasswordCodeExpiresAt) - } - if m.new_user_token != nil { - fields = append(fields, user.FieldNewUserToken) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *UserMutation) Field(name string) (ent.Value, bool) { - switch name { - case user.FieldName: - return m.Name() - case user.FieldEmail: - return m.Email() - case user.FieldPhone: - return m.Phone() - case user.FieldCountry: - return m.Country() - case user.FieldEmailVerified: - return m.EmailVerified() - case user.FieldRegister: - return m.Register() - case user.FieldCertClearPassword: - return m.CertClearPassword() - case user.FieldExpiry: - return m.Expiry() - case user.FieldOpenid: - return m.Openid() - case user.FieldPasswd: - return m.Passwd() - case user.FieldUse2fa: - return m.Use2fa() - case user.FieldCreated: +func (m *UserTenantMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.user != nil { + fields = append(fields, usertenant.FieldUserID) + } + if m.tenant != nil { + fields = append(fields, usertenant.FieldTenantID) + } + if m.role != nil { + fields = append(fields, usertenant.FieldRole) + } + if m.is_default != nil { + fields = append(fields, usertenant.FieldIsDefault) + } + if m.created != nil { + fields = append(fields, usertenant.FieldCreated) + } + if m.modified != nil { + fields = append(fields, usertenant.FieldModified) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserTenantMutation) Field(name string) (ent.Value, bool) { + switch name { + case usertenant.FieldUserID: + return m.UserID() + case usertenant.FieldTenantID: + return m.TenantID() + case usertenant.FieldRole: + return m.Role() + case usertenant.FieldIsDefault: + return m.IsDefault() + case usertenant.FieldCreated: return m.Created() - case user.FieldModified: + case usertenant.FieldModified: return m.Modified() - case user.FieldAccessToken: - return m.AccessToken() - case user.FieldRefreshToken: - return m.RefreshToken() - case user.FieldIDToken: - return m.IDToken() - case user.FieldTokenType: - return m.TokenType() - case user.FieldTokenExpiry: - return m.TokenExpiry() - case user.FieldHash: - return m.Hash() - case user.FieldTotpSecret: - return m.TotpSecret() - case user.FieldTotpSecretConfirmed: - return m.TotpSecretConfirmed() - case user.FieldForgotPasswordCode: - return m.ForgotPasswordCode() - case user.FieldForgotPasswordCodeExpiresAt: - return m.ForgotPasswordCodeExpiresAt() - case user.FieldNewUserToken: - return m.NewUserToken() } return nil, false } @@ -39743,254 +43513,87 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case user.FieldName: - return m.OldName(ctx) - case user.FieldEmail: - return m.OldEmail(ctx) - case user.FieldPhone: - return m.OldPhone(ctx) - case user.FieldCountry: - return m.OldCountry(ctx) - case user.FieldEmailVerified: - return m.OldEmailVerified(ctx) - case user.FieldRegister: - return m.OldRegister(ctx) - case user.FieldCertClearPassword: - return m.OldCertClearPassword(ctx) - case user.FieldExpiry: - return m.OldExpiry(ctx) - case user.FieldOpenid: - return m.OldOpenid(ctx) - case user.FieldPasswd: - return m.OldPasswd(ctx) - case user.FieldUse2fa: - return m.OldUse2fa(ctx) - case user.FieldCreated: +func (m *UserTenantMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case usertenant.FieldUserID: + return m.OldUserID(ctx) + case usertenant.FieldTenantID: + return m.OldTenantID(ctx) + case usertenant.FieldRole: + return m.OldRole(ctx) + case usertenant.FieldIsDefault: + return m.OldIsDefault(ctx) + case usertenant.FieldCreated: return m.OldCreated(ctx) - case user.FieldModified: + case usertenant.FieldModified: return m.OldModified(ctx) - case user.FieldAccessToken: - return m.OldAccessToken(ctx) - case user.FieldRefreshToken: - return m.OldRefreshToken(ctx) - case user.FieldIDToken: - return m.OldIDToken(ctx) - case user.FieldTokenType: - return m.OldTokenType(ctx) - case user.FieldTokenExpiry: - return m.OldTokenExpiry(ctx) - case user.FieldHash: - return m.OldHash(ctx) - case user.FieldTotpSecret: - return m.OldTotpSecret(ctx) - case user.FieldTotpSecretConfirmed: - return m.OldTotpSecretConfirmed(ctx) - case user.FieldForgotPasswordCode: - return m.OldForgotPasswordCode(ctx) - case user.FieldForgotPasswordCodeExpiresAt: - return m.OldForgotPasswordCodeExpiresAt(ctx) - case user.FieldNewUserToken: - return m.OldNewUserToken(ctx) } - return nil, fmt.Errorf("unknown User field %s", name) + return nil, fmt.Errorf("unknown UserTenant field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserMutation) SetField(name string, value ent.Value) error { +func (m *UserTenantMutation) SetField(name string, value ent.Value) error { switch name { - case user.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case user.FieldEmail: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEmail(v) - return nil - case user.FieldPhone: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPhone(v) - return nil - case user.FieldCountry: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCountry(v) - return nil - case user.FieldEmailVerified: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEmailVerified(v) - return nil - case user.FieldRegister: + case usertenant.FieldUserID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRegister(v) - return nil - case user.FieldCertClearPassword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCertClearPassword(v) + m.SetUserID(v) return nil - case user.FieldExpiry: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetExpiry(v) - return nil - case user.FieldOpenid: - v, ok := value.(bool) + case usertenant.FieldTenantID: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetOpenid(v) + m.SetTenantID(v) return nil - case user.FieldPasswd: - v, ok := value.(bool) + case usertenant.FieldRole: + v, ok := value.(usertenant.Role) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPasswd(v) + m.SetRole(v) return nil - case user.FieldUse2fa: + case usertenant.FieldIsDefault: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUse2fa(v) + m.SetIsDefault(v) return nil - case user.FieldCreated: + case usertenant.FieldCreated: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreated(v) return nil - case user.FieldModified: + case usertenant.FieldModified: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetModified(v) return nil - case user.FieldAccessToken: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAccessToken(v) - return nil - case user.FieldRefreshToken: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRefreshToken(v) - return nil - case user.FieldIDToken: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIDToken(v) - return nil - case user.FieldTokenType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTokenType(v) - return nil - case user.FieldTokenExpiry: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTokenExpiry(v) - return nil - case user.FieldHash: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetHash(v) - return nil - case user.FieldTotpSecret: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTotpSecret(v) - return nil - case user.FieldTotpSecretConfirmed: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTotpSecretConfirmed(v) - return nil - case user.FieldForgotPasswordCode: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetForgotPasswordCode(v) - return nil - case user.FieldForgotPasswordCodeExpiresAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetForgotPasswordCodeExpiresAt(v) - return nil - case user.FieldNewUserToken: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNewUserToken(v) - return nil } - return fmt.Errorf("unknown User field %s", name) + return fmt.Errorf("unknown UserTenant field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *UserMutation) AddedFields() []string { +func (m *UserTenantMutation) AddedFields() []string { var fields []string - if m.addtoken_expiry != nil { - fields = append(fields, user.FieldTokenExpiry) - } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *UserMutation) AddedField(name string) (ent.Value, bool) { +func (m *UserTenantMutation) AddedField(name string) (ent.Value, bool) { switch name { - case user.FieldTokenExpiry: - return m.AddedTokenExpiry() } return nil, false } @@ -39998,355 +43601,162 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserMutation) AddField(name string, value ent.Value) error { +func (m *UserTenantMutation) AddField(name string, value ent.Value) error { switch name { - case user.FieldTokenExpiry: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddTokenExpiry(v) - return nil } - return fmt.Errorf("unknown User numeric field %s", name) + return fmt.Errorf("unknown UserTenant numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *UserMutation) ClearedFields() []string { +func (m *UserTenantMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(user.FieldEmail) { - fields = append(fields, user.FieldEmail) - } - if m.FieldCleared(user.FieldPhone) { - fields = append(fields, user.FieldPhone) - } - if m.FieldCleared(user.FieldCountry) { - fields = append(fields, user.FieldCountry) - } - if m.FieldCleared(user.FieldCertClearPassword) { - fields = append(fields, user.FieldCertClearPassword) - } - if m.FieldCleared(user.FieldExpiry) { - fields = append(fields, user.FieldExpiry) - } - if m.FieldCleared(user.FieldOpenid) { - fields = append(fields, user.FieldOpenid) - } - if m.FieldCleared(user.FieldPasswd) { - fields = append(fields, user.FieldPasswd) - } - if m.FieldCleared(user.FieldUse2fa) { - fields = append(fields, user.FieldUse2fa) - } - if m.FieldCleared(user.FieldCreated) { - fields = append(fields, user.FieldCreated) - } - if m.FieldCleared(user.FieldModified) { - fields = append(fields, user.FieldModified) - } - if m.FieldCleared(user.FieldAccessToken) { - fields = append(fields, user.FieldAccessToken) - } - if m.FieldCleared(user.FieldRefreshToken) { - fields = append(fields, user.FieldRefreshToken) - } - if m.FieldCleared(user.FieldIDToken) { - fields = append(fields, user.FieldIDToken) + if m.FieldCleared(usertenant.FieldCreated) { + fields = append(fields, usertenant.FieldCreated) } - if m.FieldCleared(user.FieldTokenType) { - fields = append(fields, user.FieldTokenType) - } - if m.FieldCleared(user.FieldTokenExpiry) { - fields = append(fields, user.FieldTokenExpiry) - } - if m.FieldCleared(user.FieldHash) { - fields = append(fields, user.FieldHash) - } - if m.FieldCleared(user.FieldTotpSecret) { - fields = append(fields, user.FieldTotpSecret) - } - if m.FieldCleared(user.FieldTotpSecretConfirmed) { - fields = append(fields, user.FieldTotpSecretConfirmed) - } - if m.FieldCleared(user.FieldForgotPasswordCode) { - fields = append(fields, user.FieldForgotPasswordCode) - } - if m.FieldCleared(user.FieldForgotPasswordCodeExpiresAt) { - fields = append(fields, user.FieldForgotPasswordCodeExpiresAt) - } - if m.FieldCleared(user.FieldNewUserToken) { - fields = append(fields, user.FieldNewUserToken) + if m.FieldCleared(usertenant.FieldModified) { + fields = append(fields, usertenant.FieldModified) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *UserMutation) FieldCleared(name string) bool { +func (m *UserTenantMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *UserMutation) ClearField(name string) error { +func (m *UserTenantMutation) ClearField(name string) error { switch name { - case user.FieldEmail: - m.ClearEmail() - return nil - case user.FieldPhone: - m.ClearPhone() - return nil - case user.FieldCountry: - m.ClearCountry() - return nil - case user.FieldCertClearPassword: - m.ClearCertClearPassword() - return nil - case user.FieldExpiry: - m.ClearExpiry() - return nil - case user.FieldOpenid: - m.ClearOpenid() - return nil - case user.FieldPasswd: - m.ClearPasswd() - return nil - case user.FieldUse2fa: - m.ClearUse2fa() - return nil - case user.FieldCreated: + case usertenant.FieldCreated: m.ClearCreated() return nil - case user.FieldModified: + case usertenant.FieldModified: m.ClearModified() return nil - case user.FieldAccessToken: - m.ClearAccessToken() - return nil - case user.FieldRefreshToken: - m.ClearRefreshToken() - return nil - case user.FieldIDToken: - m.ClearIDToken() - return nil - case user.FieldTokenType: - m.ClearTokenType() - return nil - case user.FieldTokenExpiry: - m.ClearTokenExpiry() - return nil - case user.FieldHash: - m.ClearHash() - return nil - case user.FieldTotpSecret: - m.ClearTotpSecret() - return nil - case user.FieldTotpSecretConfirmed: - m.ClearTotpSecretConfirmed() - return nil - case user.FieldForgotPasswordCode: - m.ClearForgotPasswordCode() - return nil - case user.FieldForgotPasswordCodeExpiresAt: - m.ClearForgotPasswordCodeExpiresAt() - return nil - case user.FieldNewUserToken: - m.ClearNewUserToken() - return nil } - return fmt.Errorf("unknown User nullable field %s", name) + return fmt.Errorf("unknown UserTenant nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *UserMutation) ResetField(name string) error { +func (m *UserTenantMutation) ResetField(name string) error { switch name { - case user.FieldName: - m.ResetName() - return nil - case user.FieldEmail: - m.ResetEmail() - return nil - case user.FieldPhone: - m.ResetPhone() - return nil - case user.FieldCountry: - m.ResetCountry() - return nil - case user.FieldEmailVerified: - m.ResetEmailVerified() - return nil - case user.FieldRegister: - m.ResetRegister() - return nil - case user.FieldCertClearPassword: - m.ResetCertClearPassword() - return nil - case user.FieldExpiry: - m.ResetExpiry() + case usertenant.FieldUserID: + m.ResetUserID() return nil - case user.FieldOpenid: - m.ResetOpenid() + case usertenant.FieldTenantID: + m.ResetTenantID() return nil - case user.FieldPasswd: - m.ResetPasswd() + case usertenant.FieldRole: + m.ResetRole() return nil - case user.FieldUse2fa: - m.ResetUse2fa() + case usertenant.FieldIsDefault: + m.ResetIsDefault() return nil - case user.FieldCreated: + case usertenant.FieldCreated: m.ResetCreated() return nil - case user.FieldModified: + case usertenant.FieldModified: m.ResetModified() return nil - case user.FieldAccessToken: - m.ResetAccessToken() - return nil - case user.FieldRefreshToken: - m.ResetRefreshToken() - return nil - case user.FieldIDToken: - m.ResetIDToken() - return nil - case user.FieldTokenType: - m.ResetTokenType() - return nil - case user.FieldTokenExpiry: - m.ResetTokenExpiry() - return nil - case user.FieldHash: - m.ResetHash() - return nil - case user.FieldTotpSecret: - m.ResetTotpSecret() - return nil - case user.FieldTotpSecretConfirmed: - m.ResetTotpSecretConfirmed() - return nil - case user.FieldForgotPasswordCode: - m.ResetForgotPasswordCode() - return nil - case user.FieldForgotPasswordCodeExpiresAt: - m.ResetForgotPasswordCodeExpiresAt() - return nil - case user.FieldNewUserToken: - m.ResetNewUserToken() - return nil } - return fmt.Errorf("unknown User field %s", name) + return fmt.Errorf("unknown UserTenant field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserMutation) AddedEdges() []string { +func (m *UserTenantMutation) AddedEdges() []string { edges := make([]string, 0, 2) - if m.sessions != nil { - edges = append(edges, user.EdgeSessions) + if m.user != nil { + edges = append(edges, usertenant.EdgeUser) } - if m.recoverycodes != nil { - edges = append(edges, user.EdgeRecoverycodes) + if m.tenant != nil { + edges = append(edges, usertenant.EdgeTenant) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *UserMutation) AddedIDs(name string) []ent.Value { +func (m *UserTenantMutation) AddedIDs(name string) []ent.Value { switch name { - case user.EdgeSessions: - ids := make([]ent.Value, 0, len(m.sessions)) - for id := range m.sessions { - ids = append(ids, id) + case usertenant.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} } - return ids - case user.EdgeRecoverycodes: - ids := make([]ent.Value, 0, len(m.recoverycodes)) - for id := range m.recoverycodes { - ids = append(ids, id) + case usertenant.EdgeTenant: + if id := m.tenant; id != nil { + return []ent.Value{*id} } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserMutation) RemovedEdges() []string { +func (m *UserTenantMutation) RemovedEdges() []string { edges := make([]string, 0, 2) - if m.removedsessions != nil { - edges = append(edges, user.EdgeSessions) - } - if m.removedrecoverycodes != nil { - edges = append(edges, user.EdgeRecoverycodes) - } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *UserMutation) RemovedIDs(name string) []ent.Value { - switch name { - case user.EdgeSessions: - ids := make([]ent.Value, 0, len(m.removedsessions)) - for id := range m.removedsessions { - ids = append(ids, id) - } - return ids - case user.EdgeRecoverycodes: - ids := make([]ent.Value, 0, len(m.removedrecoverycodes)) - for id := range m.removedrecoverycodes { - ids = append(ids, id) - } - return ids - } +func (m *UserTenantMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserMutation) ClearedEdges() []string { +func (m *UserTenantMutation) ClearedEdges() []string { edges := make([]string, 0, 2) - if m.clearedsessions { - edges = append(edges, user.EdgeSessions) + if m.cleareduser { + edges = append(edges, usertenant.EdgeUser) } - if m.clearedrecoverycodes { - edges = append(edges, user.EdgeRecoverycodes) + if m.clearedtenant { + edges = append(edges, usertenant.EdgeTenant) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *UserMutation) EdgeCleared(name string) bool { +func (m *UserTenantMutation) EdgeCleared(name string) bool { switch name { - case user.EdgeSessions: - return m.clearedsessions - case user.EdgeRecoverycodes: - return m.clearedrecoverycodes + case usertenant.EdgeUser: + return m.cleareduser + case usertenant.EdgeTenant: + return m.clearedtenant } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *UserMutation) ClearEdge(name string) error { +func (m *UserTenantMutation) ClearEdge(name string) error { switch name { + case usertenant.EdgeUser: + m.ClearUser() + return nil + case usertenant.EdgeTenant: + m.ClearTenant() + return nil } - return fmt.Errorf("unknown User unique edge %s", name) + return fmt.Errorf("unknown UserTenant unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *UserMutation) ResetEdge(name string) error { +func (m *UserTenantMutation) ResetEdge(name string) error { switch name { - case user.EdgeSessions: - m.ResetSessions() + case usertenant.EdgeUser: + m.ResetUser() return nil - case user.EdgeRecoverycodes: - m.ResetRecoverycodes() + case usertenant.EdgeTenant: + m.ResetTenant() return nil } - return fmt.Errorf("unknown User edge %s", name) + return fmt.Errorf("unknown UserTenant edge %s", name) } // WingetConfigExclusionMutation represents an operation that mutates the WingetConfigExclusion nodes in the graph. diff --git a/predicate/predicate.go b/predicate/predicate.go index 06b7d3e..9c133f4 100644 --- a/predicate/predicate.go +++ b/predicate/predicate.go @@ -18,6 +18,9 @@ type App func(*sql.Selector) // Authentication is the predicate function for authentication builders. type Authentication func(*sql.Selector) +// Branding is the predicate function for branding builders. +type Branding func(*sql.Selector) + // Certificate is the predicate function for certificate builders. type Certificate func(*sql.Selector) @@ -27,6 +30,9 @@ type Computer func(*sql.Selector) // Deployment is the predicate function for deployment builders. type Deployment func(*sql.Selector) +// EnrollmentToken is the predicate function for enrollmenttoken builders. +type EnrollmentToken func(*sql.Selector) + // LogicalDisk is the predicate function for logicaldisk builders. type LogicalDisk func(*sql.Selector) @@ -111,5 +117,8 @@ type Update func(*sql.Selector) // User is the predicate function for user builders. type User func(*sql.Selector) +// UserTenant is the predicate function for usertenant builders. +type UserTenant func(*sql.Selector) + // WingetConfigExclusion is the predicate function for wingetconfigexclusion builders. type WingetConfigExclusion func(*sql.Selector) diff --git a/profile.go b/profile.go index caeea8f..733ecfd 100644 --- a/profile.go +++ b/profile.go @@ -21,10 +21,10 @@ type Profile struct { Name string `json:"name,omitempty"` // ApplyToAll holds the value of the "apply_to_all" field. ApplyToAll bool `json:"apply_to_all,omitempty"` - // Type holds the value of the "type" field. - Type profile.Type `json:"type,omitempty"` // Disabled holds the value of the "disabled" field. Disabled bool `json:"disabled,omitempty"` + // Type holds the value of the "type" field. + Type profile.Type `json:"type,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ProfileQuery when eager-loading is set. Edges ProfileEdges `json:"edges"` @@ -131,18 +131,18 @@ func (pr *Profile) assignValues(columns []string, values []any) error { } else if value.Valid { pr.ApplyToAll = value.Bool } - case profile.FieldType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - pr.Type = profile.Type(value.String) - } case profile.FieldDisabled: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field disabled", values[i]) } else if value.Valid { pr.Disabled = value.Bool } + case profile.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + pr.Type = profile.Type(value.String) + } case profile.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field site_profiles", value) @@ -212,11 +212,11 @@ func (pr *Profile) String() string { builder.WriteString("apply_to_all=") builder.WriteString(fmt.Sprintf("%v", pr.ApplyToAll)) builder.WriteString(", ") - builder.WriteString("type=") - builder.WriteString(fmt.Sprintf("%v", pr.Type)) - builder.WriteString(", ") builder.WriteString("disabled=") builder.WriteString(fmt.Sprintf("%v", pr.Disabled)) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", pr.Type)) builder.WriteByte(')') return builder.String() } diff --git a/profile/profile.go b/profile/profile.go index 57f9cd9..19493e0 100644 --- a/profile/profile.go +++ b/profile/profile.go @@ -18,10 +18,10 @@ const ( FieldName = "name" // FieldApplyToAll holds the string denoting the apply_to_all field in the database. FieldApplyToAll = "apply_to_all" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" // FieldDisabled holds the string denoting the disabled field in the database. FieldDisabled = "disabled" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" // EdgeTags holds the string denoting the tags edge name in mutations. EdgeTags = "tags" // EdgeTasks holds the string denoting the tasks edge name in mutations. @@ -65,8 +65,8 @@ var Columns = []string{ FieldID, FieldName, FieldApplyToAll, - FieldType, FieldDisabled, + FieldType, } // ForeignKeys holds the SQL foreign-keys that are owned by the "profiles" @@ -148,16 +148,16 @@ func ByApplyToAll(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldApplyToAll, opts...).ToFunc() } -// ByType orders the results by the type field. -func ByType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldType, opts...).ToFunc() -} - // ByDisabled orders the results by the disabled field. func ByDisabled(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDisabled, opts...).ToFunc() } +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + // ByTagsCount orders the results by tags count. func ByTagsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/profile/where.go b/profile/where.go index a2c6e60..6c43d5c 100644 --- a/profile/where.go +++ b/profile/where.go @@ -143,6 +143,16 @@ func ApplyToAllNEQ(v bool) predicate.Profile { return predicate.Profile(sql.FieldNEQ(FieldApplyToAll, v)) } +// DisabledEQ applies the EQ predicate on the "disabled" field. +func DisabledEQ(v bool) predicate.Profile { + return predicate.Profile(sql.FieldEQ(FieldDisabled, v)) +} + +// DisabledNEQ applies the NEQ predicate on the "disabled" field. +func DisabledNEQ(v bool) predicate.Profile { + return predicate.Profile(sql.FieldNEQ(FieldDisabled, v)) +} + // TypeEQ applies the EQ predicate on the "type" field. func TypeEQ(v Type) predicate.Profile { return predicate.Profile(sql.FieldEQ(FieldType, v)) @@ -173,16 +183,6 @@ func TypeNotNil() predicate.Profile { return predicate.Profile(sql.FieldNotNull(FieldType)) } -// DisabledEQ applies the EQ predicate on the "disabled" field. -func DisabledEQ(v bool) predicate.Profile { - return predicate.Profile(sql.FieldEQ(FieldDisabled, v)) -} - -// DisabledNEQ applies the NEQ predicate on the "disabled" field. -func DisabledNEQ(v bool) predicate.Profile { - return predicate.Profile(sql.FieldNEQ(FieldDisabled, v)) -} - // HasTags applies the HasEdge predicate on the "tags" edge. func HasTags() predicate.Profile { return predicate.Profile(func(s *sql.Selector) { diff --git a/profile_create.go b/profile_create.go index 11af9bd..fd6a19c 100644 --- a/profile_create.go +++ b/profile_create.go @@ -45,20 +45,6 @@ func (pc *ProfileCreate) SetNillableApplyToAll(b *bool) *ProfileCreate { return pc } -// SetType sets the "type" field. -func (pc *ProfileCreate) SetType(pr profile.Type) *ProfileCreate { - pc.mutation.SetType(pr) - return pc -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (pc *ProfileCreate) SetNillableType(pr *profile.Type) *ProfileCreate { - if pr != nil { - pc.SetType(*pr) - } - return pc -} - // SetDisabled sets the "disabled" field. func (pc *ProfileCreate) SetDisabled(b bool) *ProfileCreate { pc.mutation.SetDisabled(b) @@ -73,6 +59,20 @@ func (pc *ProfileCreate) SetNillableDisabled(b *bool) *ProfileCreate { return pc } +// SetType sets the "type" field. +func (pc *ProfileCreate) SetType(pr profile.Type) *ProfileCreate { + pc.mutation.SetType(pr) + return pc +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (pc *ProfileCreate) SetNillableType(pr *profile.Type) *ProfileCreate { + if pr != nil { + pc.SetType(*pr) + } + return pc +} + // AddTagIDs adds the "tags" edge to the Tag entity by IDs. func (pc *ProfileCreate) AddTagIDs(ids ...int) *ProfileCreate { pc.mutation.AddTagIDs(ids...) @@ -176,14 +176,14 @@ func (pc *ProfileCreate) defaults() { v := profile.DefaultApplyToAll pc.mutation.SetApplyToAll(v) } - if _, ok := pc.mutation.GetType(); !ok { - v := profile.DefaultType - pc.mutation.SetType(v) - } if _, ok := pc.mutation.Disabled(); !ok { v := profile.DefaultDisabled pc.mutation.SetDisabled(v) } + if _, ok := pc.mutation.GetType(); !ok { + v := profile.DefaultType + pc.mutation.SetType(v) + } } // check runs all checks and user-defined validators on the builder. @@ -199,14 +199,14 @@ func (pc *ProfileCreate) check() error { if _, ok := pc.mutation.ApplyToAll(); !ok { return &ValidationError{Name: "apply_to_all", err: errors.New(`ent: missing required field "Profile.apply_to_all"`)} } + if _, ok := pc.mutation.Disabled(); !ok { + return &ValidationError{Name: "disabled", err: errors.New(`ent: missing required field "Profile.disabled"`)} + } if v, ok := pc.mutation.GetType(); ok { if err := profile.TypeValidator(v); err != nil { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Profile.type": %w`, err)} } } - if _, ok := pc.mutation.Disabled(); !ok { - return &ValidationError{Name: "disabled", err: errors.New(`ent: missing required field "Profile.disabled"`)} - } return nil } @@ -242,14 +242,14 @@ func (pc *ProfileCreate) createSpec() (*Profile, *sqlgraph.CreateSpec) { _spec.SetField(profile.FieldApplyToAll, field.TypeBool, value) _node.ApplyToAll = value } - if value, ok := pc.mutation.GetType(); ok { - _spec.SetField(profile.FieldType, field.TypeEnum, value) - _node.Type = value - } if value, ok := pc.mutation.Disabled(); ok { _spec.SetField(profile.FieldDisabled, field.TypeBool, value) _node.Disabled = value } + if value, ok := pc.mutation.GetType(); ok { + _spec.SetField(profile.FieldType, field.TypeEnum, value) + _node.Type = value + } if nodes := pc.mutation.TagsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -391,6 +391,18 @@ func (u *ProfileUpsert) UpdateApplyToAll() *ProfileUpsert { return u } +// SetDisabled sets the "disabled" field. +func (u *ProfileUpsert) SetDisabled(v bool) *ProfileUpsert { + u.Set(profile.FieldDisabled, v) + return u +} + +// UpdateDisabled sets the "disabled" field to the value that was provided on create. +func (u *ProfileUpsert) UpdateDisabled() *ProfileUpsert { + u.SetExcluded(profile.FieldDisabled) + return u +} + // SetType sets the "type" field. func (u *ProfileUpsert) SetType(v profile.Type) *ProfileUpsert { u.Set(profile.FieldType, v) @@ -409,18 +421,6 @@ func (u *ProfileUpsert) ClearType() *ProfileUpsert { return u } -// SetDisabled sets the "disabled" field. -func (u *ProfileUpsert) SetDisabled(v bool) *ProfileUpsert { - u.Set(profile.FieldDisabled, v) - return u -} - -// UpdateDisabled sets the "disabled" field to the value that was provided on create. -func (u *ProfileUpsert) UpdateDisabled() *ProfileUpsert { - u.SetExcluded(profile.FieldDisabled) - return u -} - // UpdateNewValues updates the mutable fields using the new values that were set on create. // Using this option is equivalent to using: // @@ -489,6 +489,20 @@ func (u *ProfileUpsertOne) UpdateApplyToAll() *ProfileUpsertOne { }) } +// SetDisabled sets the "disabled" field. +func (u *ProfileUpsertOne) SetDisabled(v bool) *ProfileUpsertOne { + return u.Update(func(s *ProfileUpsert) { + s.SetDisabled(v) + }) +} + +// UpdateDisabled sets the "disabled" field to the value that was provided on create. +func (u *ProfileUpsertOne) UpdateDisabled() *ProfileUpsertOne { + return u.Update(func(s *ProfileUpsert) { + s.UpdateDisabled() + }) +} + // SetType sets the "type" field. func (u *ProfileUpsertOne) SetType(v profile.Type) *ProfileUpsertOne { return u.Update(func(s *ProfileUpsert) { @@ -510,20 +524,6 @@ func (u *ProfileUpsertOne) ClearType() *ProfileUpsertOne { }) } -// SetDisabled sets the "disabled" field. -func (u *ProfileUpsertOne) SetDisabled(v bool) *ProfileUpsertOne { - return u.Update(func(s *ProfileUpsert) { - s.SetDisabled(v) - }) -} - -// UpdateDisabled sets the "disabled" field to the value that was provided on create. -func (u *ProfileUpsertOne) UpdateDisabled() *ProfileUpsertOne { - return u.Update(func(s *ProfileUpsert) { - s.UpdateDisabled() - }) -} - // Exec executes the query. func (u *ProfileUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -756,6 +756,20 @@ func (u *ProfileUpsertBulk) UpdateApplyToAll() *ProfileUpsertBulk { }) } +// SetDisabled sets the "disabled" field. +func (u *ProfileUpsertBulk) SetDisabled(v bool) *ProfileUpsertBulk { + return u.Update(func(s *ProfileUpsert) { + s.SetDisabled(v) + }) +} + +// UpdateDisabled sets the "disabled" field to the value that was provided on create. +func (u *ProfileUpsertBulk) UpdateDisabled() *ProfileUpsertBulk { + return u.Update(func(s *ProfileUpsert) { + s.UpdateDisabled() + }) +} + // SetType sets the "type" field. func (u *ProfileUpsertBulk) SetType(v profile.Type) *ProfileUpsertBulk { return u.Update(func(s *ProfileUpsert) { @@ -777,20 +791,6 @@ func (u *ProfileUpsertBulk) ClearType() *ProfileUpsertBulk { }) } -// SetDisabled sets the "disabled" field. -func (u *ProfileUpsertBulk) SetDisabled(v bool) *ProfileUpsertBulk { - return u.Update(func(s *ProfileUpsert) { - s.SetDisabled(v) - }) -} - -// UpdateDisabled sets the "disabled" field to the value that was provided on create. -func (u *ProfileUpsertBulk) UpdateDisabled() *ProfileUpsertBulk { - return u.Update(func(s *ProfileUpsert) { - s.UpdateDisabled() - }) -} - // Exec executes the query. func (u *ProfileUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/profile_update.go b/profile_update.go index 3d1932f..098c13b 100644 --- a/profile_update.go +++ b/profile_update.go @@ -60,6 +60,20 @@ func (pu *ProfileUpdate) SetNillableApplyToAll(b *bool) *ProfileUpdate { return pu } +// SetDisabled sets the "disabled" field. +func (pu *ProfileUpdate) SetDisabled(b bool) *ProfileUpdate { + pu.mutation.SetDisabled(b) + return pu +} + +// SetNillableDisabled sets the "disabled" field if the given value is not nil. +func (pu *ProfileUpdate) SetNillableDisabled(b *bool) *ProfileUpdate { + if b != nil { + pu.SetDisabled(*b) + } + return pu +} + // SetType sets the "type" field. func (pu *ProfileUpdate) SetType(pr profile.Type) *ProfileUpdate { pu.mutation.SetType(pr) @@ -80,20 +94,6 @@ func (pu *ProfileUpdate) ClearType() *ProfileUpdate { return pu } -// SetDisabled sets the "disabled" field. -func (pu *ProfileUpdate) SetDisabled(b bool) *ProfileUpdate { - pu.mutation.SetDisabled(b) - return pu -} - -// SetNillableDisabled sets the "disabled" field if the given value is not nil. -func (pu *ProfileUpdate) SetNillableDisabled(b *bool) *ProfileUpdate { - if b != nil { - pu.SetDisabled(*b) - } - return pu -} - // AddTagIDs adds the "tags" edge to the Tag entity by IDs. func (pu *ProfileUpdate) AddTagIDs(ids ...int) *ProfileUpdate { pu.mutation.AddTagIDs(ids...) @@ -298,15 +298,15 @@ func (pu *ProfileUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := pu.mutation.ApplyToAll(); ok { _spec.SetField(profile.FieldApplyToAll, field.TypeBool, value) } + if value, ok := pu.mutation.Disabled(); ok { + _spec.SetField(profile.FieldDisabled, field.TypeBool, value) + } if value, ok := pu.mutation.GetType(); ok { _spec.SetField(profile.FieldType, field.TypeEnum, value) } if pu.mutation.TypeCleared() { _spec.ClearField(profile.FieldType, field.TypeEnum) } - if value, ok := pu.mutation.Disabled(); ok { - _spec.SetField(profile.FieldDisabled, field.TypeBool, value) - } if pu.mutation.TagsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -521,6 +521,20 @@ func (puo *ProfileUpdateOne) SetNillableApplyToAll(b *bool) *ProfileUpdateOne { return puo } +// SetDisabled sets the "disabled" field. +func (puo *ProfileUpdateOne) SetDisabled(b bool) *ProfileUpdateOne { + puo.mutation.SetDisabled(b) + return puo +} + +// SetNillableDisabled sets the "disabled" field if the given value is not nil. +func (puo *ProfileUpdateOne) SetNillableDisabled(b *bool) *ProfileUpdateOne { + if b != nil { + puo.SetDisabled(*b) + } + return puo +} + // SetType sets the "type" field. func (puo *ProfileUpdateOne) SetType(pr profile.Type) *ProfileUpdateOne { puo.mutation.SetType(pr) @@ -541,20 +555,6 @@ func (puo *ProfileUpdateOne) ClearType() *ProfileUpdateOne { return puo } -// SetDisabled sets the "disabled" field. -func (puo *ProfileUpdateOne) SetDisabled(b bool) *ProfileUpdateOne { - puo.mutation.SetDisabled(b) - return puo -} - -// SetNillableDisabled sets the "disabled" field if the given value is not nil. -func (puo *ProfileUpdateOne) SetNillableDisabled(b *bool) *ProfileUpdateOne { - if b != nil { - puo.SetDisabled(*b) - } - return puo -} - // AddTagIDs adds the "tags" edge to the Tag entity by IDs. func (puo *ProfileUpdateOne) AddTagIDs(ids ...int) *ProfileUpdateOne { puo.mutation.AddTagIDs(ids...) @@ -789,15 +789,15 @@ func (puo *ProfileUpdateOne) sqlSave(ctx context.Context) (_node *Profile, err e if value, ok := puo.mutation.ApplyToAll(); ok { _spec.SetField(profile.FieldApplyToAll, field.TypeBool, value) } + if value, ok := puo.mutation.Disabled(); ok { + _spec.SetField(profile.FieldDisabled, field.TypeBool, value) + } if value, ok := puo.mutation.GetType(); ok { _spec.SetField(profile.FieldType, field.TypeEnum, value) } if puo.mutation.TypeCleared() { _spec.ClearField(profile.FieldType, field.TypeEnum) } - if value, ok := puo.mutation.Disabled(); ok { - _spec.SetField(profile.FieldDisabled, field.TypeBool, value) - } if puo.mutation.TagsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/runtime.go b/runtime.go index 0cd1ce5..db206c2 100644 --- a/runtime.go +++ b/runtime.go @@ -7,7 +7,9 @@ import ( "github.com/open-uem/ent/agent" "github.com/open-uem/ent/authentication" + "github.com/open-uem/ent/branding" "github.com/open-uem/ent/deployment" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/logicaldisk" "github.com/open-uem/ent/netbird" "github.com/open-uem/ent/netbirdsettings" @@ -26,6 +28,7 @@ import ( "github.com/open-uem/ent/task" "github.com/open-uem/ent/tenant" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" "github.com/open-uem/ent/wingetconfigexclusion" ) @@ -161,30 +164,60 @@ func init() { authenticationDescOIDCClientID := authenticationFields[5].Descriptor() // authentication.DefaultOIDCClientID holds the default value on creation for the OIDC_client_id field. authentication.DefaultOIDCClientID = authenticationDescOIDCClientID.Default.(string) - // authenticationDescOIDCRole is the schema descriptor for OIDC_role field. - authenticationDescOIDCRole := authenticationFields[6].Descriptor() - // authentication.DefaultOIDCRole holds the default value on creation for the OIDC_role field. - authentication.DefaultOIDCRole = authenticationDescOIDCRole.Default.(string) + // authenticationDescOIDCRoleAdmin is the schema descriptor for OIDC_role_admin field. + authenticationDescOIDCRoleAdmin := authenticationFields[6].Descriptor() + // authentication.DefaultOIDCRoleAdmin holds the default value on creation for the OIDC_role_admin field. + authentication.DefaultOIDCRoleAdmin = authenticationDescOIDCRoleAdmin.Default.(string) + // authenticationDescOIDCRoleOperator is the schema descriptor for OIDC_role_operator field. + authenticationDescOIDCRoleOperator := authenticationFields[7].Descriptor() + // authentication.DefaultOIDCRoleOperator holds the default value on creation for the OIDC_role_operator field. + authentication.DefaultOIDCRoleOperator = authenticationDescOIDCRoleOperator.Default.(string) + // authenticationDescOIDCRoleUser is the schema descriptor for OIDC_role_user field. + authenticationDescOIDCRoleUser := authenticationFields[8].Descriptor() + // authentication.DefaultOIDCRoleUser holds the default value on creation for the OIDC_role_user field. + authentication.DefaultOIDCRoleUser = authenticationDescOIDCRoleUser.Default.(string) // authenticationDescOIDCCookieEncriptionKey is the schema descriptor for OIDC_cookie_encription_key field. - authenticationDescOIDCCookieEncriptionKey := authenticationFields[7].Descriptor() + authenticationDescOIDCCookieEncriptionKey := authenticationFields[9].Descriptor() // authentication.DefaultOIDCCookieEncriptionKey holds the default value on creation for the OIDC_cookie_encription_key field. authentication.DefaultOIDCCookieEncriptionKey = authenticationDescOIDCCookieEncriptionKey.Default.(string) // authenticationDescOIDCKeycloakPublicKey is the schema descriptor for OIDC_keycloak_public_key field. - authenticationDescOIDCKeycloakPublicKey := authenticationFields[8].Descriptor() + authenticationDescOIDCKeycloakPublicKey := authenticationFields[10].Descriptor() // authentication.DefaultOIDCKeycloakPublicKey holds the default value on creation for the OIDC_keycloak_public_key field. authentication.DefaultOIDCKeycloakPublicKey = authenticationDescOIDCKeycloakPublicKey.Default.(string) // authenticationDescOIDCAutoCreateAccount is the schema descriptor for OIDC_auto_create_account field. - authenticationDescOIDCAutoCreateAccount := authenticationFields[9].Descriptor() + authenticationDescOIDCAutoCreateAccount := authenticationFields[11].Descriptor() // authentication.DefaultOIDCAutoCreateAccount holds the default value on creation for the OIDC_auto_create_account field. authentication.DefaultOIDCAutoCreateAccount = authenticationDescOIDCAutoCreateAccount.Default.(bool) // authenticationDescOIDCAutoApprove is the schema descriptor for OIDC_auto_approve field. - authenticationDescOIDCAutoApprove := authenticationFields[10].Descriptor() + authenticationDescOIDCAutoApprove := authenticationFields[12].Descriptor() // authentication.DefaultOIDCAutoApprove holds the default value on creation for the OIDC_auto_approve field. authentication.DefaultOIDCAutoApprove = authenticationDescOIDCAutoApprove.Default.(bool) // authenticationDescUsePasswd is the schema descriptor for use_passwd field. - authenticationDescUsePasswd := authenticationFields[11].Descriptor() + authenticationDescUsePasswd := authenticationFields[13].Descriptor() // authentication.DefaultUsePasswd holds the default value on creation for the use_passwd field. authentication.DefaultUsePasswd = authenticationDescUsePasswd.Default.(bool) + brandingFields := schema.Branding{}.Fields() + _ = brandingFields + // brandingDescPrimaryColor is the schema descriptor for primary_color field. + brandingDescPrimaryColor := brandingFields[2].Descriptor() + // branding.DefaultPrimaryColor holds the default value on creation for the primary_color field. + branding.DefaultPrimaryColor = brandingDescPrimaryColor.Default.(string) + // brandingDescProductName is the schema descriptor for product_name field. + brandingDescProductName := brandingFields[3].Descriptor() + // branding.DefaultProductName holds the default value on creation for the product_name field. + branding.DefaultProductName = brandingDescProductName.Default.(string) + // brandingDescShowVersion is the schema descriptor for show_version field. + brandingDescShowVersion := brandingFields[6].Descriptor() + // branding.DefaultShowVersion holds the default value on creation for the show_version field. + branding.DefaultShowVersion = brandingDescShowVersion.Default.(bool) + // brandingDescBugReportLink is the schema descriptor for bug_report_link field. + brandingDescBugReportLink := brandingFields[7].Descriptor() + // branding.DefaultBugReportLink holds the default value on creation for the bug_report_link field. + branding.DefaultBugReportLink = brandingDescBugReportLink.Default.(string) + // brandingDescHelpLink is the schema descriptor for help_link field. + brandingDescHelpLink := brandingFields[8].Descriptor() + // branding.DefaultHelpLink holds the default value on creation for the help_link field. + branding.DefaultHelpLink = brandingDescHelpLink.Default.(string) deploymentFields := schema.Deployment{}.Fields() _ = deploymentFields // deploymentDescInstalled is the schema descriptor for installed field. @@ -205,6 +238,34 @@ func init() { deploymentDescByProfile := deploymentFields[6].Descriptor() // deployment.DefaultByProfile holds the default value on creation for the by_profile field. deployment.DefaultByProfile = deploymentDescByProfile.Default.(bool) + enrollmenttokenFields := schema.EnrollmentToken{}.Fields() + _ = enrollmenttokenFields + // enrollmenttokenDescToken is the schema descriptor for token field. + enrollmenttokenDescToken := enrollmenttokenFields[0].Descriptor() + // enrollmenttoken.TokenValidator is a validator for the "token" field. It is called by the builders before save. + enrollmenttoken.TokenValidator = enrollmenttokenDescToken.Validators[0].(func(string) error) + // enrollmenttokenDescMaxUses is the schema descriptor for max_uses field. + enrollmenttokenDescMaxUses := enrollmenttokenFields[2].Descriptor() + // enrollmenttoken.DefaultMaxUses holds the default value on creation for the max_uses field. + enrollmenttoken.DefaultMaxUses = enrollmenttokenDescMaxUses.Default.(int) + // enrollmenttokenDescCurrentUses is the schema descriptor for current_uses field. + enrollmenttokenDescCurrentUses := enrollmenttokenFields[3].Descriptor() + // enrollmenttoken.DefaultCurrentUses holds the default value on creation for the current_uses field. + enrollmenttoken.DefaultCurrentUses = enrollmenttokenDescCurrentUses.Default.(int) + // enrollmenttokenDescActive is the schema descriptor for active field. + enrollmenttokenDescActive := enrollmenttokenFields[5].Descriptor() + // enrollmenttoken.DefaultActive holds the default value on creation for the active field. + enrollmenttoken.DefaultActive = enrollmenttokenDescActive.Default.(bool) + // enrollmenttokenDescCreated is the schema descriptor for created field. + enrollmenttokenDescCreated := enrollmenttokenFields[6].Descriptor() + // enrollmenttoken.DefaultCreated holds the default value on creation for the created field. + enrollmenttoken.DefaultCreated = enrollmenttokenDescCreated.Default.(func() time.Time) + // enrollmenttokenDescModified is the schema descriptor for modified field. + enrollmenttokenDescModified := enrollmenttokenFields[7].Descriptor() + // enrollmenttoken.DefaultModified holds the default value on creation for the modified field. + enrollmenttoken.DefaultModified = enrollmenttokenDescModified.Default.(func() time.Time) + // enrollmenttoken.UpdateDefaultModified holds the default value on update for the modified field. + enrollmenttoken.UpdateDefaultModified = enrollmenttokenDescModified.UpdateDefault.(func() time.Time) logicaldiskFields := schema.LogicalDisk{}.Fields() _ = logicaldiskFields // logicaldiskDescUsage is the schema descriptor for usage field. @@ -302,7 +363,7 @@ func init() { // profile.DefaultApplyToAll holds the default value on creation for the apply_to_all field. profile.DefaultApplyToAll = profileDescApplyToAll.Default.(bool) // profileDescDisabled is the schema descriptor for disabled field. - profileDescDisabled := profileFields[3].Descriptor() + profileDescDisabled := profileFields[2].Descriptor() // profile.DefaultDisabled holds the default value on creation for the disabled field. profile.DefaultDisabled = profileDescDisabled.Default.(bool) profileissueFields := schema.ProfileIssue{}.Fields() @@ -716,11 +777,11 @@ func init() { tenantFields := schema.Tenant{}.Fields() _ = tenantFields // tenantDescCreated is the schema descriptor for created field. - tenantDescCreated := tenantFields[2].Descriptor() + tenantDescCreated := tenantFields[4].Descriptor() // tenant.DefaultCreated holds the default value on creation for the created field. tenant.DefaultCreated = tenantDescCreated.Default.(func() time.Time) // tenantDescModified is the schema descriptor for modified field. - tenantDescModified := tenantFields[3].Descriptor() + tenantDescModified := tenantFields[5].Descriptor() // tenant.DefaultModified holds the default value on creation for the modified field. tenant.DefaultModified = tenantDescModified.Default.(func() time.Time) // tenant.UpdateDefaultModified holds the default value on update for the modified field. @@ -805,6 +866,26 @@ func init() { userDescID := userFields[0].Descriptor() // user.IDValidator is a validator for the "id" field. It is called by the builders before save. user.IDValidator = userDescID.Validators[0].(func(string) error) + usertenantFields := schema.UserTenant{}.Fields() + _ = usertenantFields + // usertenantDescUserID is the schema descriptor for user_id field. + usertenantDescUserID := usertenantFields[0].Descriptor() + // usertenant.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + usertenant.UserIDValidator = usertenantDescUserID.Validators[0].(func(string) error) + // usertenantDescIsDefault is the schema descriptor for is_default field. + usertenantDescIsDefault := usertenantFields[3].Descriptor() + // usertenant.DefaultIsDefault holds the default value on creation for the is_default field. + usertenant.DefaultIsDefault = usertenantDescIsDefault.Default.(bool) + // usertenantDescCreated is the schema descriptor for created field. + usertenantDescCreated := usertenantFields[4].Descriptor() + // usertenant.DefaultCreated holds the default value on creation for the created field. + usertenant.DefaultCreated = usertenantDescCreated.Default.(func() time.Time) + // usertenantDescModified is the schema descriptor for modified field. + usertenantDescModified := usertenantFields[5].Descriptor() + // usertenant.DefaultModified holds the default value on creation for the modified field. + usertenant.DefaultModified = usertenantDescModified.Default.(func() time.Time) + // usertenant.UpdateDefaultModified holds the default value on update for the modified field. + usertenant.UpdateDefaultModified = usertenantDescModified.UpdateDefault.(func() time.Time) wingetconfigexclusionFields := schema.WingetConfigExclusion{}.Fields() _ = wingetconfigexclusionFields // wingetconfigexclusionDescWhen is the schema descriptor for when field. diff --git a/schema/auth.go b/schema/auth.go index 53225c4..695ed18 100644 --- a/schema/auth.go +++ b/schema/auth.go @@ -19,7 +19,12 @@ func (Authentication) Fields() []ent.Field { field.String("OIDC_provider").Optional().Default(""), field.String("OIDC_issuer_url").Optional().Default(""), field.String("OIDC_client_id").Optional().Default(""), - field.String("OIDC_role").Optional().Default(""), + field.String("OIDC_role_admin").Optional().Default(""). + Comment("OIDC role/group that maps to admin (e.g. openuem_admin)"), + field.String("OIDC_role_operator").Optional().Default(""). + Comment("OIDC role/group that maps to operator (e.g. openuem_operator)"), + field.String("OIDC_role_user").Optional().Default(""). + Comment("OIDC role/group that maps to user (e.g. openuem_user)"), field.String("OIDC_cookie_encription_key").Optional().Default(""), field.String("OIDC_keycloak_public_key").Optional().Default(""), field.Bool("OIDC_auto_create_account").Optional().Default(true), diff --git a/schema/branding.go b/schema/branding.go new file mode 100644 index 0000000..46716fe --- /dev/null +++ b/schema/branding.go @@ -0,0 +1,66 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" +) + +// Branding holds the schema definition for the Branding entity. +// This stores global provider branding settings that apply across all tenants. +type Branding struct { + ent.Schema +} + +// Fields of the Branding. +func (Branding) Fields() []ent.Field { + return []ent.Field{ + // Logo fields - stored as base64 data URLs + field.Text("logo_light"). + Optional(). + Comment("Logo as base64 data URL"), + field.Text("logo_small"). + Optional(). + Comment("Favicon as base64 data URL"), + + // Color customization + field.String("primary_color"). + Optional(). + Default("#16a34a"). + Comment("Primary brand color (hex)"), + + // Product name + field.String("product_name"). + Optional(). + Default("OpenUEM"). + Comment("Custom product name to display"), + + // Login page customization + field.Text("login_background_image"). + Optional(). + Comment("Login page background image as base64 data URL"), + field.String("login_welcome_text"). + Optional(). + Comment("Welcome text shown on login page"), + + // UI visibility + field.Bool("show_version"). + Optional(). + Default(true). + Comment("Whether to display the version number in the header"), + + // Customizable links + field.String("bug_report_link"). + Optional(). + Default("https://github.com/open-uem/openuem-console/issues/new/choose"). + Comment("URL or email for bug reports"), + field.String("help_link"). + Optional(). + Default("https://openuem.eu/docs/intro"). + Comment("URL or email for help/documentation"), + } +} + +// Edges of the Branding. +func (Branding) Edges() []ent.Edge { + return nil +} diff --git a/schema/certificate.go b/schema/certificate.go index 8253f76..7d28d91 100644 --- a/schema/certificate.go +++ b/schema/certificate.go @@ -2,6 +2,7 @@ package schema import ( "entgo.io/ent" + "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" ) @@ -18,5 +19,18 @@ func (Certificate) Fields() []ent.Field { field.String("description").Optional(), field.Time("expiry").Optional(), field.String("uid").Optional(), + field.Int("tenant_id"). + Optional(). + Nillable(). + Comment("The tenant this certificate belongs to (nil for global/hoster certificates)"), + } +} + +// Edges of the Certificate. +func (Certificate) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("tenant", Tenant.Type). + Unique(). + Field("tenant_id"), } } diff --git a/schema/enrollmenttoken.go b/schema/enrollmenttoken.go new file mode 100644 index 0000000..a369c74 --- /dev/null +++ b/schema/enrollmenttoken.go @@ -0,0 +1,56 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// EnrollmentToken holds the schema definition for the EnrollmentToken entity. +// Enrollment tokens allow tenant admins to securely register agents to their tenant. +type EnrollmentToken struct { + ent.Schema +} + +// Fields of the EnrollmentToken. +func (EnrollmentToken) Fields() []ent.Field { + return []ent.Field{ + field.String("token"). + NotEmpty(). + Unique(). + Comment("The enrollment token value (UUID)"), + field.String("description"). + Optional(). + Comment("Human-readable description for this token"), + field.Int("max_uses"). + Default(0). + Comment("Maximum number of times this token can be used (0 = unlimited)"), + field.Int("current_uses"). + Default(0). + Comment("Number of times this token has been used"), + field.Time("expires_at"). + Optional(). + Nillable(). + Comment("When this token expires (nil = never)"), + field.Bool("active"). + Default(true). + Comment("Whether this token is currently active"), + field.Time("created").Optional().Default(time.Now), + field.Time("modified").Optional().Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the EnrollmentToken. +func (EnrollmentToken) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("tenant", Tenant.Type). + Ref("enrollment_tokens"). + Unique(). + Required(), + edge.From("site", Site.Type). + Ref("enrollment_tokens"). + Unique(), + } +} diff --git a/schema/memoryslot.go b/schema/memoryslot.go index 51b3870..8b2e590 100644 --- a/schema/memoryslot.go +++ b/schema/memoryslot.go @@ -6,12 +6,12 @@ import ( "entgo.io/ent/schema/field" ) -// MemorySlot holds the schema definition for the Monitor entity. +// MemorySlot holds the schema definition for the MemorySlot entity. type MemorySlot struct { ent.Schema } -// Fields of the Memory. +// Fields of the MemorySlot. func (MemorySlot) Fields() []ent.Field { return []ent.Field{ field.String("slot").Optional(), @@ -24,7 +24,7 @@ func (MemorySlot) Fields() []ent.Field { } } -// Edges of the Memory. +// Edges of the MemorySlot. func (MemorySlot) Edges() []ent.Edge { return []ent.Edge{ edge.From("owner", Agent.Type).Unique().Ref("memoryslots").Required(), diff --git a/schema/netbirdsettings.go b/schema/netbirdsettings.go index 7587586..f399310 100644 --- a/schema/netbirdsettings.go +++ b/schema/netbirdsettings.go @@ -6,7 +6,7 @@ import ( "entgo.io/ent/schema/field" ) -// NetbirdSettings holds the schema definition for the Rustdesk entity. +// NetbirdSettings holds the schema definition for the NetbirdSettings entity. type NetbirdSettings struct { ent.Schema } diff --git a/schema/profile.go b/schema/profile.go index b3276a5..ee9a732 100644 --- a/schema/profile.go +++ b/schema/profile.go @@ -17,8 +17,8 @@ func (Profile) Fields() []ent.Field { return []ent.Field{ field.String("name").NotEmpty(), field.Bool("apply_to_all").Default(false), - field.Enum("type").Values("winget").Optional().Default("winget"), field.Bool("disabled").Default(false), + field.Enum("type").Values("winget").Optional().Default("winget"), } } diff --git a/schema/site.go b/schema/site.go index 1a66144..4ac8b6a 100644 --- a/schema/site.go +++ b/schema/site.go @@ -31,5 +31,6 @@ func (Site) Edges() []ent.Edge { edge.From("tenant", Tenant.Type).Ref("sites").Unique(), edge.To("agents", Agent.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("profiles", Profile.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), + edge.To("enrollment_tokens", EnrollmentToken.Type), } } diff --git a/schema/tenant.go b/schema/tenant.go index a6deadf..8382872 100644 --- a/schema/tenant.go +++ b/schema/tenant.go @@ -19,6 +19,14 @@ func (Tenant) Fields() []ent.Field { return []ent.Field{ field.String("description").Optional(), field.Bool("is_default").Optional(), + field.String("oidc_org_id"). + Optional(). + Comment("OIDC organization ID (e.g. Zitadel Org-ID) for automatic tenant mapping"), + field.Enum("oidc_default_role"). + Values("admin", "operator", "user"). + Default("user"). + Optional(). + Comment("Default role for users auto-assigned via OIDC"), field.Time("created").Optional().Default(time.Now), field.Time("modified").Optional().Default(time.Now).UpdateDefault(time.Now), } @@ -33,5 +41,7 @@ func (Tenant) Edges() []ent.Edge { edge.To("metadata", OrgMetadata.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("rustdesk", Rustdesk.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("netbird", NetbirdSettings.Type).Unique().Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), + edge.From("user_tenants", UserTenant.Type).Ref("tenant"), + edge.To("enrollment_tokens", EnrollmentToken.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), } } diff --git a/schema/user.go b/schema/user.go index fca4f6a..d5c5921 100644 --- a/schema/user.go +++ b/schema/user.go @@ -50,6 +50,7 @@ func (User) Edges() []ent.Edge { return []ent.Edge{ edge.To("sessions", Sessions.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("recoverycodes", RecoveryCode.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), + edge.From("user_tenants", UserTenant.Type).Ref("user"), } } diff --git a/schema/usertenant.go b/schema/usertenant.go new file mode 100644 index 0000000..c37e76b --- /dev/null +++ b/schema/usertenant.go @@ -0,0 +1,55 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// UserTenant holds the schema definition for the User-Tenant relationship. +// This is the junction table that connects users to tenants with their role. +type UserTenant struct { + ent.Schema +} + +// Fields of the UserTenant. +func (UserTenant) Fields() []ent.Field { + return []ent.Field{ + field.String("user_id").NotEmpty(), + field.Int("tenant_id"), + field.Enum("role"). + Values("admin", "operator", "user"). + Default("user"). + Comment("The role of the user within this tenant"), + field.Bool("is_default"). + Default(false). + Comment("If true, this is the default tenant for the user after login"), + field.Time("created").Optional().Default(time.Now), + field.Time("modified").Optional().Default(time.Now).UpdateDefault(time.Now), + } +} + +// Edges of the UserTenant. +func (UserTenant) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("user", User.Type). + Unique(). + Required(). + Field("user_id"), + edge.To("tenant", Tenant.Type). + Unique(). + Required(). + Field("tenant_id"), + } +} + +// Indexes of the UserTenant. +func (UserTenant) Indexes() []ent.Index { + return []ent.Index{ + // Ensure a user can only be assigned to a tenant once + index.Fields("user_id", "tenant_id").Unique(), + } +} diff --git a/site.go b/site.go index 87e878d..eb38e20 100644 --- a/site.go +++ b/site.go @@ -43,9 +43,11 @@ type SiteEdges struct { Agents []*Agent `json:"agents,omitempty"` // Profiles holds the value of the profiles edge. Profiles []*Profile `json:"profiles,omitempty"` + // EnrollmentTokens holds the value of the enrollment_tokens edge. + EnrollmentTokens []*EnrollmentToken `json:"enrollment_tokens,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool + loadedTypes [4]bool } // TenantOrErr returns the Tenant value or an error if the edge @@ -77,6 +79,15 @@ func (e SiteEdges) ProfilesOrErr() ([]*Profile, error) { return nil, &NotLoadedError{edge: "profiles"} } +// EnrollmentTokensOrErr returns the EnrollmentTokens value or an error if the edge +// was not loaded in eager-loading. +func (e SiteEdges) EnrollmentTokensOrErr() ([]*EnrollmentToken, error) { + if e.loadedTypes[3] { + return e.EnrollmentTokens, nil + } + return nil, &NotLoadedError{edge: "enrollment_tokens"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Site) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -178,6 +189,11 @@ func (s *Site) QueryProfiles() *ProfileQuery { return NewSiteClient(s.config).QueryProfiles(s) } +// QueryEnrollmentTokens queries the "enrollment_tokens" edge of the Site entity. +func (s *Site) QueryEnrollmentTokens() *EnrollmentTokenQuery { + return NewSiteClient(s.config).QueryEnrollmentTokens(s) +} + // Update returns a builder for updating this Site. // Note that you need to call Site.Unwrap() before calling this method if this Site // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/site/site.go b/site/site.go index 3b2c7c6..511f5ed 100644 --- a/site/site.go +++ b/site/site.go @@ -30,6 +30,8 @@ const ( EdgeAgents = "agents" // EdgeProfiles holds the string denoting the profiles edge name in mutations. EdgeProfiles = "profiles" + // EdgeEnrollmentTokens holds the string denoting the enrollment_tokens edge name in mutations. + EdgeEnrollmentTokens = "enrollment_tokens" // AgentFieldID holds the string denoting the ID field of the Agent. AgentFieldID = "oid" // Table holds the table name of the site in the database. @@ -53,6 +55,13 @@ const ( ProfilesInverseTable = "profiles" // ProfilesColumn is the table column denoting the profiles relation/edge. ProfilesColumn = "site_profiles" + // EnrollmentTokensTable is the table that holds the enrollment_tokens relation/edge. + EnrollmentTokensTable = "enrollment_tokens" + // EnrollmentTokensInverseTable is the table name for the EnrollmentToken entity. + // It exists in this package in order to avoid circular dependency with the "enrollmenttoken" package. + EnrollmentTokensInverseTable = "enrollment_tokens" + // EnrollmentTokensColumn is the table column denoting the enrollment_tokens relation/edge. + EnrollmentTokensColumn = "site_enrollment_tokens" ) // Columns holds all SQL columns for site fields. @@ -168,6 +177,20 @@ func ByProfiles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newProfilesStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByEnrollmentTokensCount orders the results by enrollment_tokens count. +func ByEnrollmentTokensCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newEnrollmentTokensStep(), opts...) + } +} + +// ByEnrollmentTokens orders the results by enrollment_tokens terms. +func ByEnrollmentTokens(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newEnrollmentTokensStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newTenantStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -189,3 +212,10 @@ func newProfilesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, ProfilesTable, ProfilesColumn), ) } +func newEnrollmentTokensStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(EnrollmentTokensInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EnrollmentTokensTable, EnrollmentTokensColumn), + ) +} diff --git a/site/where.go b/site/where.go index 956db52..8dc2646 100644 --- a/site/where.go +++ b/site/where.go @@ -419,6 +419,29 @@ func HasProfilesWith(preds ...predicate.Profile) predicate.Site { }) } +// HasEnrollmentTokens applies the HasEdge predicate on the "enrollment_tokens" edge. +func HasEnrollmentTokens() predicate.Site { + return predicate.Site(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EnrollmentTokensTable, EnrollmentTokensColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasEnrollmentTokensWith applies the HasEdge predicate on the "enrollment_tokens" edge with a given conditions (other predicates). +func HasEnrollmentTokensWith(preds ...predicate.EnrollmentToken) predicate.Site { + return predicate.Site(func(s *sql.Selector) { + step := newEnrollmentTokensStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Site) predicate.Site { return predicate.Site(sql.AndPredicates(predicates...)) diff --git a/site_create.go b/site_create.go index 1c20f59..d526829 100644 --- a/site_create.go +++ b/site_create.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/open-uem/ent/agent" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/profile" "github.com/open-uem/ent/site" "github.com/open-uem/ent/tenant" @@ -144,6 +145,21 @@ func (sc *SiteCreate) AddProfiles(p ...*Profile) *SiteCreate { return sc.AddProfileIDs(ids...) } +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (sc *SiteCreate) AddEnrollmentTokenIDs(ids ...int) *SiteCreate { + sc.mutation.AddEnrollmentTokenIDs(ids...) + return sc +} + +// AddEnrollmentTokens adds the "enrollment_tokens" edges to the EnrollmentToken entity. +func (sc *SiteCreate) AddEnrollmentTokens(e ...*EnrollmentToken) *SiteCreate { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return sc.AddEnrollmentTokenIDs(ids...) +} + // Mutation returns the SiteMutation object of the builder. func (sc *SiteCreate) Mutation() *SiteMutation { return sc.mutation @@ -287,6 +303,22 @@ func (sc *SiteCreate) createSpec() (*Site, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := sc.mutation.EnrollmentTokensIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/site_query.go b/site_query.go index 4348ba6..8dcf033 100644 --- a/site_query.go +++ b/site_query.go @@ -13,6 +13,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/open-uem/ent/agent" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/predicate" "github.com/open-uem/ent/profile" "github.com/open-uem/ent/site" @@ -22,15 +23,16 @@ import ( // SiteQuery is the builder for querying Site entities. type SiteQuery struct { config - ctx *QueryContext - order []site.OrderOption - inters []Interceptor - predicates []predicate.Site - withTenant *TenantQuery - withAgents *AgentQuery - withProfiles *ProfileQuery - withFKs bool - modifiers []func(*sql.Selector) + ctx *QueryContext + order []site.OrderOption + inters []Interceptor + predicates []predicate.Site + withTenant *TenantQuery + withAgents *AgentQuery + withProfiles *ProfileQuery + withEnrollmentTokens *EnrollmentTokenQuery + withFKs bool + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -133,6 +135,28 @@ func (sq *SiteQuery) QueryProfiles() *ProfileQuery { return query } +// QueryEnrollmentTokens chains the current query on the "enrollment_tokens" edge. +func (sq *SiteQuery) QueryEnrollmentTokens() *EnrollmentTokenQuery { + query := (&EnrollmentTokenClient{config: sq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := sq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := sq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(site.Table, site.FieldID, selector), + sqlgraph.To(enrollmenttoken.Table, enrollmenttoken.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, site.EnrollmentTokensTable, site.EnrollmentTokensColumn), + ) + fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Site entity from the query. // Returns a *NotFoundError when no Site was found. func (sq *SiteQuery) First(ctx context.Context) (*Site, error) { @@ -320,14 +344,15 @@ func (sq *SiteQuery) Clone() *SiteQuery { return nil } return &SiteQuery{ - config: sq.config, - ctx: sq.ctx.Clone(), - order: append([]site.OrderOption{}, sq.order...), - inters: append([]Interceptor{}, sq.inters...), - predicates: append([]predicate.Site{}, sq.predicates...), - withTenant: sq.withTenant.Clone(), - withAgents: sq.withAgents.Clone(), - withProfiles: sq.withProfiles.Clone(), + config: sq.config, + ctx: sq.ctx.Clone(), + order: append([]site.OrderOption{}, sq.order...), + inters: append([]Interceptor{}, sq.inters...), + predicates: append([]predicate.Site{}, sq.predicates...), + withTenant: sq.withTenant.Clone(), + withAgents: sq.withAgents.Clone(), + withProfiles: sq.withProfiles.Clone(), + withEnrollmentTokens: sq.withEnrollmentTokens.Clone(), // clone intermediate query. sql: sq.sql.Clone(), path: sq.path, @@ -368,6 +393,17 @@ func (sq *SiteQuery) WithProfiles(opts ...func(*ProfileQuery)) *SiteQuery { return sq } +// WithEnrollmentTokens tells the query-builder to eager-load the nodes that are connected to +// the "enrollment_tokens" edge. The optional arguments are used to configure the query builder of the edge. +func (sq *SiteQuery) WithEnrollmentTokens(opts ...func(*EnrollmentTokenQuery)) *SiteQuery { + query := (&EnrollmentTokenClient{config: sq.config}).Query() + for _, opt := range opts { + opt(query) + } + sq.withEnrollmentTokens = query + return sq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -447,10 +483,11 @@ func (sq *SiteQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Site, e nodes = []*Site{} withFKs = sq.withFKs _spec = sq.querySpec() - loadedTypes = [3]bool{ + loadedTypes = [4]bool{ sq.withTenant != nil, sq.withAgents != nil, sq.withProfiles != nil, + sq.withEnrollmentTokens != nil, } ) if sq.withTenant != nil { @@ -500,6 +537,13 @@ func (sq *SiteQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Site, e return nil, err } } + if query := sq.withEnrollmentTokens; query != nil { + if err := sq.loadEnrollmentTokens(ctx, query, nodes, + func(n *Site) { n.Edges.EnrollmentTokens = []*EnrollmentToken{} }, + func(n *Site, e *EnrollmentToken) { n.Edges.EnrollmentTokens = append(n.Edges.EnrollmentTokens, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -627,6 +671,37 @@ func (sq *SiteQuery) loadProfiles(ctx context.Context, query *ProfileQuery, node } return nil } +func (sq *SiteQuery) loadEnrollmentTokens(ctx context.Context, query *EnrollmentTokenQuery, nodes []*Site, init func(*Site), assign func(*Site, *EnrollmentToken)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Site) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.EnrollmentToken(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(site.EnrollmentTokensColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.site_enrollment_tokens + if fk == nil { + return fmt.Errorf(`foreign-key "site_enrollment_tokens" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "site_enrollment_tokens" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (sq *SiteQuery) sqlCount(ctx context.Context) (int, error) { _spec := sq.querySpec() diff --git a/site_update.go b/site_update.go index 207279c..14c4fc5 100644 --- a/site_update.go +++ b/site_update.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/open-uem/ent/agent" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/predicate" "github.com/open-uem/ent/profile" "github.com/open-uem/ent/site" @@ -173,6 +174,21 @@ func (su *SiteUpdate) AddProfiles(p ...*Profile) *SiteUpdate { return su.AddProfileIDs(ids...) } +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (su *SiteUpdate) AddEnrollmentTokenIDs(ids ...int) *SiteUpdate { + su.mutation.AddEnrollmentTokenIDs(ids...) + return su +} + +// AddEnrollmentTokens adds the "enrollment_tokens" edges to the EnrollmentToken entity. +func (su *SiteUpdate) AddEnrollmentTokens(e ...*EnrollmentToken) *SiteUpdate { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return su.AddEnrollmentTokenIDs(ids...) +} + // Mutation returns the SiteMutation object of the builder. func (su *SiteUpdate) Mutation() *SiteMutation { return su.mutation @@ -226,6 +242,27 @@ func (su *SiteUpdate) RemoveProfiles(p ...*Profile) *SiteUpdate { return su.RemoveProfileIDs(ids...) } +// ClearEnrollmentTokens clears all "enrollment_tokens" edges to the EnrollmentToken entity. +func (su *SiteUpdate) ClearEnrollmentTokens() *SiteUpdate { + su.mutation.ClearEnrollmentTokens() + return su +} + +// RemoveEnrollmentTokenIDs removes the "enrollment_tokens" edge to EnrollmentToken entities by IDs. +func (su *SiteUpdate) RemoveEnrollmentTokenIDs(ids ...int) *SiteUpdate { + su.mutation.RemoveEnrollmentTokenIDs(ids...) + return su +} + +// RemoveEnrollmentTokens removes "enrollment_tokens" edges to EnrollmentToken entities. +func (su *SiteUpdate) RemoveEnrollmentTokens(e ...*EnrollmentToken) *SiteUpdate { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return su.RemoveEnrollmentTokenIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (su *SiteUpdate) Save(ctx context.Context) (int, error) { su.defaults() @@ -426,6 +463,51 @@ func (su *SiteUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if su.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.RemovedEnrollmentTokensIDs(); len(nodes) > 0 && !su.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := su.mutation.EnrollmentTokensIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(su.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -589,6 +671,21 @@ func (suo *SiteUpdateOne) AddProfiles(p ...*Profile) *SiteUpdateOne { return suo.AddProfileIDs(ids...) } +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (suo *SiteUpdateOne) AddEnrollmentTokenIDs(ids ...int) *SiteUpdateOne { + suo.mutation.AddEnrollmentTokenIDs(ids...) + return suo +} + +// AddEnrollmentTokens adds the "enrollment_tokens" edges to the EnrollmentToken entity. +func (suo *SiteUpdateOne) AddEnrollmentTokens(e ...*EnrollmentToken) *SiteUpdateOne { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return suo.AddEnrollmentTokenIDs(ids...) +} + // Mutation returns the SiteMutation object of the builder. func (suo *SiteUpdateOne) Mutation() *SiteMutation { return suo.mutation @@ -642,6 +739,27 @@ func (suo *SiteUpdateOne) RemoveProfiles(p ...*Profile) *SiteUpdateOne { return suo.RemoveProfileIDs(ids...) } +// ClearEnrollmentTokens clears all "enrollment_tokens" edges to the EnrollmentToken entity. +func (suo *SiteUpdateOne) ClearEnrollmentTokens() *SiteUpdateOne { + suo.mutation.ClearEnrollmentTokens() + return suo +} + +// RemoveEnrollmentTokenIDs removes the "enrollment_tokens" edge to EnrollmentToken entities by IDs. +func (suo *SiteUpdateOne) RemoveEnrollmentTokenIDs(ids ...int) *SiteUpdateOne { + suo.mutation.RemoveEnrollmentTokenIDs(ids...) + return suo +} + +// RemoveEnrollmentTokens removes "enrollment_tokens" edges to EnrollmentToken entities. +func (suo *SiteUpdateOne) RemoveEnrollmentTokens(e ...*EnrollmentToken) *SiteUpdateOne { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return suo.RemoveEnrollmentTokenIDs(ids...) +} + // Where appends a list predicates to the SiteUpdate builder. func (suo *SiteUpdateOne) Where(ps ...predicate.Site) *SiteUpdateOne { suo.mutation.Where(ps...) @@ -872,6 +990,51 @@ func (suo *SiteUpdateOne) sqlSave(ctx context.Context) (_node *Site, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if suo.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.RemovedEnrollmentTokensIDs(); len(nodes) > 0 && !suo.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := suo.mutation.EnrollmentTokensIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: site.EnrollmentTokensTable, + Columns: []string{site.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(suo.modifiers...) _node = &Site{config: suo.config} _spec.Assign = _node.assignValues diff --git a/tenant.go b/tenant.go index eb83589..9f5b2b5 100644 --- a/tenant.go +++ b/tenant.go @@ -23,6 +23,10 @@ type Tenant struct { Description string `json:"description,omitempty"` // IsDefault holds the value of the "is_default" field. IsDefault bool `json:"is_default,omitempty"` + // OIDC organization ID (e.g. Zitadel Org-ID) for automatic tenant mapping + OidcOrgID string `json:"oidc_org_id,omitempty"` + // Default role for users auto-assigned via OIDC + OidcDefaultRole tenant.OidcDefaultRole `json:"oidc_default_role,omitempty"` // Created holds the value of the "created" field. Created time.Time `json:"created,omitempty"` // Modified holds the value of the "modified" field. @@ -48,9 +52,13 @@ type TenantEdges struct { Rustdesk []*Rustdesk `json:"rustdesk,omitempty"` // Netbird holds the value of the netbird edge. Netbird *NetbirdSettings `json:"netbird,omitempty"` + // UserTenants holds the value of the user_tenants edge. + UserTenants []*UserTenant `json:"user_tenants,omitempty"` + // EnrollmentTokens holds the value of the enrollment_tokens edge. + EnrollmentTokens []*EnrollmentToken `json:"enrollment_tokens,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [6]bool + loadedTypes [8]bool } // SitesOrErr returns the Sites value or an error if the edge @@ -111,6 +119,24 @@ func (e TenantEdges) NetbirdOrErr() (*NetbirdSettings, error) { return nil, &NotLoadedError{edge: "netbird"} } +// UserTenantsOrErr returns the UserTenants value or an error if the edge +// was not loaded in eager-loading. +func (e TenantEdges) UserTenantsOrErr() ([]*UserTenant, error) { + if e.loadedTypes[6] { + return e.UserTenants, nil + } + return nil, &NotLoadedError{edge: "user_tenants"} +} + +// EnrollmentTokensOrErr returns the EnrollmentTokens value or an error if the edge +// was not loaded in eager-loading. +func (e TenantEdges) EnrollmentTokensOrErr() ([]*EnrollmentToken, error) { + if e.loadedTypes[7] { + return e.EnrollmentTokens, nil + } + return nil, &NotLoadedError{edge: "enrollment_tokens"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Tenant) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -120,7 +146,7 @@ func (*Tenant) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case tenant.FieldID: values[i] = new(sql.NullInt64) - case tenant.FieldDescription: + case tenant.FieldDescription, tenant.FieldOidcOrgID, tenant.FieldOidcDefaultRole: values[i] = new(sql.NullString) case tenant.FieldCreated, tenant.FieldModified: values[i] = new(sql.NullTime) @@ -159,6 +185,18 @@ func (t *Tenant) assignValues(columns []string, values []any) error { } else if value.Valid { t.IsDefault = value.Bool } + case tenant.FieldOidcOrgID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field oidc_org_id", values[i]) + } else if value.Valid { + t.OidcOrgID = value.String + } + case tenant.FieldOidcDefaultRole: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field oidc_default_role", values[i]) + } else if value.Valid { + t.OidcDefaultRole = tenant.OidcDefaultRole(value.String) + } case tenant.FieldCreated: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created", values[i]) @@ -221,6 +259,16 @@ func (t *Tenant) QueryNetbird() *NetbirdSettingsQuery { return NewTenantClient(t.config).QueryNetbird(t) } +// QueryUserTenants queries the "user_tenants" edge of the Tenant entity. +func (t *Tenant) QueryUserTenants() *UserTenantQuery { + return NewTenantClient(t.config).QueryUserTenants(t) +} + +// QueryEnrollmentTokens queries the "enrollment_tokens" edge of the Tenant entity. +func (t *Tenant) QueryEnrollmentTokens() *EnrollmentTokenQuery { + return NewTenantClient(t.config).QueryEnrollmentTokens(t) +} + // Update returns a builder for updating this Tenant. // Note that you need to call Tenant.Unwrap() before calling this method if this Tenant // was returned from a transaction, and the transaction was committed or rolled back. @@ -250,6 +298,12 @@ func (t *Tenant) String() string { builder.WriteString("is_default=") builder.WriteString(fmt.Sprintf("%v", t.IsDefault)) builder.WriteString(", ") + builder.WriteString("oidc_org_id=") + builder.WriteString(t.OidcOrgID) + builder.WriteString(", ") + builder.WriteString("oidc_default_role=") + builder.WriteString(fmt.Sprintf("%v", t.OidcDefaultRole)) + builder.WriteString(", ") builder.WriteString("created=") builder.WriteString(t.Created.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/tenant/tenant.go b/tenant/tenant.go index 1ab594d..b0cbd0f 100644 --- a/tenant/tenant.go +++ b/tenant/tenant.go @@ -3,6 +3,7 @@ package tenant import ( + "fmt" "time" "entgo.io/ent/dialect/sql" @@ -18,6 +19,10 @@ const ( FieldDescription = "description" // FieldIsDefault holds the string denoting the is_default field in the database. FieldIsDefault = "is_default" + // FieldOidcOrgID holds the string denoting the oidc_org_id field in the database. + FieldOidcOrgID = "oidc_org_id" + // FieldOidcDefaultRole holds the string denoting the oidc_default_role field in the database. + FieldOidcDefaultRole = "oidc_default_role" // FieldCreated holds the string denoting the created field in the database. FieldCreated = "created" // FieldModified holds the string denoting the modified field in the database. @@ -34,6 +39,10 @@ const ( EdgeRustdesk = "rustdesk" // EdgeNetbird holds the string denoting the netbird edge name in mutations. EdgeNetbird = "netbird" + // EdgeUserTenants holds the string denoting the user_tenants edge name in mutations. + EdgeUserTenants = "user_tenants" + // EdgeEnrollmentTokens holds the string denoting the enrollment_tokens edge name in mutations. + EdgeEnrollmentTokens = "enrollment_tokens" // Table holds the table name of the tenant in the database. Table = "tenants" // SitesTable is the table that holds the sites relation/edge. @@ -76,6 +85,20 @@ const ( NetbirdInverseTable = "netbird_settings" // NetbirdColumn is the table column denoting the netbird relation/edge. NetbirdColumn = "tenant_netbird" + // UserTenantsTable is the table that holds the user_tenants relation/edge. + UserTenantsTable = "user_tenants" + // UserTenantsInverseTable is the table name for the UserTenant entity. + // It exists in this package in order to avoid circular dependency with the "usertenant" package. + UserTenantsInverseTable = "user_tenants" + // UserTenantsColumn is the table column denoting the user_tenants relation/edge. + UserTenantsColumn = "tenant_id" + // EnrollmentTokensTable is the table that holds the enrollment_tokens relation/edge. + EnrollmentTokensTable = "enrollment_tokens" + // EnrollmentTokensInverseTable is the table name for the EnrollmentToken entity. + // It exists in this package in order to avoid circular dependency with the "enrollmenttoken" package. + EnrollmentTokensInverseTable = "enrollment_tokens" + // EnrollmentTokensColumn is the table column denoting the enrollment_tokens relation/edge. + EnrollmentTokensColumn = "tenant_enrollment_tokens" ) // Columns holds all SQL columns for tenant fields. @@ -83,6 +106,8 @@ var Columns = []string{ FieldID, FieldDescription, FieldIsDefault, + FieldOidcOrgID, + FieldOidcDefaultRole, FieldCreated, FieldModified, } @@ -123,6 +148,33 @@ var ( UpdateDefaultModified func() time.Time ) +// OidcDefaultRole defines the type for the "oidc_default_role" enum field. +type OidcDefaultRole string + +// OidcDefaultRoleUser is the default value of the OidcDefaultRole enum. +const DefaultOidcDefaultRole = OidcDefaultRoleUser + +// OidcDefaultRole values. +const ( + OidcDefaultRoleAdmin OidcDefaultRole = "admin" + OidcDefaultRoleOperator OidcDefaultRole = "operator" + OidcDefaultRoleUser OidcDefaultRole = "user" +) + +func (odr OidcDefaultRole) String() string { + return string(odr) +} + +// OidcDefaultRoleValidator is a validator for the "oidc_default_role" field enum values. It is called by the builders before save. +func OidcDefaultRoleValidator(odr OidcDefaultRole) error { + switch odr { + case OidcDefaultRoleAdmin, OidcDefaultRoleOperator, OidcDefaultRoleUser: + return nil + default: + return fmt.Errorf("tenant: invalid enum value for oidc_default_role field: %q", odr) + } +} + // OrderOption defines the ordering options for the Tenant queries. type OrderOption func(*sql.Selector) @@ -141,6 +193,16 @@ func ByIsDefault(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldIsDefault, opts...).ToFunc() } +// ByOidcOrgID orders the results by the oidc_org_id field. +func ByOidcOrgID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOidcOrgID, opts...).ToFunc() +} + +// ByOidcDefaultRole orders the results by the oidc_default_role field. +func ByOidcDefaultRole(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOidcDefaultRole, opts...).ToFunc() +} + // ByCreated orders the results by the created field. func ByCreated(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreated, opts...).ToFunc() @@ -220,6 +282,34 @@ func ByNetbirdField(field string, opts ...sql.OrderTermOption) OrderOption { sqlgraph.OrderByNeighborTerms(s, newNetbirdStep(), sql.OrderByField(field, opts...)) } } + +// ByUserTenantsCount orders the results by user_tenants count. +func ByUserTenantsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserTenantsStep(), opts...) + } +} + +// ByUserTenants orders the results by user_tenants terms. +func ByUserTenants(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserTenantsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByEnrollmentTokensCount orders the results by enrollment_tokens count. +func ByEnrollmentTokensCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newEnrollmentTokensStep(), opts...) + } +} + +// ByEnrollmentTokens orders the results by enrollment_tokens terms. +func ByEnrollmentTokens(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newEnrollmentTokensStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newSitesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -262,3 +352,17 @@ func newNetbirdStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2O, false, NetbirdTable, NetbirdColumn), ) } +func newUserTenantsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserTenantsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserTenantsTable, UserTenantsColumn), + ) +} +func newEnrollmentTokensStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(EnrollmentTokensInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EnrollmentTokensTable, EnrollmentTokensColumn), + ) +} diff --git a/tenant/where.go b/tenant/where.go index 8e3f607..f71282b 100644 --- a/tenant/where.go +++ b/tenant/where.go @@ -65,6 +65,11 @@ func IsDefault(v bool) predicate.Tenant { return predicate.Tenant(sql.FieldEQ(FieldIsDefault, v)) } +// OidcOrgID applies equality check predicate on the "oidc_org_id" field. It's identical to OidcOrgIDEQ. +func OidcOrgID(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldEQ(FieldOidcOrgID, v)) +} + // Created applies equality check predicate on the "created" field. It's identical to CreatedEQ. func Created(v time.Time) predicate.Tenant { return predicate.Tenant(sql.FieldEQ(FieldCreated, v)) @@ -170,6 +175,111 @@ func IsDefaultNotNil() predicate.Tenant { return predicate.Tenant(sql.FieldNotNull(FieldIsDefault)) } +// OidcOrgIDEQ applies the EQ predicate on the "oidc_org_id" field. +func OidcOrgIDEQ(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldEQ(FieldOidcOrgID, v)) +} + +// OidcOrgIDNEQ applies the NEQ predicate on the "oidc_org_id" field. +func OidcOrgIDNEQ(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldNEQ(FieldOidcOrgID, v)) +} + +// OidcOrgIDIn applies the In predicate on the "oidc_org_id" field. +func OidcOrgIDIn(vs ...string) predicate.Tenant { + return predicate.Tenant(sql.FieldIn(FieldOidcOrgID, vs...)) +} + +// OidcOrgIDNotIn applies the NotIn predicate on the "oidc_org_id" field. +func OidcOrgIDNotIn(vs ...string) predicate.Tenant { + return predicate.Tenant(sql.FieldNotIn(FieldOidcOrgID, vs...)) +} + +// OidcOrgIDGT applies the GT predicate on the "oidc_org_id" field. +func OidcOrgIDGT(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldGT(FieldOidcOrgID, v)) +} + +// OidcOrgIDGTE applies the GTE predicate on the "oidc_org_id" field. +func OidcOrgIDGTE(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldGTE(FieldOidcOrgID, v)) +} + +// OidcOrgIDLT applies the LT predicate on the "oidc_org_id" field. +func OidcOrgIDLT(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldLT(FieldOidcOrgID, v)) +} + +// OidcOrgIDLTE applies the LTE predicate on the "oidc_org_id" field. +func OidcOrgIDLTE(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldLTE(FieldOidcOrgID, v)) +} + +// OidcOrgIDContains applies the Contains predicate on the "oidc_org_id" field. +func OidcOrgIDContains(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldContains(FieldOidcOrgID, v)) +} + +// OidcOrgIDHasPrefix applies the HasPrefix predicate on the "oidc_org_id" field. +func OidcOrgIDHasPrefix(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldHasPrefix(FieldOidcOrgID, v)) +} + +// OidcOrgIDHasSuffix applies the HasSuffix predicate on the "oidc_org_id" field. +func OidcOrgIDHasSuffix(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldHasSuffix(FieldOidcOrgID, v)) +} + +// OidcOrgIDIsNil applies the IsNil predicate on the "oidc_org_id" field. +func OidcOrgIDIsNil() predicate.Tenant { + return predicate.Tenant(sql.FieldIsNull(FieldOidcOrgID)) +} + +// OidcOrgIDNotNil applies the NotNil predicate on the "oidc_org_id" field. +func OidcOrgIDNotNil() predicate.Tenant { + return predicate.Tenant(sql.FieldNotNull(FieldOidcOrgID)) +} + +// OidcOrgIDEqualFold applies the EqualFold predicate on the "oidc_org_id" field. +func OidcOrgIDEqualFold(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldEqualFold(FieldOidcOrgID, v)) +} + +// OidcOrgIDContainsFold applies the ContainsFold predicate on the "oidc_org_id" field. +func OidcOrgIDContainsFold(v string) predicate.Tenant { + return predicate.Tenant(sql.FieldContainsFold(FieldOidcOrgID, v)) +} + +// OidcDefaultRoleEQ applies the EQ predicate on the "oidc_default_role" field. +func OidcDefaultRoleEQ(v OidcDefaultRole) predicate.Tenant { + return predicate.Tenant(sql.FieldEQ(FieldOidcDefaultRole, v)) +} + +// OidcDefaultRoleNEQ applies the NEQ predicate on the "oidc_default_role" field. +func OidcDefaultRoleNEQ(v OidcDefaultRole) predicate.Tenant { + return predicate.Tenant(sql.FieldNEQ(FieldOidcDefaultRole, v)) +} + +// OidcDefaultRoleIn applies the In predicate on the "oidc_default_role" field. +func OidcDefaultRoleIn(vs ...OidcDefaultRole) predicate.Tenant { + return predicate.Tenant(sql.FieldIn(FieldOidcDefaultRole, vs...)) +} + +// OidcDefaultRoleNotIn applies the NotIn predicate on the "oidc_default_role" field. +func OidcDefaultRoleNotIn(vs ...OidcDefaultRole) predicate.Tenant { + return predicate.Tenant(sql.FieldNotIn(FieldOidcDefaultRole, vs...)) +} + +// OidcDefaultRoleIsNil applies the IsNil predicate on the "oidc_default_role" field. +func OidcDefaultRoleIsNil() predicate.Tenant { + return predicate.Tenant(sql.FieldIsNull(FieldOidcDefaultRole)) +} + +// OidcDefaultRoleNotNil applies the NotNil predicate on the "oidc_default_role" field. +func OidcDefaultRoleNotNil() predicate.Tenant { + return predicate.Tenant(sql.FieldNotNull(FieldOidcDefaultRole)) +} + // CreatedEQ applies the EQ predicate on the "created" field. func CreatedEQ(v time.Time) predicate.Tenant { return predicate.Tenant(sql.FieldEQ(FieldCreated, v)) @@ -408,6 +518,52 @@ func HasNetbirdWith(preds ...predicate.NetbirdSettings) predicate.Tenant { }) } +// HasUserTenants applies the HasEdge predicate on the "user_tenants" edge. +func HasUserTenants() predicate.Tenant { + return predicate.Tenant(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserTenantsTable, UserTenantsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserTenantsWith applies the HasEdge predicate on the "user_tenants" edge with a given conditions (other predicates). +func HasUserTenantsWith(preds ...predicate.UserTenant) predicate.Tenant { + return predicate.Tenant(func(s *sql.Selector) { + step := newUserTenantsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasEnrollmentTokens applies the HasEdge predicate on the "enrollment_tokens" edge. +func HasEnrollmentTokens() predicate.Tenant { + return predicate.Tenant(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, EnrollmentTokensTable, EnrollmentTokensColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasEnrollmentTokensWith applies the HasEdge predicate on the "enrollment_tokens" edge with a given conditions (other predicates). +func HasEnrollmentTokensWith(preds ...predicate.EnrollmentToken) predicate.Tenant { + return predicate.Tenant(func(s *sql.Selector) { + step := newEnrollmentTokensStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Tenant) predicate.Tenant { return predicate.Tenant(sql.AndPredicates(predicates...)) diff --git a/tenant_create.go b/tenant_create.go index a54408d..28ac16a 100644 --- a/tenant_create.go +++ b/tenant_create.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/netbirdsettings" "github.com/open-uem/ent/orgmetadata" "github.com/open-uem/ent/rustdesk" @@ -18,6 +19,7 @@ import ( "github.com/open-uem/ent/site" "github.com/open-uem/ent/tag" "github.com/open-uem/ent/tenant" + "github.com/open-uem/ent/usertenant" ) // TenantCreate is the builder for creating a Tenant entity. @@ -56,6 +58,34 @@ func (tc *TenantCreate) SetNillableIsDefault(b *bool) *TenantCreate { return tc } +// SetOidcOrgID sets the "oidc_org_id" field. +func (tc *TenantCreate) SetOidcOrgID(s string) *TenantCreate { + tc.mutation.SetOidcOrgID(s) + return tc +} + +// SetNillableOidcOrgID sets the "oidc_org_id" field if the given value is not nil. +func (tc *TenantCreate) SetNillableOidcOrgID(s *string) *TenantCreate { + if s != nil { + tc.SetOidcOrgID(*s) + } + return tc +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (tc *TenantCreate) SetOidcDefaultRole(tdr tenant.OidcDefaultRole) *TenantCreate { + tc.mutation.SetOidcDefaultRole(tdr) + return tc +} + +// SetNillableOidcDefaultRole sets the "oidc_default_role" field if the given value is not nil. +func (tc *TenantCreate) SetNillableOidcDefaultRole(tdr *tenant.OidcDefaultRole) *TenantCreate { + if tdr != nil { + tc.SetOidcDefaultRole(*tdr) + } + return tc +} + // SetCreated sets the "created" field. func (tc *TenantCreate) SetCreated(t time.Time) *TenantCreate { tc.mutation.SetCreated(t) @@ -182,6 +212,36 @@ func (tc *TenantCreate) SetNetbird(n *NetbirdSettings) *TenantCreate { return tc.SetNetbirdID(n.ID) } +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by IDs. +func (tc *TenantCreate) AddUserTenantIDs(ids ...int) *TenantCreate { + tc.mutation.AddUserTenantIDs(ids...) + return tc +} + +// AddUserTenants adds the "user_tenants" edges to the UserTenant entity. +func (tc *TenantCreate) AddUserTenants(u ...*UserTenant) *TenantCreate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return tc.AddUserTenantIDs(ids...) +} + +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (tc *TenantCreate) AddEnrollmentTokenIDs(ids ...int) *TenantCreate { + tc.mutation.AddEnrollmentTokenIDs(ids...) + return tc +} + +// AddEnrollmentTokens adds the "enrollment_tokens" edges to the EnrollmentToken entity. +func (tc *TenantCreate) AddEnrollmentTokens(e ...*EnrollmentToken) *TenantCreate { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return tc.AddEnrollmentTokenIDs(ids...) +} + // Mutation returns the TenantMutation object of the builder. func (tc *TenantCreate) Mutation() *TenantMutation { return tc.mutation @@ -217,6 +277,10 @@ func (tc *TenantCreate) ExecX(ctx context.Context) { // defaults sets the default values of the builder before save. func (tc *TenantCreate) defaults() { + if _, ok := tc.mutation.OidcDefaultRole(); !ok { + v := tenant.DefaultOidcDefaultRole + tc.mutation.SetOidcDefaultRole(v) + } if _, ok := tc.mutation.Created(); !ok { v := tenant.DefaultCreated() tc.mutation.SetCreated(v) @@ -229,6 +293,11 @@ func (tc *TenantCreate) defaults() { // check runs all checks and user-defined validators on the builder. func (tc *TenantCreate) check() error { + if v, ok := tc.mutation.OidcDefaultRole(); ok { + if err := tenant.OidcDefaultRoleValidator(v); err != nil { + return &ValidationError{Name: "oidc_default_role", err: fmt.Errorf(`ent: validator failed for field "Tenant.oidc_default_role": %w`, err)} + } + } return nil } @@ -264,6 +333,14 @@ func (tc *TenantCreate) createSpec() (*Tenant, *sqlgraph.CreateSpec) { _spec.SetField(tenant.FieldIsDefault, field.TypeBool, value) _node.IsDefault = value } + if value, ok := tc.mutation.OidcOrgID(); ok { + _spec.SetField(tenant.FieldOidcOrgID, field.TypeString, value) + _node.OidcOrgID = value + } + if value, ok := tc.mutation.OidcDefaultRole(); ok { + _spec.SetField(tenant.FieldOidcDefaultRole, field.TypeEnum, value) + _node.OidcDefaultRole = value + } if value, ok := tc.mutation.Created(); ok { _spec.SetField(tenant.FieldCreated, field.TypeTime, value) _node.Created = value @@ -369,6 +446,38 @@ func (tc *TenantCreate) createSpec() (*Tenant, *sqlgraph.CreateSpec) { _node.tenant_netbird = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } + if nodes := tc.mutation.UserTenantsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := tc.mutation.EnrollmentTokensIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } @@ -457,6 +566,42 @@ func (u *TenantUpsert) ClearIsDefault() *TenantUpsert { return u } +// SetOidcOrgID sets the "oidc_org_id" field. +func (u *TenantUpsert) SetOidcOrgID(v string) *TenantUpsert { + u.Set(tenant.FieldOidcOrgID, v) + return u +} + +// UpdateOidcOrgID sets the "oidc_org_id" field to the value that was provided on create. +func (u *TenantUpsert) UpdateOidcOrgID() *TenantUpsert { + u.SetExcluded(tenant.FieldOidcOrgID) + return u +} + +// ClearOidcOrgID clears the value of the "oidc_org_id" field. +func (u *TenantUpsert) ClearOidcOrgID() *TenantUpsert { + u.SetNull(tenant.FieldOidcOrgID) + return u +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (u *TenantUpsert) SetOidcDefaultRole(v tenant.OidcDefaultRole) *TenantUpsert { + u.Set(tenant.FieldOidcDefaultRole, v) + return u +} + +// UpdateOidcDefaultRole sets the "oidc_default_role" field to the value that was provided on create. +func (u *TenantUpsert) UpdateOidcDefaultRole() *TenantUpsert { + u.SetExcluded(tenant.FieldOidcDefaultRole) + return u +} + +// ClearOidcDefaultRole clears the value of the "oidc_default_role" field. +func (u *TenantUpsert) ClearOidcDefaultRole() *TenantUpsert { + u.SetNull(tenant.FieldOidcDefaultRole) + return u +} + // SetCreated sets the "created" field. func (u *TenantUpsert) SetCreated(v time.Time) *TenantUpsert { u.Set(tenant.FieldCreated, v) @@ -575,6 +720,48 @@ func (u *TenantUpsertOne) ClearIsDefault() *TenantUpsertOne { }) } +// SetOidcOrgID sets the "oidc_org_id" field. +func (u *TenantUpsertOne) SetOidcOrgID(v string) *TenantUpsertOne { + return u.Update(func(s *TenantUpsert) { + s.SetOidcOrgID(v) + }) +} + +// UpdateOidcOrgID sets the "oidc_org_id" field to the value that was provided on create. +func (u *TenantUpsertOne) UpdateOidcOrgID() *TenantUpsertOne { + return u.Update(func(s *TenantUpsert) { + s.UpdateOidcOrgID() + }) +} + +// ClearOidcOrgID clears the value of the "oidc_org_id" field. +func (u *TenantUpsertOne) ClearOidcOrgID() *TenantUpsertOne { + return u.Update(func(s *TenantUpsert) { + s.ClearOidcOrgID() + }) +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (u *TenantUpsertOne) SetOidcDefaultRole(v tenant.OidcDefaultRole) *TenantUpsertOne { + return u.Update(func(s *TenantUpsert) { + s.SetOidcDefaultRole(v) + }) +} + +// UpdateOidcDefaultRole sets the "oidc_default_role" field to the value that was provided on create. +func (u *TenantUpsertOne) UpdateOidcDefaultRole() *TenantUpsertOne { + return u.Update(func(s *TenantUpsert) { + s.UpdateOidcDefaultRole() + }) +} + +// ClearOidcDefaultRole clears the value of the "oidc_default_role" field. +func (u *TenantUpsertOne) ClearOidcDefaultRole() *TenantUpsertOne { + return u.Update(func(s *TenantUpsert) { + s.ClearOidcDefaultRole() + }) +} + // SetCreated sets the "created" field. func (u *TenantUpsertOne) SetCreated(v time.Time) *TenantUpsertOne { return u.Update(func(s *TenantUpsert) { @@ -863,6 +1050,48 @@ func (u *TenantUpsertBulk) ClearIsDefault() *TenantUpsertBulk { }) } +// SetOidcOrgID sets the "oidc_org_id" field. +func (u *TenantUpsertBulk) SetOidcOrgID(v string) *TenantUpsertBulk { + return u.Update(func(s *TenantUpsert) { + s.SetOidcOrgID(v) + }) +} + +// UpdateOidcOrgID sets the "oidc_org_id" field to the value that was provided on create. +func (u *TenantUpsertBulk) UpdateOidcOrgID() *TenantUpsertBulk { + return u.Update(func(s *TenantUpsert) { + s.UpdateOidcOrgID() + }) +} + +// ClearOidcOrgID clears the value of the "oidc_org_id" field. +func (u *TenantUpsertBulk) ClearOidcOrgID() *TenantUpsertBulk { + return u.Update(func(s *TenantUpsert) { + s.ClearOidcOrgID() + }) +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (u *TenantUpsertBulk) SetOidcDefaultRole(v tenant.OidcDefaultRole) *TenantUpsertBulk { + return u.Update(func(s *TenantUpsert) { + s.SetOidcDefaultRole(v) + }) +} + +// UpdateOidcDefaultRole sets the "oidc_default_role" field to the value that was provided on create. +func (u *TenantUpsertBulk) UpdateOidcDefaultRole() *TenantUpsertBulk { + return u.Update(func(s *TenantUpsert) { + s.UpdateOidcDefaultRole() + }) +} + +// ClearOidcDefaultRole clears the value of the "oidc_default_role" field. +func (u *TenantUpsertBulk) ClearOidcDefaultRole() *TenantUpsertBulk { + return u.Update(func(s *TenantUpsert) { + s.ClearOidcDefaultRole() + }) +} + // SetCreated sets the "created" field. func (u *TenantUpsertBulk) SetCreated(v time.Time) *TenantUpsertBulk { return u.Update(func(s *TenantUpsert) { diff --git a/tenant_query.go b/tenant_query.go index 35b9596..b2e2219 100644 --- a/tenant_query.go +++ b/tenant_query.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/netbirdsettings" "github.com/open-uem/ent/orgmetadata" "github.com/open-uem/ent/predicate" @@ -20,23 +21,26 @@ import ( "github.com/open-uem/ent/site" "github.com/open-uem/ent/tag" "github.com/open-uem/ent/tenant" + "github.com/open-uem/ent/usertenant" ) // TenantQuery is the builder for querying Tenant entities. type TenantQuery struct { config - ctx *QueryContext - order []tenant.OrderOption - inters []Interceptor - predicates []predicate.Tenant - withSites *SiteQuery - withSettings *SettingsQuery - withTags *TagQuery - withMetadata *OrgMetadataQuery - withRustdesk *RustdeskQuery - withNetbird *NetbirdSettingsQuery - withFKs bool - modifiers []func(*sql.Selector) + ctx *QueryContext + order []tenant.OrderOption + inters []Interceptor + predicates []predicate.Tenant + withSites *SiteQuery + withSettings *SettingsQuery + withTags *TagQuery + withMetadata *OrgMetadataQuery + withRustdesk *RustdeskQuery + withNetbird *NetbirdSettingsQuery + withUserTenants *UserTenantQuery + withEnrollmentTokens *EnrollmentTokenQuery + withFKs bool + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -205,6 +209,50 @@ func (tq *TenantQuery) QueryNetbird() *NetbirdSettingsQuery { return query } +// QueryUserTenants chains the current query on the "user_tenants" edge. +func (tq *TenantQuery) QueryUserTenants() *UserTenantQuery { + query := (&UserTenantClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(tenant.Table, tenant.FieldID, selector), + sqlgraph.To(usertenant.Table, usertenant.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, tenant.UserTenantsTable, tenant.UserTenantsColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryEnrollmentTokens chains the current query on the "enrollment_tokens" edge. +func (tq *TenantQuery) QueryEnrollmentTokens() *EnrollmentTokenQuery { + query := (&EnrollmentTokenClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(tenant.Table, tenant.FieldID, selector), + sqlgraph.To(enrollmenttoken.Table, enrollmenttoken.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, tenant.EnrollmentTokensTable, tenant.EnrollmentTokensColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Tenant entity from the query. // Returns a *NotFoundError when no Tenant was found. func (tq *TenantQuery) First(ctx context.Context) (*Tenant, error) { @@ -392,17 +440,19 @@ func (tq *TenantQuery) Clone() *TenantQuery { return nil } return &TenantQuery{ - config: tq.config, - ctx: tq.ctx.Clone(), - order: append([]tenant.OrderOption{}, tq.order...), - inters: append([]Interceptor{}, tq.inters...), - predicates: append([]predicate.Tenant{}, tq.predicates...), - withSites: tq.withSites.Clone(), - withSettings: tq.withSettings.Clone(), - withTags: tq.withTags.Clone(), - withMetadata: tq.withMetadata.Clone(), - withRustdesk: tq.withRustdesk.Clone(), - withNetbird: tq.withNetbird.Clone(), + config: tq.config, + ctx: tq.ctx.Clone(), + order: append([]tenant.OrderOption{}, tq.order...), + inters: append([]Interceptor{}, tq.inters...), + predicates: append([]predicate.Tenant{}, tq.predicates...), + withSites: tq.withSites.Clone(), + withSettings: tq.withSettings.Clone(), + withTags: tq.withTags.Clone(), + withMetadata: tq.withMetadata.Clone(), + withRustdesk: tq.withRustdesk.Clone(), + withNetbird: tq.withNetbird.Clone(), + withUserTenants: tq.withUserTenants.Clone(), + withEnrollmentTokens: tq.withEnrollmentTokens.Clone(), // clone intermediate query. sql: tq.sql.Clone(), path: tq.path, @@ -476,6 +526,28 @@ func (tq *TenantQuery) WithNetbird(opts ...func(*NetbirdSettingsQuery)) *TenantQ return tq } +// WithUserTenants tells the query-builder to eager-load the nodes that are connected to +// the "user_tenants" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TenantQuery) WithUserTenants(opts ...func(*UserTenantQuery)) *TenantQuery { + query := (&UserTenantClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withUserTenants = query + return tq +} + +// WithEnrollmentTokens tells the query-builder to eager-load the nodes that are connected to +// the "enrollment_tokens" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TenantQuery) WithEnrollmentTokens(opts ...func(*EnrollmentTokenQuery)) *TenantQuery { + query := (&EnrollmentTokenClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withEnrollmentTokens = query + return tq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -555,13 +627,15 @@ func (tq *TenantQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tenan nodes = []*Tenant{} withFKs = tq.withFKs _spec = tq.querySpec() - loadedTypes = [6]bool{ + loadedTypes = [8]bool{ tq.withSites != nil, tq.withSettings != nil, tq.withTags != nil, tq.withMetadata != nil, tq.withRustdesk != nil, tq.withNetbird != nil, + tq.withUserTenants != nil, + tq.withEnrollmentTokens != nil, } ) if tq.withNetbird != nil { @@ -631,6 +705,20 @@ func (tq *TenantQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tenan return nil, err } } + if query := tq.withUserTenants; query != nil { + if err := tq.loadUserTenants(ctx, query, nodes, + func(n *Tenant) { n.Edges.UserTenants = []*UserTenant{} }, + func(n *Tenant, e *UserTenant) { n.Edges.UserTenants = append(n.Edges.UserTenants, e) }); err != nil { + return nil, err + } + } + if query := tq.withEnrollmentTokens; query != nil { + if err := tq.loadEnrollmentTokens(ctx, query, nodes, + func(n *Tenant) { n.Edges.EnrollmentTokens = []*EnrollmentToken{} }, + func(n *Tenant, e *EnrollmentToken) { n.Edges.EnrollmentTokens = append(n.Edges.EnrollmentTokens, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -848,6 +936,67 @@ func (tq *TenantQuery) loadNetbird(ctx context.Context, query *NetbirdSettingsQu } return nil } +func (tq *TenantQuery) loadUserTenants(ctx context.Context, query *UserTenantQuery, nodes []*Tenant, init func(*Tenant), assign func(*Tenant, *UserTenant)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Tenant) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(usertenant.FieldTenantID) + } + query.Where(predicate.UserTenant(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(tenant.UserTenantsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.TenantID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "tenant_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (tq *TenantQuery) loadEnrollmentTokens(ctx context.Context, query *EnrollmentTokenQuery, nodes []*Tenant, init func(*Tenant), assign func(*Tenant, *EnrollmentToken)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Tenant) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.EnrollmentToken(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(tenant.EnrollmentTokensColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.tenant_enrollment_tokens + if fk == nil { + return fmt.Errorf(`foreign-key "tenant_enrollment_tokens" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "tenant_enrollment_tokens" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} func (tq *TenantQuery) sqlCount(ctx context.Context) (int, error) { _spec := tq.querySpec() diff --git a/tenant_update.go b/tenant_update.go index 44c7c73..479cbf9 100644 --- a/tenant_update.go +++ b/tenant_update.go @@ -11,6 +11,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "github.com/open-uem/ent/enrollmenttoken" "github.com/open-uem/ent/netbirdsettings" "github.com/open-uem/ent/orgmetadata" "github.com/open-uem/ent/predicate" @@ -19,6 +20,7 @@ import ( "github.com/open-uem/ent/site" "github.com/open-uem/ent/tag" "github.com/open-uem/ent/tenant" + "github.com/open-uem/ent/usertenant" ) // TenantUpdate is the builder for updating Tenant entities. @@ -75,6 +77,46 @@ func (tu *TenantUpdate) ClearIsDefault() *TenantUpdate { return tu } +// SetOidcOrgID sets the "oidc_org_id" field. +func (tu *TenantUpdate) SetOidcOrgID(s string) *TenantUpdate { + tu.mutation.SetOidcOrgID(s) + return tu +} + +// SetNillableOidcOrgID sets the "oidc_org_id" field if the given value is not nil. +func (tu *TenantUpdate) SetNillableOidcOrgID(s *string) *TenantUpdate { + if s != nil { + tu.SetOidcOrgID(*s) + } + return tu +} + +// ClearOidcOrgID clears the value of the "oidc_org_id" field. +func (tu *TenantUpdate) ClearOidcOrgID() *TenantUpdate { + tu.mutation.ClearOidcOrgID() + return tu +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (tu *TenantUpdate) SetOidcDefaultRole(tdr tenant.OidcDefaultRole) *TenantUpdate { + tu.mutation.SetOidcDefaultRole(tdr) + return tu +} + +// SetNillableOidcDefaultRole sets the "oidc_default_role" field if the given value is not nil. +func (tu *TenantUpdate) SetNillableOidcDefaultRole(tdr *tenant.OidcDefaultRole) *TenantUpdate { + if tdr != nil { + tu.SetOidcDefaultRole(*tdr) + } + return tu +} + +// ClearOidcDefaultRole clears the value of the "oidc_default_role" field. +func (tu *TenantUpdate) ClearOidcDefaultRole() *TenantUpdate { + tu.mutation.ClearOidcDefaultRole() + return tu +} + // SetCreated sets the "created" field. func (tu *TenantUpdate) SetCreated(t time.Time) *TenantUpdate { tu.mutation.SetCreated(t) @@ -205,6 +247,36 @@ func (tu *TenantUpdate) SetNetbird(n *NetbirdSettings) *TenantUpdate { return tu.SetNetbirdID(n.ID) } +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by IDs. +func (tu *TenantUpdate) AddUserTenantIDs(ids ...int) *TenantUpdate { + tu.mutation.AddUserTenantIDs(ids...) + return tu +} + +// AddUserTenants adds the "user_tenants" edges to the UserTenant entity. +func (tu *TenantUpdate) AddUserTenants(u ...*UserTenant) *TenantUpdate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return tu.AddUserTenantIDs(ids...) +} + +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (tu *TenantUpdate) AddEnrollmentTokenIDs(ids ...int) *TenantUpdate { + tu.mutation.AddEnrollmentTokenIDs(ids...) + return tu +} + +// AddEnrollmentTokens adds the "enrollment_tokens" edges to the EnrollmentToken entity. +func (tu *TenantUpdate) AddEnrollmentTokens(e ...*EnrollmentToken) *TenantUpdate { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return tu.AddEnrollmentTokenIDs(ids...) +} + // Mutation returns the TenantMutation object of the builder. func (tu *TenantUpdate) Mutation() *TenantMutation { return tu.mutation @@ -306,6 +378,48 @@ func (tu *TenantUpdate) ClearNetbird() *TenantUpdate { return tu } +// ClearUserTenants clears all "user_tenants" edges to the UserTenant entity. +func (tu *TenantUpdate) ClearUserTenants() *TenantUpdate { + tu.mutation.ClearUserTenants() + return tu +} + +// RemoveUserTenantIDs removes the "user_tenants" edge to UserTenant entities by IDs. +func (tu *TenantUpdate) RemoveUserTenantIDs(ids ...int) *TenantUpdate { + tu.mutation.RemoveUserTenantIDs(ids...) + return tu +} + +// RemoveUserTenants removes "user_tenants" edges to UserTenant entities. +func (tu *TenantUpdate) RemoveUserTenants(u ...*UserTenant) *TenantUpdate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return tu.RemoveUserTenantIDs(ids...) +} + +// ClearEnrollmentTokens clears all "enrollment_tokens" edges to the EnrollmentToken entity. +func (tu *TenantUpdate) ClearEnrollmentTokens() *TenantUpdate { + tu.mutation.ClearEnrollmentTokens() + return tu +} + +// RemoveEnrollmentTokenIDs removes the "enrollment_tokens" edge to EnrollmentToken entities by IDs. +func (tu *TenantUpdate) RemoveEnrollmentTokenIDs(ids ...int) *TenantUpdate { + tu.mutation.RemoveEnrollmentTokenIDs(ids...) + return tu +} + +// RemoveEnrollmentTokens removes "enrollment_tokens" edges to EnrollmentToken entities. +func (tu *TenantUpdate) RemoveEnrollmentTokens(e ...*EnrollmentToken) *TenantUpdate { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return tu.RemoveEnrollmentTokenIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (tu *TenantUpdate) Save(ctx context.Context) (int, error) { tu.defaults() @@ -342,6 +456,16 @@ func (tu *TenantUpdate) defaults() { } } +// check runs all checks and user-defined validators on the builder. +func (tu *TenantUpdate) check() error { + if v, ok := tu.mutation.OidcDefaultRole(); ok { + if err := tenant.OidcDefaultRoleValidator(v); err != nil { + return &ValidationError{Name: "oidc_default_role", err: fmt.Errorf(`ent: validator failed for field "Tenant.oidc_default_role": %w`, err)} + } + } + return nil +} + // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (tu *TenantUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TenantUpdate { tu.modifiers = append(tu.modifiers, modifiers...) @@ -349,6 +473,9 @@ func (tu *TenantUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TenantU } func (tu *TenantUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := tu.check(); err != nil { + return n, err + } _spec := sqlgraph.NewUpdateSpec(tenant.Table, tenant.Columns, sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt)) if ps := tu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { @@ -369,6 +496,18 @@ func (tu *TenantUpdate) sqlSave(ctx context.Context) (n int, err error) { if tu.mutation.IsDefaultCleared() { _spec.ClearField(tenant.FieldIsDefault, field.TypeBool) } + if value, ok := tu.mutation.OidcOrgID(); ok { + _spec.SetField(tenant.FieldOidcOrgID, field.TypeString, value) + } + if tu.mutation.OidcOrgIDCleared() { + _spec.ClearField(tenant.FieldOidcOrgID, field.TypeString) + } + if value, ok := tu.mutation.OidcDefaultRole(); ok { + _spec.SetField(tenant.FieldOidcDefaultRole, field.TypeEnum, value) + } + if tu.mutation.OidcDefaultRoleCleared() { + _spec.ClearField(tenant.FieldOidcDefaultRole, field.TypeEnum) + } if value, ok := tu.mutation.Created(); ok { _spec.SetField(tenant.FieldCreated, field.TypeTime, value) } @@ -619,6 +758,96 @@ func (tu *TenantUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tu.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedUserTenantsIDs(); len(nodes) > 0 && !tu.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.UserTenantsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if tu.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedEnrollmentTokensIDs(); len(nodes) > 0 && !tu.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.EnrollmentTokensIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(tu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -681,6 +910,46 @@ func (tuo *TenantUpdateOne) ClearIsDefault() *TenantUpdateOne { return tuo } +// SetOidcOrgID sets the "oidc_org_id" field. +func (tuo *TenantUpdateOne) SetOidcOrgID(s string) *TenantUpdateOne { + tuo.mutation.SetOidcOrgID(s) + return tuo +} + +// SetNillableOidcOrgID sets the "oidc_org_id" field if the given value is not nil. +func (tuo *TenantUpdateOne) SetNillableOidcOrgID(s *string) *TenantUpdateOne { + if s != nil { + tuo.SetOidcOrgID(*s) + } + return tuo +} + +// ClearOidcOrgID clears the value of the "oidc_org_id" field. +func (tuo *TenantUpdateOne) ClearOidcOrgID() *TenantUpdateOne { + tuo.mutation.ClearOidcOrgID() + return tuo +} + +// SetOidcDefaultRole sets the "oidc_default_role" field. +func (tuo *TenantUpdateOne) SetOidcDefaultRole(tdr tenant.OidcDefaultRole) *TenantUpdateOne { + tuo.mutation.SetOidcDefaultRole(tdr) + return tuo +} + +// SetNillableOidcDefaultRole sets the "oidc_default_role" field if the given value is not nil. +func (tuo *TenantUpdateOne) SetNillableOidcDefaultRole(tdr *tenant.OidcDefaultRole) *TenantUpdateOne { + if tdr != nil { + tuo.SetOidcDefaultRole(*tdr) + } + return tuo +} + +// ClearOidcDefaultRole clears the value of the "oidc_default_role" field. +func (tuo *TenantUpdateOne) ClearOidcDefaultRole() *TenantUpdateOne { + tuo.mutation.ClearOidcDefaultRole() + return tuo +} + // SetCreated sets the "created" field. func (tuo *TenantUpdateOne) SetCreated(t time.Time) *TenantUpdateOne { tuo.mutation.SetCreated(t) @@ -811,6 +1080,36 @@ func (tuo *TenantUpdateOne) SetNetbird(n *NetbirdSettings) *TenantUpdateOne { return tuo.SetNetbirdID(n.ID) } +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by IDs. +func (tuo *TenantUpdateOne) AddUserTenantIDs(ids ...int) *TenantUpdateOne { + tuo.mutation.AddUserTenantIDs(ids...) + return tuo +} + +// AddUserTenants adds the "user_tenants" edges to the UserTenant entity. +func (tuo *TenantUpdateOne) AddUserTenants(u ...*UserTenant) *TenantUpdateOne { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return tuo.AddUserTenantIDs(ids...) +} + +// AddEnrollmentTokenIDs adds the "enrollment_tokens" edge to the EnrollmentToken entity by IDs. +func (tuo *TenantUpdateOne) AddEnrollmentTokenIDs(ids ...int) *TenantUpdateOne { + tuo.mutation.AddEnrollmentTokenIDs(ids...) + return tuo +} + +// AddEnrollmentTokens adds the "enrollment_tokens" edges to the EnrollmentToken entity. +func (tuo *TenantUpdateOne) AddEnrollmentTokens(e ...*EnrollmentToken) *TenantUpdateOne { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return tuo.AddEnrollmentTokenIDs(ids...) +} + // Mutation returns the TenantMutation object of the builder. func (tuo *TenantUpdateOne) Mutation() *TenantMutation { return tuo.mutation @@ -912,6 +1211,48 @@ func (tuo *TenantUpdateOne) ClearNetbird() *TenantUpdateOne { return tuo } +// ClearUserTenants clears all "user_tenants" edges to the UserTenant entity. +func (tuo *TenantUpdateOne) ClearUserTenants() *TenantUpdateOne { + tuo.mutation.ClearUserTenants() + return tuo +} + +// RemoveUserTenantIDs removes the "user_tenants" edge to UserTenant entities by IDs. +func (tuo *TenantUpdateOne) RemoveUserTenantIDs(ids ...int) *TenantUpdateOne { + tuo.mutation.RemoveUserTenantIDs(ids...) + return tuo +} + +// RemoveUserTenants removes "user_tenants" edges to UserTenant entities. +func (tuo *TenantUpdateOne) RemoveUserTenants(u ...*UserTenant) *TenantUpdateOne { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return tuo.RemoveUserTenantIDs(ids...) +} + +// ClearEnrollmentTokens clears all "enrollment_tokens" edges to the EnrollmentToken entity. +func (tuo *TenantUpdateOne) ClearEnrollmentTokens() *TenantUpdateOne { + tuo.mutation.ClearEnrollmentTokens() + return tuo +} + +// RemoveEnrollmentTokenIDs removes the "enrollment_tokens" edge to EnrollmentToken entities by IDs. +func (tuo *TenantUpdateOne) RemoveEnrollmentTokenIDs(ids ...int) *TenantUpdateOne { + tuo.mutation.RemoveEnrollmentTokenIDs(ids...) + return tuo +} + +// RemoveEnrollmentTokens removes "enrollment_tokens" edges to EnrollmentToken entities. +func (tuo *TenantUpdateOne) RemoveEnrollmentTokens(e ...*EnrollmentToken) *TenantUpdateOne { + ids := make([]int, len(e)) + for i := range e { + ids[i] = e[i].ID + } + return tuo.RemoveEnrollmentTokenIDs(ids...) +} + // Where appends a list predicates to the TenantUpdate builder. func (tuo *TenantUpdateOne) Where(ps ...predicate.Tenant) *TenantUpdateOne { tuo.mutation.Where(ps...) @@ -961,6 +1302,16 @@ func (tuo *TenantUpdateOne) defaults() { } } +// check runs all checks and user-defined validators on the builder. +func (tuo *TenantUpdateOne) check() error { + if v, ok := tuo.mutation.OidcDefaultRole(); ok { + if err := tenant.OidcDefaultRoleValidator(v); err != nil { + return &ValidationError{Name: "oidc_default_role", err: fmt.Errorf(`ent: validator failed for field "Tenant.oidc_default_role": %w`, err)} + } + } + return nil +} + // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (tuo *TenantUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *TenantUpdateOne { tuo.modifiers = append(tuo.modifiers, modifiers...) @@ -968,6 +1319,9 @@ func (tuo *TenantUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Ten } func (tuo *TenantUpdateOne) sqlSave(ctx context.Context) (_node *Tenant, err error) { + if err := tuo.check(); err != nil { + return _node, err + } _spec := sqlgraph.NewUpdateSpec(tenant.Table, tenant.Columns, sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt)) id, ok := tuo.mutation.ID() if !ok { @@ -1005,6 +1359,18 @@ func (tuo *TenantUpdateOne) sqlSave(ctx context.Context) (_node *Tenant, err err if tuo.mutation.IsDefaultCleared() { _spec.ClearField(tenant.FieldIsDefault, field.TypeBool) } + if value, ok := tuo.mutation.OidcOrgID(); ok { + _spec.SetField(tenant.FieldOidcOrgID, field.TypeString, value) + } + if tuo.mutation.OidcOrgIDCleared() { + _spec.ClearField(tenant.FieldOidcOrgID, field.TypeString) + } + if value, ok := tuo.mutation.OidcDefaultRole(); ok { + _spec.SetField(tenant.FieldOidcDefaultRole, field.TypeEnum, value) + } + if tuo.mutation.OidcDefaultRoleCleared() { + _spec.ClearField(tenant.FieldOidcDefaultRole, field.TypeEnum) + } if value, ok := tuo.mutation.Created(); ok { _spec.SetField(tenant.FieldCreated, field.TypeTime, value) } @@ -1255,6 +1621,96 @@ func (tuo *TenantUpdateOne) sqlSave(ctx context.Context) (_node *Tenant, err err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tuo.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedUserTenantsIDs(); len(nodes) > 0 && !tuo.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.UserTenantsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: tenant.UserTenantsTable, + Columns: []string{tenant.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if tuo.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedEnrollmentTokensIDs(); len(nodes) > 0 && !tuo.mutation.EnrollmentTokensCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.EnrollmentTokensIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: tenant.EnrollmentTokensTable, + Columns: []string{tenant.EnrollmentTokensColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(enrollmenttoken.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(tuo.modifiers...) _node = &Tenant{config: tuo.config} _spec.Assign = _node.assignValues diff --git a/tx.go b/tx.go index 3235773..13e86f5 100644 --- a/tx.go +++ b/tx.go @@ -20,12 +20,16 @@ type Tx struct { App *AppClient // Authentication is the client for interacting with the Authentication builders. Authentication *AuthenticationClient + // Branding is the client for interacting with the Branding builders. + Branding *BrandingClient // Certificate is the client for interacting with the Certificate builders. Certificate *CertificateClient // Computer is the client for interacting with the Computer builders. Computer *ComputerClient // Deployment is the client for interacting with the Deployment builders. Deployment *DeploymentClient + // EnrollmentToken is the client for interacting with the EnrollmentToken builders. + EnrollmentToken *EnrollmentTokenClient // LogicalDisk is the client for interacting with the LogicalDisk builders. LogicalDisk *LogicalDiskClient // MemorySlot is the client for interacting with the MemorySlot builders. @@ -82,6 +86,8 @@ type Tx struct { Update *UpdateClient // User is the client for interacting with the User builders. User *UserClient + // UserTenant is the client for interacting with the UserTenant builders. + UserTenant *UserTenantClient // WingetConfigExclusion is the client for interacting with the WingetConfigExclusion builders. WingetConfigExclusion *WingetConfigExclusionClient @@ -219,9 +225,11 @@ func (tx *Tx) init() { tx.Antivirus = NewAntivirusClient(tx.config) tx.App = NewAppClient(tx.config) tx.Authentication = NewAuthenticationClient(tx.config) + tx.Branding = NewBrandingClient(tx.config) tx.Certificate = NewCertificateClient(tx.config) tx.Computer = NewComputerClient(tx.config) tx.Deployment = NewDeploymentClient(tx.config) + tx.EnrollmentToken = NewEnrollmentTokenClient(tx.config) tx.LogicalDisk = NewLogicalDiskClient(tx.config) tx.MemorySlot = NewMemorySlotClient(tx.config) tx.Metadata = NewMetadataClient(tx.config) @@ -250,6 +258,7 @@ func (tx *Tx) init() { tx.Tenant = NewTenantClient(tx.config) tx.Update = NewUpdateClient(tx.config) tx.User = NewUserClient(tx.config) + tx.UserTenant = NewUserTenantClient(tx.config) tx.WingetConfigExclusion = NewWingetConfigExclusionClient(tx.config) } diff --git a/user.go b/user.go index 2afad2e..c947a9a 100644 --- a/user.go +++ b/user.go @@ -77,9 +77,11 @@ type UserEdges struct { Sessions []*Sessions `json:"sessions,omitempty"` // Recoverycodes holds the value of the recoverycodes edge. Recoverycodes []*RecoveryCode `json:"recoverycodes,omitempty"` + // UserTenants holds the value of the user_tenants edge. + UserTenants []*UserTenant `json:"user_tenants,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [3]bool } // SessionsOrErr returns the Sessions value or an error if the edge @@ -100,6 +102,15 @@ func (e UserEdges) RecoverycodesOrErr() ([]*RecoveryCode, error) { return nil, &NotLoadedError{edge: "recoverycodes"} } +// UserTenantsOrErr returns the UserTenants value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) UserTenantsOrErr() ([]*UserTenant, error) { + if e.loadedTypes[2] { + return e.UserTenants, nil + } + return nil, &NotLoadedError{edge: "user_tenants"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*User) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -301,6 +312,11 @@ func (u *User) QueryRecoverycodes() *RecoveryCodeQuery { return NewUserClient(u.config).QueryRecoverycodes(u) } +// QueryUserTenants queries the "user_tenants" edge of the User entity. +func (u *User) QueryUserTenants() *UserTenantQuery { + return NewUserClient(u.config).QueryUserTenants(u) +} + // Update returns a builder for updating this User. // Note that you need to call User.Unwrap() before calling this method if this User // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/user/user.go b/user/user.go index f6ff89b..2fdc084 100644 --- a/user/user.go +++ b/user/user.go @@ -66,10 +66,14 @@ const ( EdgeSessions = "sessions" // EdgeRecoverycodes holds the string denoting the recoverycodes edge name in mutations. EdgeRecoverycodes = "recoverycodes" + // EdgeUserTenants holds the string denoting the user_tenants edge name in mutations. + EdgeUserTenants = "user_tenants" // SessionsFieldID holds the string denoting the ID field of the Sessions. SessionsFieldID = "token" // RecoveryCodeFieldID holds the string denoting the ID field of the RecoveryCode. RecoveryCodeFieldID = "id" + // UserTenantFieldID holds the string denoting the ID field of the UserTenant. + UserTenantFieldID = "id" // Table holds the table name of the user in the database. Table = "users" // SessionsTable is the table that holds the sessions relation/edge. @@ -86,6 +90,13 @@ const ( RecoverycodesInverseTable = "recovery_codes" // RecoverycodesColumn is the table column denoting the recoverycodes relation/edge. RecoverycodesColumn = "user_recoverycodes" + // UserTenantsTable is the table that holds the user_tenants relation/edge. + UserTenantsTable = "user_tenants" + // UserTenantsInverseTable is the table name for the UserTenant entity. + // It exists in this package in order to avoid circular dependency with the "usertenant" package. + UserTenantsInverseTable = "user_tenants" + // UserTenantsColumn is the table column denoting the user_tenants relation/edge. + UserTenantsColumn = "user_id" ) // Columns holds all SQL columns for user fields. @@ -325,6 +336,20 @@ func ByRecoverycodes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newRecoverycodesStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByUserTenantsCount orders the results by user_tenants count. +func ByUserTenantsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserTenantsStep(), opts...) + } +} + +// ByUserTenants orders the results by user_tenants terms. +func ByUserTenants(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserTenantsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newSessionsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -339,3 +364,10 @@ func newRecoverycodesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, RecoverycodesTable, RecoverycodesColumn), ) } +func newUserTenantsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserTenantsInverseTable, UserTenantFieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserTenantsTable, UserTenantsColumn), + ) +} diff --git a/user/where.go b/user/where.go index ec68972..26b94b3 100644 --- a/user/where.go +++ b/user/where.go @@ -1601,6 +1601,29 @@ func HasRecoverycodesWith(preds ...predicate.RecoveryCode) predicate.User { }) } +// HasUserTenants applies the HasEdge predicate on the "user_tenants" edge. +func HasUserTenants() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserTenantsTable, UserTenantsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserTenantsWith applies the HasEdge predicate on the "user_tenants" edge with a given conditions (other predicates). +func HasUserTenantsWith(preds ...predicate.UserTenant) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newUserTenantsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.User) predicate.User { return predicate.User(sql.AndPredicates(predicates...)) diff --git a/user_create.go b/user_create.go index 71c74a5..dfb99b6 100644 --- a/user_create.go +++ b/user_create.go @@ -15,6 +15,7 @@ import ( "github.com/open-uem/ent/recoverycode" "github.com/open-uem/ent/sessions" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" ) // UserCreate is the builder for creating a User entity. @@ -389,6 +390,21 @@ func (uc *UserCreate) AddRecoverycodes(r ...*RecoveryCode) *UserCreate { return uc.AddRecoverycodeIDs(ids...) } +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by IDs. +func (uc *UserCreate) AddUserTenantIDs(ids ...int) *UserCreate { + uc.mutation.AddUserTenantIDs(ids...) + return uc +} + +// AddUserTenants adds the "user_tenants" edges to the UserTenant entity. +func (uc *UserCreate) AddUserTenants(u ...*UserTenant) *UserCreate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uc.AddUserTenantIDs(ids...) +} + // Mutation returns the UserMutation object of the builder. func (uc *UserCreate) Mutation() *UserMutation { return uc.mutation @@ -678,6 +694,22 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := uc.mutation.UserTenantsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/user_query.go b/user_query.go index d738b97..3f0fa05 100644 --- a/user_query.go +++ b/user_query.go @@ -16,6 +16,7 @@ import ( "github.com/open-uem/ent/recoverycode" "github.com/open-uem/ent/sessions" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" ) // UserQuery is the builder for querying User entities. @@ -27,6 +28,7 @@ type UserQuery struct { predicates []predicate.User withSessions *SessionsQuery withRecoverycodes *RecoveryCodeQuery + withUserTenants *UserTenantQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -108,6 +110,28 @@ func (uq *UserQuery) QueryRecoverycodes() *RecoveryCodeQuery { return query } +// QueryUserTenants chains the current query on the "user_tenants" edge. +func (uq *UserQuery) QueryUserTenants() *UserTenantQuery { + query := (&UserTenantClient{config: uq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := uq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(usertenant.Table, usertenant.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, user.UserTenantsTable, user.UserTenantsColumn), + ) + fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first User entity from the query. // Returns a *NotFoundError when no User was found. func (uq *UserQuery) First(ctx context.Context) (*User, error) { @@ -302,6 +326,7 @@ func (uq *UserQuery) Clone() *UserQuery { predicates: append([]predicate.User{}, uq.predicates...), withSessions: uq.withSessions.Clone(), withRecoverycodes: uq.withRecoverycodes.Clone(), + withUserTenants: uq.withUserTenants.Clone(), // clone intermediate query. sql: uq.sql.Clone(), path: uq.path, @@ -331,6 +356,17 @@ func (uq *UserQuery) WithRecoverycodes(opts ...func(*RecoveryCodeQuery)) *UserQu return uq } +// WithUserTenants tells the query-builder to eager-load the nodes that are connected to +// the "user_tenants" edge. The optional arguments are used to configure the query builder of the edge. +func (uq *UserQuery) WithUserTenants(opts ...func(*UserTenantQuery)) *UserQuery { + query := (&UserTenantClient{config: uq.config}).Query() + for _, opt := range opts { + opt(query) + } + uq.withUserTenants = query + return uq +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -409,9 +445,10 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e var ( nodes = []*User{} _spec = uq.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [3]bool{ uq.withSessions != nil, uq.withRecoverycodes != nil, + uq.withUserTenants != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -449,6 +486,13 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e return nil, err } } + if query := uq.withUserTenants; query != nil { + if err := uq.loadUserTenants(ctx, query, nodes, + func(n *User) { n.Edges.UserTenants = []*UserTenant{} }, + func(n *User, e *UserTenant) { n.Edges.UserTenants = append(n.Edges.UserTenants, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -514,6 +558,36 @@ func (uq *UserQuery) loadRecoverycodes(ctx context.Context, query *RecoveryCodeQ } return nil } +func (uq *UserQuery) loadUserTenants(ctx context.Context, query *UserTenantQuery, nodes []*User, init func(*User), assign func(*User, *UserTenant)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[string]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(usertenant.FieldUserID) + } + query.Where(predicate.UserTenant(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.UserTenantsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.UserID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { _spec := uq.querySpec() diff --git a/user_update.go b/user_update.go index 1b07318..0922790 100644 --- a/user_update.go +++ b/user_update.go @@ -15,6 +15,7 @@ import ( "github.com/open-uem/ent/recoverycode" "github.com/open-uem/ent/sessions" "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" ) // UserUpdate is the builder for updating User entities. @@ -522,6 +523,21 @@ func (uu *UserUpdate) AddRecoverycodes(r ...*RecoveryCode) *UserUpdate { return uu.AddRecoverycodeIDs(ids...) } +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by IDs. +func (uu *UserUpdate) AddUserTenantIDs(ids ...int) *UserUpdate { + uu.mutation.AddUserTenantIDs(ids...) + return uu +} + +// AddUserTenants adds the "user_tenants" edges to the UserTenant entity. +func (uu *UserUpdate) AddUserTenants(u ...*UserTenant) *UserUpdate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.AddUserTenantIDs(ids...) +} + // Mutation returns the UserMutation object of the builder. func (uu *UserUpdate) Mutation() *UserMutation { return uu.mutation @@ -569,6 +585,27 @@ func (uu *UserUpdate) RemoveRecoverycodes(r ...*RecoveryCode) *UserUpdate { return uu.RemoveRecoverycodeIDs(ids...) } +// ClearUserTenants clears all "user_tenants" edges to the UserTenant entity. +func (uu *UserUpdate) ClearUserTenants() *UserUpdate { + uu.mutation.ClearUserTenants() + return uu +} + +// RemoveUserTenantIDs removes the "user_tenants" edge to UserTenant entities by IDs. +func (uu *UserUpdate) RemoveUserTenantIDs(ids ...int) *UserUpdate { + uu.mutation.RemoveUserTenantIDs(ids...) + return uu +} + +// RemoveUserTenants removes "user_tenants" edges to UserTenant entities. +func (uu *UserUpdate) RemoveUserTenants(u ...*UserTenant) *UserUpdate { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uu.RemoveUserTenantIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (uu *UserUpdate) Save(ctx context.Context) (int, error) { uu.defaults() @@ -848,6 +885,51 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if uu.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.RemovedUserTenantsIDs(); len(nodes) > 0 && !uu.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uu.mutation.UserTenantsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(uu.modifiers...) if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -1361,6 +1443,21 @@ func (uuo *UserUpdateOne) AddRecoverycodes(r ...*RecoveryCode) *UserUpdateOne { return uuo.AddRecoverycodeIDs(ids...) } +// AddUserTenantIDs adds the "user_tenants" edge to the UserTenant entity by IDs. +func (uuo *UserUpdateOne) AddUserTenantIDs(ids ...int) *UserUpdateOne { + uuo.mutation.AddUserTenantIDs(ids...) + return uuo +} + +// AddUserTenants adds the "user_tenants" edges to the UserTenant entity. +func (uuo *UserUpdateOne) AddUserTenants(u ...*UserTenant) *UserUpdateOne { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.AddUserTenantIDs(ids...) +} + // Mutation returns the UserMutation object of the builder. func (uuo *UserUpdateOne) Mutation() *UserMutation { return uuo.mutation @@ -1408,6 +1505,27 @@ func (uuo *UserUpdateOne) RemoveRecoverycodes(r ...*RecoveryCode) *UserUpdateOne return uuo.RemoveRecoverycodeIDs(ids...) } +// ClearUserTenants clears all "user_tenants" edges to the UserTenant entity. +func (uuo *UserUpdateOne) ClearUserTenants() *UserUpdateOne { + uuo.mutation.ClearUserTenants() + return uuo +} + +// RemoveUserTenantIDs removes the "user_tenants" edge to UserTenant entities by IDs. +func (uuo *UserUpdateOne) RemoveUserTenantIDs(ids ...int) *UserUpdateOne { + uuo.mutation.RemoveUserTenantIDs(ids...) + return uuo +} + +// RemoveUserTenants removes "user_tenants" edges to UserTenant entities. +func (uuo *UserUpdateOne) RemoveUserTenants(u ...*UserTenant) *UserUpdateOne { + ids := make([]int, len(u)) + for i := range u { + ids[i] = u[i].ID + } + return uuo.RemoveUserTenantIDs(ids...) +} + // Where appends a list predicates to the UserUpdate builder. func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { uuo.mutation.Where(ps...) @@ -1717,6 +1835,51 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if uuo.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.RemovedUserTenantsIDs(); len(nodes) > 0 && !uuo.mutation.UserTenantsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := uuo.mutation.UserTenantsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserTenantsTable, + Columns: []string{user.UserTenantsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(uuo.modifiers...) _node = &User{config: uuo.config} _spec.Assign = _node.assignValues diff --git a/usertenant.go b/usertenant.go new file mode 100644 index 0000000..e730ec9 --- /dev/null +++ b/usertenant.go @@ -0,0 +1,211 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/open-uem/ent/tenant" + "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" +) + +// UserTenant is the model entity for the UserTenant schema. +type UserTenant struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // UserID holds the value of the "user_id" field. + UserID string `json:"user_id,omitempty"` + // TenantID holds the value of the "tenant_id" field. + TenantID int `json:"tenant_id,omitempty"` + // The role of the user within this tenant + Role usertenant.Role `json:"role,omitempty"` + // If true, this is the default tenant for the user after login + IsDefault bool `json:"is_default,omitempty"` + // Created holds the value of the "created" field. + Created time.Time `json:"created,omitempty"` + // Modified holds the value of the "modified" field. + Modified time.Time `json:"modified,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserTenantQuery when eager-loading is set. + Edges UserTenantEdges `json:"edges"` + selectValues sql.SelectValues +} + +// UserTenantEdges holds the relations/edges for other nodes in the graph. +type UserTenantEdges struct { + // User holds the value of the user edge. + User *User `json:"user,omitempty"` + // Tenant holds the value of the tenant edge. + Tenant *Tenant `json:"tenant,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserTenantEdges) UserOrErr() (*User, error) { + if e.User != nil { + return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} + } + return nil, &NotLoadedError{edge: "user"} +} + +// TenantOrErr returns the Tenant value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserTenantEdges) TenantOrErr() (*Tenant, error) { + if e.Tenant != nil { + return e.Tenant, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: tenant.Label} + } + return nil, &NotLoadedError{edge: "tenant"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserTenant) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case usertenant.FieldIsDefault: + values[i] = new(sql.NullBool) + case usertenant.FieldID, usertenant.FieldTenantID: + values[i] = new(sql.NullInt64) + case usertenant.FieldUserID, usertenant.FieldRole: + values[i] = new(sql.NullString) + case usertenant.FieldCreated, usertenant.FieldModified: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the UserTenant fields. +func (ut *UserTenant) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case usertenant.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + ut.ID = int(value.Int64) + case usertenant.FieldUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + ut.UserID = value.String + } + case usertenant.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + ut.TenantID = int(value.Int64) + } + case usertenant.FieldRole: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field role", values[i]) + } else if value.Valid { + ut.Role = usertenant.Role(value.String) + } + case usertenant.FieldIsDefault: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_default", values[i]) + } else if value.Valid { + ut.IsDefault = value.Bool + } + case usertenant.FieldCreated: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created", values[i]) + } else if value.Valid { + ut.Created = value.Time + } + case usertenant.FieldModified: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field modified", values[i]) + } else if value.Valid { + ut.Modified = value.Time + } + default: + ut.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserTenant. +// This includes values selected through modifiers, order, etc. +func (ut *UserTenant) Value(name string) (ent.Value, error) { + return ut.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the UserTenant entity. +func (ut *UserTenant) QueryUser() *UserQuery { + return NewUserTenantClient(ut.config).QueryUser(ut) +} + +// QueryTenant queries the "tenant" edge of the UserTenant entity. +func (ut *UserTenant) QueryTenant() *TenantQuery { + return NewUserTenantClient(ut.config).QueryTenant(ut) +} + +// Update returns a builder for updating this UserTenant. +// Note that you need to call UserTenant.Unwrap() before calling this method if this UserTenant +// was returned from a transaction, and the transaction was committed or rolled back. +func (ut *UserTenant) Update() *UserTenantUpdateOne { + return NewUserTenantClient(ut.config).UpdateOne(ut) +} + +// Unwrap unwraps the UserTenant entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (ut *UserTenant) Unwrap() *UserTenant { + _tx, ok := ut.config.driver.(*txDriver) + if !ok { + panic("ent: UserTenant is not a transactional entity") + } + ut.config.driver = _tx.drv + return ut +} + +// String implements the fmt.Stringer. +func (ut *UserTenant) String() string { + var builder strings.Builder + builder.WriteString("UserTenant(") + builder.WriteString(fmt.Sprintf("id=%v, ", ut.ID)) + builder.WriteString("user_id=") + builder.WriteString(ut.UserID) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", ut.TenantID)) + builder.WriteString(", ") + builder.WriteString("role=") + builder.WriteString(fmt.Sprintf("%v", ut.Role)) + builder.WriteString(", ") + builder.WriteString("is_default=") + builder.WriteString(fmt.Sprintf("%v", ut.IsDefault)) + builder.WriteString(", ") + builder.WriteString("created=") + builder.WriteString(ut.Created.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("modified=") + builder.WriteString(ut.Modified.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// UserTenants is a parsable slice of UserTenant. +type UserTenants []*UserTenant diff --git a/usertenant/usertenant.go b/usertenant/usertenant.go new file mode 100644 index 0000000..5ca963e --- /dev/null +++ b/usertenant/usertenant.go @@ -0,0 +1,179 @@ +// Code generated by ent, DO NOT EDIT. + +package usertenant + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the usertenant type in the database. + Label = "user_tenant" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldRole holds the string denoting the role field in the database. + FieldRole = "role" + // FieldIsDefault holds the string denoting the is_default field in the database. + FieldIsDefault = "is_default" + // FieldCreated holds the string denoting the created field in the database. + FieldCreated = "created" + // FieldModified holds the string denoting the modified field in the database. + FieldModified = "modified" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgeTenant holds the string denoting the tenant edge name in mutations. + EdgeTenant = "tenant" + // UserFieldID holds the string denoting the ID field of the User. + UserFieldID = "uid" + // Table holds the table name of the usertenant in the database. + Table = "user_tenants" + // UserTable is the table that holds the user relation/edge. + UserTable = "user_tenants" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // TenantTable is the table that holds the tenant relation/edge. + TenantTable = "user_tenants" + // TenantInverseTable is the table name for the Tenant entity. + // It exists in this package in order to avoid circular dependency with the "tenant" package. + TenantInverseTable = "tenants" + // TenantColumn is the table column denoting the tenant relation/edge. + TenantColumn = "tenant_id" +) + +// Columns holds all SQL columns for usertenant fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldTenantID, + FieldRole, + FieldIsDefault, + FieldCreated, + FieldModified, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(string) error + // DefaultIsDefault holds the default value on creation for the "is_default" field. + DefaultIsDefault bool + // DefaultCreated holds the default value on creation for the "created" field. + DefaultCreated func() time.Time + // DefaultModified holds the default value on creation for the "modified" field. + DefaultModified func() time.Time + // UpdateDefaultModified holds the default value on update for the "modified" field. + UpdateDefaultModified func() time.Time +) + +// Role defines the type for the "role" enum field. +type Role string + +// RoleUser is the default value of the Role enum. +const DefaultRole = RoleUser + +// Role values. +const ( + RoleAdmin Role = "admin" + RoleOperator Role = "operator" + RoleUser Role = "user" +) + +func (r Role) String() string { + return string(r) +} + +// RoleValidator is a validator for the "role" field enum values. It is called by the builders before save. +func RoleValidator(r Role) error { + switch r { + case RoleAdmin, RoleOperator, RoleUser: + return nil + default: + return fmt.Errorf("usertenant: invalid enum value for role field: %q", r) + } +} + +// OrderOption defines the ordering options for the UserTenant queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByRole orders the results by the role field. +func ByRole(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRole, opts...).ToFunc() +} + +// ByIsDefault orders the results by the is_default field. +func ByIsDefault(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDefault, opts...).ToFunc() +} + +// ByCreated orders the results by the created field. +func ByCreated(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreated, opts...).ToFunc() +} + +// ByModified orders the results by the modified field. +func ByModified(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldModified, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} + +// ByTenantField orders the results by tenant field. +func ByTenantField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTenantStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, UserFieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) +} +func newTenantStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TenantInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TenantTable, TenantColumn), + ) +} diff --git a/usertenant/where.go b/usertenant/where.go new file mode 100644 index 0000000..2781228 --- /dev/null +++ b/usertenant/where.go @@ -0,0 +1,357 @@ +// Code generated by ent, DO NOT EDIT. + +package usertenant + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/open-uem/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldUserID, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldTenantID, v)) +} + +// IsDefault applies equality check predicate on the "is_default" field. It's identical to IsDefaultEQ. +func IsDefault(v bool) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldIsDefault, v)) +} + +// Created applies equality check predicate on the "created" field. It's identical to CreatedEQ. +func Created(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldCreated, v)) +} + +// Modified applies equality check predicate on the "modified" field. It's identical to ModifiedEQ. +func Modified(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldModified, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLTE(FieldUserID, v)) +} + +// UserIDContains applies the Contains predicate on the "user_id" field. +func UserIDContains(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldContains(FieldUserID, v)) +} + +// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field. +func UserIDHasPrefix(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldHasPrefix(FieldUserID, v)) +} + +// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field. +func UserIDHasSuffix(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldHasSuffix(FieldUserID, v)) +} + +// UserIDEqualFold applies the EqualFold predicate on the "user_id" field. +func UserIDEqualFold(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEqualFold(FieldUserID, v)) +} + +// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field. +func UserIDContainsFold(v string) predicate.UserTenant { + return predicate.UserTenant(sql.FieldContainsFold(FieldUserID, v)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...int) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// RoleEQ applies the EQ predicate on the "role" field. +func RoleEQ(v Role) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldRole, v)) +} + +// RoleNEQ applies the NEQ predicate on the "role" field. +func RoleNEQ(v Role) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldRole, v)) +} + +// RoleIn applies the In predicate on the "role" field. +func RoleIn(vs ...Role) predicate.UserTenant { + return predicate.UserTenant(sql.FieldIn(FieldRole, vs...)) +} + +// RoleNotIn applies the NotIn predicate on the "role" field. +func RoleNotIn(vs ...Role) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotIn(FieldRole, vs...)) +} + +// IsDefaultEQ applies the EQ predicate on the "is_default" field. +func IsDefaultEQ(v bool) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldIsDefault, v)) +} + +// IsDefaultNEQ applies the NEQ predicate on the "is_default" field. +func IsDefaultNEQ(v bool) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldIsDefault, v)) +} + +// CreatedEQ applies the EQ predicate on the "created" field. +func CreatedEQ(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldCreated, v)) +} + +// CreatedNEQ applies the NEQ predicate on the "created" field. +func CreatedNEQ(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldCreated, v)) +} + +// CreatedIn applies the In predicate on the "created" field. +func CreatedIn(vs ...time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldIn(FieldCreated, vs...)) +} + +// CreatedNotIn applies the NotIn predicate on the "created" field. +func CreatedNotIn(vs ...time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotIn(FieldCreated, vs...)) +} + +// CreatedGT applies the GT predicate on the "created" field. +func CreatedGT(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGT(FieldCreated, v)) +} + +// CreatedGTE applies the GTE predicate on the "created" field. +func CreatedGTE(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGTE(FieldCreated, v)) +} + +// CreatedLT applies the LT predicate on the "created" field. +func CreatedLT(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLT(FieldCreated, v)) +} + +// CreatedLTE applies the LTE predicate on the "created" field. +func CreatedLTE(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLTE(FieldCreated, v)) +} + +// CreatedIsNil applies the IsNil predicate on the "created" field. +func CreatedIsNil() predicate.UserTenant { + return predicate.UserTenant(sql.FieldIsNull(FieldCreated)) +} + +// CreatedNotNil applies the NotNil predicate on the "created" field. +func CreatedNotNil() predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotNull(FieldCreated)) +} + +// ModifiedEQ applies the EQ predicate on the "modified" field. +func ModifiedEQ(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldEQ(FieldModified, v)) +} + +// ModifiedNEQ applies the NEQ predicate on the "modified" field. +func ModifiedNEQ(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNEQ(FieldModified, v)) +} + +// ModifiedIn applies the In predicate on the "modified" field. +func ModifiedIn(vs ...time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldIn(FieldModified, vs...)) +} + +// ModifiedNotIn applies the NotIn predicate on the "modified" field. +func ModifiedNotIn(vs ...time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotIn(FieldModified, vs...)) +} + +// ModifiedGT applies the GT predicate on the "modified" field. +func ModifiedGT(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGT(FieldModified, v)) +} + +// ModifiedGTE applies the GTE predicate on the "modified" field. +func ModifiedGTE(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldGTE(FieldModified, v)) +} + +// ModifiedLT applies the LT predicate on the "modified" field. +func ModifiedLT(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLT(FieldModified, v)) +} + +// ModifiedLTE applies the LTE predicate on the "modified" field. +func ModifiedLTE(v time.Time) predicate.UserTenant { + return predicate.UserTenant(sql.FieldLTE(FieldModified, v)) +} + +// ModifiedIsNil applies the IsNil predicate on the "modified" field. +func ModifiedIsNil() predicate.UserTenant { + return predicate.UserTenant(sql.FieldIsNull(FieldModified)) +} + +// ModifiedNotNil applies the NotNil predicate on the "modified" field. +func ModifiedNotNil() predicate.UserTenant { + return predicate.UserTenant(sql.FieldNotNull(FieldModified)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserTenant { + return predicate.UserTenant(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserTenant { + return predicate.UserTenant(func(s *sql.Selector) { + step := newUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTenant applies the HasEdge predicate on the "tenant" edge. +func HasTenant() predicate.UserTenant { + return predicate.UserTenant(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, TenantTable, TenantColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTenantWith applies the HasEdge predicate on the "tenant" edge with a given conditions (other predicates). +func HasTenantWith(preds ...predicate.Tenant) predicate.UserTenant { + return predicate.UserTenant(func(s *sql.Selector) { + step := newTenantStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserTenant) predicate.UserTenant { + return predicate.UserTenant(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserTenant) predicate.UserTenant { + return predicate.UserTenant(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserTenant) predicate.UserTenant { + return predicate.UserTenant(sql.NotPredicates(p)) +} diff --git a/usertenant_create.go b/usertenant_create.go new file mode 100644 index 0000000..2cb3a87 --- /dev/null +++ b/usertenant_create.go @@ -0,0 +1,862 @@ +// 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/open-uem/ent/tenant" + "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" +) + +// UserTenantCreate is the builder for creating a UserTenant entity. +type UserTenantCreate struct { + config + mutation *UserTenantMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetUserID sets the "user_id" field. +func (utc *UserTenantCreate) SetUserID(s string) *UserTenantCreate { + utc.mutation.SetUserID(s) + return utc +} + +// SetTenantID sets the "tenant_id" field. +func (utc *UserTenantCreate) SetTenantID(i int) *UserTenantCreate { + utc.mutation.SetTenantID(i) + return utc +} + +// SetRole sets the "role" field. +func (utc *UserTenantCreate) SetRole(u usertenant.Role) *UserTenantCreate { + utc.mutation.SetRole(u) + return utc +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (utc *UserTenantCreate) SetNillableRole(u *usertenant.Role) *UserTenantCreate { + if u != nil { + utc.SetRole(*u) + } + return utc +} + +// SetIsDefault sets the "is_default" field. +func (utc *UserTenantCreate) SetIsDefault(b bool) *UserTenantCreate { + utc.mutation.SetIsDefault(b) + return utc +} + +// SetNillableIsDefault sets the "is_default" field if the given value is not nil. +func (utc *UserTenantCreate) SetNillableIsDefault(b *bool) *UserTenantCreate { + if b != nil { + utc.SetIsDefault(*b) + } + return utc +} + +// SetCreated sets the "created" field. +func (utc *UserTenantCreate) SetCreated(t time.Time) *UserTenantCreate { + utc.mutation.SetCreated(t) + return utc +} + +// SetNillableCreated sets the "created" field if the given value is not nil. +func (utc *UserTenantCreate) SetNillableCreated(t *time.Time) *UserTenantCreate { + if t != nil { + utc.SetCreated(*t) + } + return utc +} + +// SetModified sets the "modified" field. +func (utc *UserTenantCreate) SetModified(t time.Time) *UserTenantCreate { + utc.mutation.SetModified(t) + return utc +} + +// SetNillableModified sets the "modified" field if the given value is not nil. +func (utc *UserTenantCreate) SetNillableModified(t *time.Time) *UserTenantCreate { + if t != nil { + utc.SetModified(*t) + } + return utc +} + +// SetUser sets the "user" edge to the User entity. +func (utc *UserTenantCreate) SetUser(u *User) *UserTenantCreate { + return utc.SetUserID(u.ID) +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (utc *UserTenantCreate) SetTenant(t *Tenant) *UserTenantCreate { + return utc.SetTenantID(t.ID) +} + +// Mutation returns the UserTenantMutation object of the builder. +func (utc *UserTenantCreate) Mutation() *UserTenantMutation { + return utc.mutation +} + +// Save creates the UserTenant in the database. +func (utc *UserTenantCreate) Save(ctx context.Context) (*UserTenant, error) { + utc.defaults() + return withHooks(ctx, utc.sqlSave, utc.mutation, utc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (utc *UserTenantCreate) SaveX(ctx context.Context) *UserTenant { + v, err := utc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (utc *UserTenantCreate) Exec(ctx context.Context) error { + _, err := utc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (utc *UserTenantCreate) ExecX(ctx context.Context) { + if err := utc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (utc *UserTenantCreate) defaults() { + if _, ok := utc.mutation.Role(); !ok { + v := usertenant.DefaultRole + utc.mutation.SetRole(v) + } + if _, ok := utc.mutation.IsDefault(); !ok { + v := usertenant.DefaultIsDefault + utc.mutation.SetIsDefault(v) + } + if _, ok := utc.mutation.Created(); !ok { + v := usertenant.DefaultCreated() + utc.mutation.SetCreated(v) + } + if _, ok := utc.mutation.Modified(); !ok { + v := usertenant.DefaultModified() + utc.mutation.SetModified(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (utc *UserTenantCreate) check() error { + if _, ok := utc.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserTenant.user_id"`)} + } + if v, ok := utc.mutation.UserID(); ok { + if err := usertenant.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserTenant.user_id": %w`, err)} + } + } + if _, ok := utc.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "UserTenant.tenant_id"`)} + } + if _, ok := utc.mutation.Role(); !ok { + return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "UserTenant.role"`)} + } + if v, ok := utc.mutation.Role(); ok { + if err := usertenant.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "UserTenant.role": %w`, err)} + } + } + if _, ok := utc.mutation.IsDefault(); !ok { + return &ValidationError{Name: "is_default", err: errors.New(`ent: missing required field "UserTenant.is_default"`)} + } + if len(utc.mutation.UserIDs()) == 0 { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserTenant.user"`)} + } + if len(utc.mutation.TenantIDs()) == 0 { + return &ValidationError{Name: "tenant", err: errors.New(`ent: missing required edge "UserTenant.tenant"`)} + } + return nil +} + +func (utc *UserTenantCreate) sqlSave(ctx context.Context) (*UserTenant, error) { + if err := utc.check(); err != nil { + return nil, err + } + _node, _spec := utc.createSpec() + if err := sqlgraph.CreateNode(ctx, utc.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 = int(id) + utc.mutation.id = &_node.ID + utc.mutation.done = true + return _node, nil +} + +func (utc *UserTenantCreate) createSpec() (*UserTenant, *sqlgraph.CreateSpec) { + var ( + _node = &UserTenant{config: utc.config} + _spec = sqlgraph.NewCreateSpec(usertenant.Table, sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt)) + ) + _spec.OnConflict = utc.conflict + if value, ok := utc.mutation.Role(); ok { + _spec.SetField(usertenant.FieldRole, field.TypeEnum, value) + _node.Role = value + } + if value, ok := utc.mutation.IsDefault(); ok { + _spec.SetField(usertenant.FieldIsDefault, field.TypeBool, value) + _node.IsDefault = value + } + if value, ok := utc.mutation.Created(); ok { + _spec.SetField(usertenant.FieldCreated, field.TypeTime, value) + _node.Created = value + } + if value, ok := utc.mutation.Modified(); ok { + _spec.SetField(usertenant.FieldModified, field.TypeTime, value) + _node.Modified = value + } + if nodes := utc.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.UserTable, + Columns: []string{usertenant.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.UserID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := utc.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.TenantTable, + Columns: []string{usertenant.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.TenantID = 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.UserTenant.Create(). +// SetUserID(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.UserTenantUpsert) { +// SetUserID(v+v). +// }). +// Exec(ctx) +func (utc *UserTenantCreate) OnConflict(opts ...sql.ConflictOption) *UserTenantUpsertOne { + utc.conflict = opts + return &UserTenantUpsertOne{ + create: utc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserTenant.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (utc *UserTenantCreate) OnConflictColumns(columns ...string) *UserTenantUpsertOne { + utc.conflict = append(utc.conflict, sql.ConflictColumns(columns...)) + return &UserTenantUpsertOne{ + create: utc, + } +} + +type ( + // UserTenantUpsertOne is the builder for "upsert"-ing + // one UserTenant node. + UserTenantUpsertOne struct { + create *UserTenantCreate + } + + // UserTenantUpsert is the "OnConflict" setter. + UserTenantUpsert struct { + *sql.UpdateSet + } +) + +// SetUserID sets the "user_id" field. +func (u *UserTenantUpsert) SetUserID(v string) *UserTenantUpsert { + u.Set(usertenant.FieldUserID, v) + return u +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserTenantUpsert) UpdateUserID() *UserTenantUpsert { + u.SetExcluded(usertenant.FieldUserID) + return u +} + +// SetTenantID sets the "tenant_id" field. +func (u *UserTenantUpsert) SetTenantID(v int) *UserTenantUpsert { + u.Set(usertenant.FieldTenantID, v) + return u +} + +// UpdateTenantID sets the "tenant_id" field to the value that was provided on create. +func (u *UserTenantUpsert) UpdateTenantID() *UserTenantUpsert { + u.SetExcluded(usertenant.FieldTenantID) + return u +} + +// SetRole sets the "role" field. +func (u *UserTenantUpsert) SetRole(v usertenant.Role) *UserTenantUpsert { + u.Set(usertenant.FieldRole, v) + return u +} + +// UpdateRole sets the "role" field to the value that was provided on create. +func (u *UserTenantUpsert) UpdateRole() *UserTenantUpsert { + u.SetExcluded(usertenant.FieldRole) + return u +} + +// SetIsDefault sets the "is_default" field. +func (u *UserTenantUpsert) SetIsDefault(v bool) *UserTenantUpsert { + u.Set(usertenant.FieldIsDefault, v) + return u +} + +// UpdateIsDefault sets the "is_default" field to the value that was provided on create. +func (u *UserTenantUpsert) UpdateIsDefault() *UserTenantUpsert { + u.SetExcluded(usertenant.FieldIsDefault) + return u +} + +// SetCreated sets the "created" field. +func (u *UserTenantUpsert) SetCreated(v time.Time) *UserTenantUpsert { + u.Set(usertenant.FieldCreated, v) + return u +} + +// UpdateCreated sets the "created" field to the value that was provided on create. +func (u *UserTenantUpsert) UpdateCreated() *UserTenantUpsert { + u.SetExcluded(usertenant.FieldCreated) + return u +} + +// ClearCreated clears the value of the "created" field. +func (u *UserTenantUpsert) ClearCreated() *UserTenantUpsert { + u.SetNull(usertenant.FieldCreated) + return u +} + +// SetModified sets the "modified" field. +func (u *UserTenantUpsert) SetModified(v time.Time) *UserTenantUpsert { + u.Set(usertenant.FieldModified, v) + return u +} + +// UpdateModified sets the "modified" field to the value that was provided on create. +func (u *UserTenantUpsert) UpdateModified() *UserTenantUpsert { + u.SetExcluded(usertenant.FieldModified) + return u +} + +// ClearModified clears the value of the "modified" field. +func (u *UserTenantUpsert) ClearModified() *UserTenantUpsert { + u.SetNull(usertenant.FieldModified) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.UserTenant.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *UserTenantUpsertOne) UpdateNewValues() *UserTenantUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.UserTenant.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserTenantUpsertOne) Ignore() *UserTenantUpsertOne { + 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 *UserTenantUpsertOne) DoNothing() *UserTenantUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserTenantCreate.OnConflict +// documentation for more info. +func (u *UserTenantUpsertOne) Update(set func(*UserTenantUpsert)) *UserTenantUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserTenantUpsert{UpdateSet: update}) + })) + return u +} + +// SetUserID sets the "user_id" field. +func (u *UserTenantUpsertOne) SetUserID(v string) *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserTenantUpsertOne) UpdateUserID() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateUserID() + }) +} + +// SetTenantID sets the "tenant_id" field. +func (u *UserTenantUpsertOne) SetTenantID(v int) *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.SetTenantID(v) + }) +} + +// UpdateTenantID sets the "tenant_id" field to the value that was provided on create. +func (u *UserTenantUpsertOne) UpdateTenantID() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateTenantID() + }) +} + +// SetRole sets the "role" field. +func (u *UserTenantUpsertOne) SetRole(v usertenant.Role) *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.SetRole(v) + }) +} + +// UpdateRole sets the "role" field to the value that was provided on create. +func (u *UserTenantUpsertOne) UpdateRole() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateRole() + }) +} + +// SetIsDefault sets the "is_default" field. +func (u *UserTenantUpsertOne) SetIsDefault(v bool) *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.SetIsDefault(v) + }) +} + +// UpdateIsDefault sets the "is_default" field to the value that was provided on create. +func (u *UserTenantUpsertOne) UpdateIsDefault() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateIsDefault() + }) +} + +// SetCreated sets the "created" field. +func (u *UserTenantUpsertOne) SetCreated(v time.Time) *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.SetCreated(v) + }) +} + +// UpdateCreated sets the "created" field to the value that was provided on create. +func (u *UserTenantUpsertOne) UpdateCreated() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateCreated() + }) +} + +// ClearCreated clears the value of the "created" field. +func (u *UserTenantUpsertOne) ClearCreated() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.ClearCreated() + }) +} + +// SetModified sets the "modified" field. +func (u *UserTenantUpsertOne) SetModified(v time.Time) *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.SetModified(v) + }) +} + +// UpdateModified sets the "modified" field to the value that was provided on create. +func (u *UserTenantUpsertOne) UpdateModified() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateModified() + }) +} + +// ClearModified clears the value of the "modified" field. +func (u *UserTenantUpsertOne) ClearModified() *UserTenantUpsertOne { + return u.Update(func(s *UserTenantUpsert) { + s.ClearModified() + }) +} + +// Exec executes the query. +func (u *UserTenantUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserTenantCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserTenantUpsertOne) 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 *UserTenantUpsertOne) ID(ctx context.Context) (id int, 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 *UserTenantUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// UserTenantCreateBulk is the builder for creating many UserTenant entities in bulk. +type UserTenantCreateBulk struct { + config + err error + builders []*UserTenantCreate + conflict []sql.ConflictOption +} + +// Save creates the UserTenant entities in the database. +func (utcb *UserTenantCreateBulk) Save(ctx context.Context) ([]*UserTenant, error) { + if utcb.err != nil { + return nil, utcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(utcb.builders)) + nodes := make([]*UserTenant, len(utcb.builders)) + mutators := make([]Mutator, len(utcb.builders)) + for i := range utcb.builders { + func(i int, root context.Context) { + builder := utcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserTenantMutation) + 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, utcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = utcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, utcb.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 = int(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, utcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (utcb *UserTenantCreateBulk) SaveX(ctx context.Context) []*UserTenant { + v, err := utcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (utcb *UserTenantCreateBulk) Exec(ctx context.Context) error { + _, err := utcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (utcb *UserTenantCreateBulk) ExecX(ctx context.Context) { + if err := utcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.UserTenant.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.UserTenantUpsert) { +// SetUserID(v+v). +// }). +// Exec(ctx) +func (utcb *UserTenantCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserTenantUpsertBulk { + utcb.conflict = opts + return &UserTenantUpsertBulk{ + create: utcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.UserTenant.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (utcb *UserTenantCreateBulk) OnConflictColumns(columns ...string) *UserTenantUpsertBulk { + utcb.conflict = append(utcb.conflict, sql.ConflictColumns(columns...)) + return &UserTenantUpsertBulk{ + create: utcb, + } +} + +// UserTenantUpsertBulk is the builder for "upsert"-ing +// a bulk of UserTenant nodes. +type UserTenantUpsertBulk struct { + create *UserTenantCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.UserTenant.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *UserTenantUpsertBulk) UpdateNewValues() *UserTenantUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.UserTenant.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *UserTenantUpsertBulk) Ignore() *UserTenantUpsertBulk { + 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 *UserTenantUpsertBulk) DoNothing() *UserTenantUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the UserTenantCreateBulk.OnConflict +// documentation for more info. +func (u *UserTenantUpsertBulk) Update(set func(*UserTenantUpsert)) *UserTenantUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&UserTenantUpsert{UpdateSet: update}) + })) + return u +} + +// SetUserID sets the "user_id" field. +func (u *UserTenantUpsertBulk) SetUserID(v string) *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.SetUserID(v) + }) +} + +// UpdateUserID sets the "user_id" field to the value that was provided on create. +func (u *UserTenantUpsertBulk) UpdateUserID() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateUserID() + }) +} + +// SetTenantID sets the "tenant_id" field. +func (u *UserTenantUpsertBulk) SetTenantID(v int) *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.SetTenantID(v) + }) +} + +// UpdateTenantID sets the "tenant_id" field to the value that was provided on create. +func (u *UserTenantUpsertBulk) UpdateTenantID() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateTenantID() + }) +} + +// SetRole sets the "role" field. +func (u *UserTenantUpsertBulk) SetRole(v usertenant.Role) *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.SetRole(v) + }) +} + +// UpdateRole sets the "role" field to the value that was provided on create. +func (u *UserTenantUpsertBulk) UpdateRole() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateRole() + }) +} + +// SetIsDefault sets the "is_default" field. +func (u *UserTenantUpsertBulk) SetIsDefault(v bool) *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.SetIsDefault(v) + }) +} + +// UpdateIsDefault sets the "is_default" field to the value that was provided on create. +func (u *UserTenantUpsertBulk) UpdateIsDefault() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateIsDefault() + }) +} + +// SetCreated sets the "created" field. +func (u *UserTenantUpsertBulk) SetCreated(v time.Time) *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.SetCreated(v) + }) +} + +// UpdateCreated sets the "created" field to the value that was provided on create. +func (u *UserTenantUpsertBulk) UpdateCreated() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateCreated() + }) +} + +// ClearCreated clears the value of the "created" field. +func (u *UserTenantUpsertBulk) ClearCreated() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.ClearCreated() + }) +} + +// SetModified sets the "modified" field. +func (u *UserTenantUpsertBulk) SetModified(v time.Time) *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.SetModified(v) + }) +} + +// UpdateModified sets the "modified" field to the value that was provided on create. +func (u *UserTenantUpsertBulk) UpdateModified() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.UpdateModified() + }) +} + +// ClearModified clears the value of the "modified" field. +func (u *UserTenantUpsertBulk) ClearModified() *UserTenantUpsertBulk { + return u.Update(func(s *UserTenantUpsert) { + s.ClearModified() + }) +} + +// Exec executes the query. +func (u *UserTenantUpsertBulk) 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 UserTenantCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for UserTenantCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *UserTenantUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/usertenant_delete.go b/usertenant_delete.go new file mode 100644 index 0000000..3b99450 --- /dev/null +++ b/usertenant_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/predicate" + "github.com/open-uem/ent/usertenant" +) + +// UserTenantDelete is the builder for deleting a UserTenant entity. +type UserTenantDelete struct { + config + hooks []Hook + mutation *UserTenantMutation +} + +// Where appends a list predicates to the UserTenantDelete builder. +func (utd *UserTenantDelete) Where(ps ...predicate.UserTenant) *UserTenantDelete { + utd.mutation.Where(ps...) + return utd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (utd *UserTenantDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, utd.sqlExec, utd.mutation, utd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (utd *UserTenantDelete) ExecX(ctx context.Context) int { + n, err := utd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (utd *UserTenantDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(usertenant.Table, sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt)) + if ps := utd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, utd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + utd.mutation.done = true + return affected, err +} + +// UserTenantDeleteOne is the builder for deleting a single UserTenant entity. +type UserTenantDeleteOne struct { + utd *UserTenantDelete +} + +// Where appends a list predicates to the UserTenantDelete builder. +func (utdo *UserTenantDeleteOne) Where(ps ...predicate.UserTenant) *UserTenantDeleteOne { + utdo.utd.mutation.Where(ps...) + return utdo +} + +// Exec executes the deletion query. +func (utdo *UserTenantDeleteOne) Exec(ctx context.Context) error { + n, err := utdo.utd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{usertenant.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (utdo *UserTenantDeleteOne) ExecX(ctx context.Context) { + if err := utdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/usertenant_query.go b/usertenant_query.go new file mode 100644 index 0000000..f9686cd --- /dev/null +++ b/usertenant_query.go @@ -0,0 +1,704 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/open-uem/ent/predicate" + "github.com/open-uem/ent/tenant" + "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" +) + +// UserTenantQuery is the builder for querying UserTenant entities. +type UserTenantQuery struct { + config + ctx *QueryContext + order []usertenant.OrderOption + inters []Interceptor + predicates []predicate.UserTenant + withUser *UserQuery + withTenant *TenantQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserTenantQuery builder. +func (utq *UserTenantQuery) Where(ps ...predicate.UserTenant) *UserTenantQuery { + utq.predicates = append(utq.predicates, ps...) + return utq +} + +// Limit the number of records to be returned by this query. +func (utq *UserTenantQuery) Limit(limit int) *UserTenantQuery { + utq.ctx.Limit = &limit + return utq +} + +// Offset to start from. +func (utq *UserTenantQuery) Offset(offset int) *UserTenantQuery { + utq.ctx.Offset = &offset + return utq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (utq *UserTenantQuery) Unique(unique bool) *UserTenantQuery { + utq.ctx.Unique = &unique + return utq +} + +// Order specifies how the records should be ordered. +func (utq *UserTenantQuery) Order(o ...usertenant.OrderOption) *UserTenantQuery { + utq.order = append(utq.order, o...) + return utq +} + +// QueryUser chains the current query on the "user" edge. +func (utq *UserTenantQuery) QueryUser() *UserQuery { + query := (&UserClient{config: utq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := utq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := utq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(usertenant.Table, usertenant.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, usertenant.UserTable, usertenant.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(utq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTenant chains the current query on the "tenant" edge. +func (utq *UserTenantQuery) QueryTenant() *TenantQuery { + query := (&TenantClient{config: utq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := utq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := utq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(usertenant.Table, usertenant.FieldID, selector), + sqlgraph.To(tenant.Table, tenant.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, usertenant.TenantTable, usertenant.TenantColumn), + ) + fromU = sqlgraph.SetNeighbors(utq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first UserTenant entity from the query. +// Returns a *NotFoundError when no UserTenant was found. +func (utq *UserTenantQuery) First(ctx context.Context) (*UserTenant, error) { + nodes, err := utq.Limit(1).All(setContextOp(ctx, utq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{usertenant.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (utq *UserTenantQuery) FirstX(ctx context.Context) *UserTenant { + node, err := utq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserTenant ID from the query. +// Returns a *NotFoundError when no UserTenant ID was found. +func (utq *UserTenantQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = utq.Limit(1).IDs(setContextOp(ctx, utq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{usertenant.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (utq *UserTenantQuery) FirstIDX(ctx context.Context) int { + id, err := utq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserTenant entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserTenant entity is found. +// Returns a *NotFoundError when no UserTenant entities are found. +func (utq *UserTenantQuery) Only(ctx context.Context) (*UserTenant, error) { + nodes, err := utq.Limit(2).All(setContextOp(ctx, utq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{usertenant.Label} + default: + return nil, &NotSingularError{usertenant.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (utq *UserTenantQuery) OnlyX(ctx context.Context) *UserTenant { + node, err := utq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserTenant ID in the query. +// Returns a *NotSingularError when more than one UserTenant ID is found. +// Returns a *NotFoundError when no entities are found. +func (utq *UserTenantQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = utq.Limit(2).IDs(setContextOp(ctx, utq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{usertenant.Label} + default: + err = &NotSingularError{usertenant.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (utq *UserTenantQuery) OnlyIDX(ctx context.Context) int { + id, err := utq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserTenants. +func (utq *UserTenantQuery) All(ctx context.Context) ([]*UserTenant, error) { + ctx = setContextOp(ctx, utq.ctx, ent.OpQueryAll) + if err := utq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserTenant, *UserTenantQuery]() + return withInterceptors[[]*UserTenant](ctx, utq, qr, utq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (utq *UserTenantQuery) AllX(ctx context.Context) []*UserTenant { + nodes, err := utq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserTenant IDs. +func (utq *UserTenantQuery) IDs(ctx context.Context) (ids []int, err error) { + if utq.ctx.Unique == nil && utq.path != nil { + utq.Unique(true) + } + ctx = setContextOp(ctx, utq.ctx, ent.OpQueryIDs) + if err = utq.Select(usertenant.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (utq *UserTenantQuery) IDsX(ctx context.Context) []int { + ids, err := utq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (utq *UserTenantQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, utq.ctx, ent.OpQueryCount) + if err := utq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, utq, querierCount[*UserTenantQuery](), utq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (utq *UserTenantQuery) CountX(ctx context.Context) int { + count, err := utq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (utq *UserTenantQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, utq.ctx, ent.OpQueryExist) + switch _, err := utq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (utq *UserTenantQuery) ExistX(ctx context.Context) bool { + exist, err := utq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserTenantQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (utq *UserTenantQuery) Clone() *UserTenantQuery { + if utq == nil { + return nil + } + return &UserTenantQuery{ + config: utq.config, + ctx: utq.ctx.Clone(), + order: append([]usertenant.OrderOption{}, utq.order...), + inters: append([]Interceptor{}, utq.inters...), + predicates: append([]predicate.UserTenant{}, utq.predicates...), + withUser: utq.withUser.Clone(), + withTenant: utq.withTenant.Clone(), + // clone intermediate query. + sql: utq.sql.Clone(), + path: utq.path, + modifiers: append([]func(*sql.Selector){}, utq.modifiers...), + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (utq *UserTenantQuery) WithUser(opts ...func(*UserQuery)) *UserTenantQuery { + query := (&UserClient{config: utq.config}).Query() + for _, opt := range opts { + opt(query) + } + utq.withUser = query + return utq +} + +// WithTenant tells the query-builder to eager-load the nodes that are connected to +// the "tenant" edge. The optional arguments are used to configure the query builder of the edge. +func (utq *UserTenantQuery) WithTenant(opts ...func(*TenantQuery)) *UserTenantQuery { + query := (&TenantClient{config: utq.config}).Query() + for _, opt := range opts { + opt(query) + } + utq.withTenant = query + return utq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// UserID string `json:"user_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.UserTenant.Query(). +// GroupBy(usertenant.FieldUserID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (utq *UserTenantQuery) GroupBy(field string, fields ...string) *UserTenantGroupBy { + utq.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserTenantGroupBy{build: utq} + grbuild.flds = &utq.ctx.Fields + grbuild.label = usertenant.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// UserID string `json:"user_id,omitempty"` +// } +// +// client.UserTenant.Query(). +// Select(usertenant.FieldUserID). +// Scan(ctx, &v) +func (utq *UserTenantQuery) Select(fields ...string) *UserTenantSelect { + utq.ctx.Fields = append(utq.ctx.Fields, fields...) + sbuild := &UserTenantSelect{UserTenantQuery: utq} + sbuild.label = usertenant.Label + sbuild.flds, sbuild.scan = &utq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserTenantSelect configured with the given aggregations. +func (utq *UserTenantQuery) Aggregate(fns ...AggregateFunc) *UserTenantSelect { + return utq.Select().Aggregate(fns...) +} + +func (utq *UserTenantQuery) prepareQuery(ctx context.Context) error { + for _, inter := range utq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, utq); err != nil { + return err + } + } + } + for _, f := range utq.ctx.Fields { + if !usertenant.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if utq.path != nil { + prev, err := utq.path(ctx) + if err != nil { + return err + } + utq.sql = prev + } + return nil +} + +func (utq *UserTenantQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserTenant, error) { + var ( + nodes = []*UserTenant{} + _spec = utq.querySpec() + loadedTypes = [2]bool{ + utq.withUser != nil, + utq.withTenant != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserTenant).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserTenant{config: utq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(utq.modifiers) > 0 { + _spec.Modifiers = utq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, utq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := utq.withUser; query != nil { + if err := utq.loadUser(ctx, query, nodes, nil, + func(n *UserTenant, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + if query := utq.withTenant; query != nil { + if err := utq.loadTenant(ctx, query, nodes, nil, + func(n *UserTenant, e *Tenant) { n.Edges.Tenant = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (utq *UserTenantQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserTenant, init func(*UserTenant), assign func(*UserTenant, *User)) error { + ids := make([]string, 0, len(nodes)) + nodeids := make(map[string][]*UserTenant) + for i := range nodes { + fk := nodes[i].UserID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (utq *UserTenantQuery) loadTenant(ctx context.Context, query *TenantQuery, nodes []*UserTenant, init func(*UserTenant), assign func(*UserTenant, *Tenant)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*UserTenant) + for i := range nodes { + fk := nodes[i].TenantID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(tenant.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "tenant_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (utq *UserTenantQuery) sqlCount(ctx context.Context) (int, error) { + _spec := utq.querySpec() + if len(utq.modifiers) > 0 { + _spec.Modifiers = utq.modifiers + } + _spec.Node.Columns = utq.ctx.Fields + if len(utq.ctx.Fields) > 0 { + _spec.Unique = utq.ctx.Unique != nil && *utq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, utq.driver, _spec) +} + +func (utq *UserTenantQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(usertenant.Table, usertenant.Columns, sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt)) + _spec.From = utq.sql + if unique := utq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if utq.path != nil { + _spec.Unique = true + } + if fields := utq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, usertenant.FieldID) + for i := range fields { + if fields[i] != usertenant.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if utq.withUser != nil { + _spec.Node.AddColumnOnce(usertenant.FieldUserID) + } + if utq.withTenant != nil { + _spec.Node.AddColumnOnce(usertenant.FieldTenantID) + } + } + if ps := utq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := utq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := utq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := utq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (utq *UserTenantQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(utq.driver.Dialect()) + t1 := builder.Table(usertenant.Table) + columns := utq.ctx.Fields + if len(columns) == 0 { + columns = usertenant.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if utq.sql != nil { + selector = utq.sql + selector.Select(selector.Columns(columns...)...) + } + if utq.ctx.Unique != nil && *utq.ctx.Unique { + selector.Distinct() + } + for _, m := range utq.modifiers { + m(selector) + } + for _, p := range utq.predicates { + p(selector) + } + for _, p := range utq.order { + p(selector) + } + if offset := utq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := utq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (utq *UserTenantQuery) Modify(modifiers ...func(s *sql.Selector)) *UserTenantSelect { + utq.modifiers = append(utq.modifiers, modifiers...) + return utq.Select() +} + +// UserTenantGroupBy is the group-by builder for UserTenant entities. +type UserTenantGroupBy struct { + selector + build *UserTenantQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (utgb *UserTenantGroupBy) Aggregate(fns ...AggregateFunc) *UserTenantGroupBy { + utgb.fns = append(utgb.fns, fns...) + return utgb +} + +// Scan applies the selector query and scans the result into the given value. +func (utgb *UserTenantGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, utgb.build.ctx, ent.OpQueryGroupBy) + if err := utgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserTenantQuery, *UserTenantGroupBy](ctx, utgb.build, utgb, utgb.build.inters, v) +} + +func (utgb *UserTenantGroupBy) sqlScan(ctx context.Context, root *UserTenantQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(utgb.fns)) + for _, fn := range utgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*utgb.flds)+len(utgb.fns)) + for _, f := range *utgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*utgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := utgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserTenantSelect is the builder for selecting fields of UserTenant entities. +type UserTenantSelect struct { + *UserTenantQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (uts *UserTenantSelect) Aggregate(fns ...AggregateFunc) *UserTenantSelect { + uts.fns = append(uts.fns, fns...) + return uts +} + +// Scan applies the selector query and scans the result into the given value. +func (uts *UserTenantSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, uts.ctx, ent.OpQuerySelect) + if err := uts.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserTenantQuery, *UserTenantSelect](ctx, uts.UserTenantQuery, uts, uts.inters, v) +} + +func (uts *UserTenantSelect) sqlScan(ctx context.Context, root *UserTenantQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(uts.fns)) + for _, fn := range uts.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*uts.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := uts.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (uts *UserTenantSelect) Modify(modifiers ...func(s *sql.Selector)) *UserTenantSelect { + uts.modifiers = append(uts.modifiers, modifiers...) + return uts +} diff --git a/usertenant_update.go b/usertenant_update.go new file mode 100644 index 0000000..f2f7141 --- /dev/null +++ b/usertenant_update.go @@ -0,0 +1,632 @@ +// 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/open-uem/ent/predicate" + "github.com/open-uem/ent/tenant" + "github.com/open-uem/ent/user" + "github.com/open-uem/ent/usertenant" +) + +// UserTenantUpdate is the builder for updating UserTenant entities. +type UserTenantUpdate struct { + config + hooks []Hook + mutation *UserTenantMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserTenantUpdate builder. +func (utu *UserTenantUpdate) Where(ps ...predicate.UserTenant) *UserTenantUpdate { + utu.mutation.Where(ps...) + return utu +} + +// SetUserID sets the "user_id" field. +func (utu *UserTenantUpdate) SetUserID(s string) *UserTenantUpdate { + utu.mutation.SetUserID(s) + return utu +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (utu *UserTenantUpdate) SetNillableUserID(s *string) *UserTenantUpdate { + if s != nil { + utu.SetUserID(*s) + } + return utu +} + +// SetTenantID sets the "tenant_id" field. +func (utu *UserTenantUpdate) SetTenantID(i int) *UserTenantUpdate { + utu.mutation.SetTenantID(i) + return utu +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (utu *UserTenantUpdate) SetNillableTenantID(i *int) *UserTenantUpdate { + if i != nil { + utu.SetTenantID(*i) + } + return utu +} + +// SetRole sets the "role" field. +func (utu *UserTenantUpdate) SetRole(u usertenant.Role) *UserTenantUpdate { + utu.mutation.SetRole(u) + return utu +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (utu *UserTenantUpdate) SetNillableRole(u *usertenant.Role) *UserTenantUpdate { + if u != nil { + utu.SetRole(*u) + } + return utu +} + +// SetIsDefault sets the "is_default" field. +func (utu *UserTenantUpdate) SetIsDefault(b bool) *UserTenantUpdate { + utu.mutation.SetIsDefault(b) + return utu +} + +// SetNillableIsDefault sets the "is_default" field if the given value is not nil. +func (utu *UserTenantUpdate) SetNillableIsDefault(b *bool) *UserTenantUpdate { + if b != nil { + utu.SetIsDefault(*b) + } + return utu +} + +// SetCreated sets the "created" field. +func (utu *UserTenantUpdate) SetCreated(t time.Time) *UserTenantUpdate { + utu.mutation.SetCreated(t) + return utu +} + +// SetNillableCreated sets the "created" field if the given value is not nil. +func (utu *UserTenantUpdate) SetNillableCreated(t *time.Time) *UserTenantUpdate { + if t != nil { + utu.SetCreated(*t) + } + return utu +} + +// ClearCreated clears the value of the "created" field. +func (utu *UserTenantUpdate) ClearCreated() *UserTenantUpdate { + utu.mutation.ClearCreated() + return utu +} + +// SetModified sets the "modified" field. +func (utu *UserTenantUpdate) SetModified(t time.Time) *UserTenantUpdate { + utu.mutation.SetModified(t) + return utu +} + +// ClearModified clears the value of the "modified" field. +func (utu *UserTenantUpdate) ClearModified() *UserTenantUpdate { + utu.mutation.ClearModified() + return utu +} + +// SetUser sets the "user" edge to the User entity. +func (utu *UserTenantUpdate) SetUser(u *User) *UserTenantUpdate { + return utu.SetUserID(u.ID) +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (utu *UserTenantUpdate) SetTenant(t *Tenant) *UserTenantUpdate { + return utu.SetTenantID(t.ID) +} + +// Mutation returns the UserTenantMutation object of the builder. +func (utu *UserTenantUpdate) Mutation() *UserTenantMutation { + return utu.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (utu *UserTenantUpdate) ClearUser() *UserTenantUpdate { + utu.mutation.ClearUser() + return utu +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (utu *UserTenantUpdate) ClearTenant() *UserTenantUpdate { + utu.mutation.ClearTenant() + return utu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (utu *UserTenantUpdate) Save(ctx context.Context) (int, error) { + utu.defaults() + return withHooks(ctx, utu.sqlSave, utu.mutation, utu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (utu *UserTenantUpdate) SaveX(ctx context.Context) int { + affected, err := utu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (utu *UserTenantUpdate) Exec(ctx context.Context) error { + _, err := utu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (utu *UserTenantUpdate) ExecX(ctx context.Context) { + if err := utu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (utu *UserTenantUpdate) defaults() { + if _, ok := utu.mutation.Modified(); !ok && !utu.mutation.ModifiedCleared() { + v := usertenant.UpdateDefaultModified() + utu.mutation.SetModified(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (utu *UserTenantUpdate) check() error { + if v, ok := utu.mutation.UserID(); ok { + if err := usertenant.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserTenant.user_id": %w`, err)} + } + } + if v, ok := utu.mutation.Role(); ok { + if err := usertenant.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "UserTenant.role": %w`, err)} + } + } + if utu.mutation.UserCleared() && len(utu.mutation.UserIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserTenant.user"`) + } + if utu.mutation.TenantCleared() && len(utu.mutation.TenantIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserTenant.tenant"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (utu *UserTenantUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserTenantUpdate { + utu.modifiers = append(utu.modifiers, modifiers...) + return utu +} + +func (utu *UserTenantUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := utu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(usertenant.Table, usertenant.Columns, sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt)) + if ps := utu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := utu.mutation.Role(); ok { + _spec.SetField(usertenant.FieldRole, field.TypeEnum, value) + } + if value, ok := utu.mutation.IsDefault(); ok { + _spec.SetField(usertenant.FieldIsDefault, field.TypeBool, value) + } + if value, ok := utu.mutation.Created(); ok { + _spec.SetField(usertenant.FieldCreated, field.TypeTime, value) + } + if utu.mutation.CreatedCleared() { + _spec.ClearField(usertenant.FieldCreated, field.TypeTime) + } + if value, ok := utu.mutation.Modified(); ok { + _spec.SetField(usertenant.FieldModified, field.TypeTime, value) + } + if utu.mutation.ModifiedCleared() { + _spec.ClearField(usertenant.FieldModified, field.TypeTime) + } + if utu.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.UserTable, + Columns: []string{usertenant.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := utu.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.UserTable, + Columns: []string{usertenant.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if utu.mutation.TenantCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.TenantTable, + Columns: []string{usertenant.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := utu.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.TenantTable, + Columns: []string{usertenant.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(utu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, utu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usertenant.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + utu.mutation.done = true + return n, nil +} + +// UserTenantUpdateOne is the builder for updating a single UserTenant entity. +type UserTenantUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserTenantMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUserID sets the "user_id" field. +func (utuo *UserTenantUpdateOne) SetUserID(s string) *UserTenantUpdateOne { + utuo.mutation.SetUserID(s) + return utuo +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (utuo *UserTenantUpdateOne) SetNillableUserID(s *string) *UserTenantUpdateOne { + if s != nil { + utuo.SetUserID(*s) + } + return utuo +} + +// SetTenantID sets the "tenant_id" field. +func (utuo *UserTenantUpdateOne) SetTenantID(i int) *UserTenantUpdateOne { + utuo.mutation.SetTenantID(i) + return utuo +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (utuo *UserTenantUpdateOne) SetNillableTenantID(i *int) *UserTenantUpdateOne { + if i != nil { + utuo.SetTenantID(*i) + } + return utuo +} + +// SetRole sets the "role" field. +func (utuo *UserTenantUpdateOne) SetRole(u usertenant.Role) *UserTenantUpdateOne { + utuo.mutation.SetRole(u) + return utuo +} + +// SetNillableRole sets the "role" field if the given value is not nil. +func (utuo *UserTenantUpdateOne) SetNillableRole(u *usertenant.Role) *UserTenantUpdateOne { + if u != nil { + utuo.SetRole(*u) + } + return utuo +} + +// SetIsDefault sets the "is_default" field. +func (utuo *UserTenantUpdateOne) SetIsDefault(b bool) *UserTenantUpdateOne { + utuo.mutation.SetIsDefault(b) + return utuo +} + +// SetNillableIsDefault sets the "is_default" field if the given value is not nil. +func (utuo *UserTenantUpdateOne) SetNillableIsDefault(b *bool) *UserTenantUpdateOne { + if b != nil { + utuo.SetIsDefault(*b) + } + return utuo +} + +// SetCreated sets the "created" field. +func (utuo *UserTenantUpdateOne) SetCreated(t time.Time) *UserTenantUpdateOne { + utuo.mutation.SetCreated(t) + return utuo +} + +// SetNillableCreated sets the "created" field if the given value is not nil. +func (utuo *UserTenantUpdateOne) SetNillableCreated(t *time.Time) *UserTenantUpdateOne { + if t != nil { + utuo.SetCreated(*t) + } + return utuo +} + +// ClearCreated clears the value of the "created" field. +func (utuo *UserTenantUpdateOne) ClearCreated() *UserTenantUpdateOne { + utuo.mutation.ClearCreated() + return utuo +} + +// SetModified sets the "modified" field. +func (utuo *UserTenantUpdateOne) SetModified(t time.Time) *UserTenantUpdateOne { + utuo.mutation.SetModified(t) + return utuo +} + +// ClearModified clears the value of the "modified" field. +func (utuo *UserTenantUpdateOne) ClearModified() *UserTenantUpdateOne { + utuo.mutation.ClearModified() + return utuo +} + +// SetUser sets the "user" edge to the User entity. +func (utuo *UserTenantUpdateOne) SetUser(u *User) *UserTenantUpdateOne { + return utuo.SetUserID(u.ID) +} + +// SetTenant sets the "tenant" edge to the Tenant entity. +func (utuo *UserTenantUpdateOne) SetTenant(t *Tenant) *UserTenantUpdateOne { + return utuo.SetTenantID(t.ID) +} + +// Mutation returns the UserTenantMutation object of the builder. +func (utuo *UserTenantUpdateOne) Mutation() *UserTenantMutation { + return utuo.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (utuo *UserTenantUpdateOne) ClearUser() *UserTenantUpdateOne { + utuo.mutation.ClearUser() + return utuo +} + +// ClearTenant clears the "tenant" edge to the Tenant entity. +func (utuo *UserTenantUpdateOne) ClearTenant() *UserTenantUpdateOne { + utuo.mutation.ClearTenant() + return utuo +} + +// Where appends a list predicates to the UserTenantUpdate builder. +func (utuo *UserTenantUpdateOne) Where(ps ...predicate.UserTenant) *UserTenantUpdateOne { + utuo.mutation.Where(ps...) + return utuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (utuo *UserTenantUpdateOne) Select(field string, fields ...string) *UserTenantUpdateOne { + utuo.fields = append([]string{field}, fields...) + return utuo +} + +// Save executes the query and returns the updated UserTenant entity. +func (utuo *UserTenantUpdateOne) Save(ctx context.Context) (*UserTenant, error) { + utuo.defaults() + return withHooks(ctx, utuo.sqlSave, utuo.mutation, utuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (utuo *UserTenantUpdateOne) SaveX(ctx context.Context) *UserTenant { + node, err := utuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (utuo *UserTenantUpdateOne) Exec(ctx context.Context) error { + _, err := utuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (utuo *UserTenantUpdateOne) ExecX(ctx context.Context) { + if err := utuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (utuo *UserTenantUpdateOne) defaults() { + if _, ok := utuo.mutation.Modified(); !ok && !utuo.mutation.ModifiedCleared() { + v := usertenant.UpdateDefaultModified() + utuo.mutation.SetModified(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (utuo *UserTenantUpdateOne) check() error { + if v, ok := utuo.mutation.UserID(); ok { + if err := usertenant.UserIDValidator(v); err != nil { + return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserTenant.user_id": %w`, err)} + } + } + if v, ok := utuo.mutation.Role(); ok { + if err := usertenant.RoleValidator(v); err != nil { + return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "UserTenant.role": %w`, err)} + } + } + if utuo.mutation.UserCleared() && len(utuo.mutation.UserIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserTenant.user"`) + } + if utuo.mutation.TenantCleared() && len(utuo.mutation.TenantIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserTenant.tenant"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (utuo *UserTenantUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserTenantUpdateOne { + utuo.modifiers = append(utuo.modifiers, modifiers...) + return utuo +} + +func (utuo *UserTenantUpdateOne) sqlSave(ctx context.Context) (_node *UserTenant, err error) { + if err := utuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(usertenant.Table, usertenant.Columns, sqlgraph.NewFieldSpec(usertenant.FieldID, field.TypeInt)) + id, ok := utuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserTenant.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := utuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, usertenant.FieldID) + for _, f := range fields { + if !usertenant.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != usertenant.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := utuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := utuo.mutation.Role(); ok { + _spec.SetField(usertenant.FieldRole, field.TypeEnum, value) + } + if value, ok := utuo.mutation.IsDefault(); ok { + _spec.SetField(usertenant.FieldIsDefault, field.TypeBool, value) + } + if value, ok := utuo.mutation.Created(); ok { + _spec.SetField(usertenant.FieldCreated, field.TypeTime, value) + } + if utuo.mutation.CreatedCleared() { + _spec.ClearField(usertenant.FieldCreated, field.TypeTime) + } + if value, ok := utuo.mutation.Modified(); ok { + _spec.SetField(usertenant.FieldModified, field.TypeTime, value) + } + if utuo.mutation.ModifiedCleared() { + _spec.ClearField(usertenant.FieldModified, field.TypeTime) + } + if utuo.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.UserTable, + Columns: []string{usertenant.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := utuo.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.UserTable, + Columns: []string{usertenant.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeString), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if utuo.mutation.TenantCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.TenantTable, + Columns: []string{usertenant.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := utuo.mutation.TenantIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: usertenant.TenantTable, + Columns: []string{usertenant.TenantColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(tenant.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(utuo.modifiers...) + _node = &UserTenant{config: utuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, utuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{usertenant.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + utuo.mutation.done = true + return _node, nil +}