Files
unR2/internal/ent/mutation.go
2025-07-19 02:03:24 +08:00

1995 lines
61 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"sync"
"time"
"unR2/internal/ent/cloudflareaccounts"
"unR2/internal/ent/cloudflarer2"
"unR2/internal/ent/predicate"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
const (
// Operation types.
OpCreate = ent.OpCreate
OpDelete = ent.OpDelete
OpDeleteOne = ent.OpDeleteOne
OpUpdate = ent.OpUpdate
OpUpdateOne = ent.OpUpdateOne
// Node types.
TypeCloudflareAccounts = "CloudflareAccounts"
TypeCloudflareR2 = "CloudflareR2"
)
// CloudflareAccountsMutation represents an operation that mutates the CloudflareAccounts nodes in the graph.
type CloudflareAccountsMutation struct {
config
op Op
typ string
id *int
name *string
account_id *string
api_token *string
email *string
status *int8
addstatus *int8
remark *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
cloudflare_buckets map[int]struct{}
removedcloudflare_buckets map[int]struct{}
clearedcloudflare_buckets bool
done bool
oldValue func(context.Context) (*CloudflareAccounts, error)
predicates []predicate.CloudflareAccounts
}
var _ ent.Mutation = (*CloudflareAccountsMutation)(nil)
// cloudflareaccountsOption allows management of the mutation configuration using functional options.
type cloudflareaccountsOption func(*CloudflareAccountsMutation)
// newCloudflareAccountsMutation creates new mutation for the CloudflareAccounts entity.
func newCloudflareAccountsMutation(c config, op Op, opts ...cloudflareaccountsOption) *CloudflareAccountsMutation {
m := &CloudflareAccountsMutation{
config: c,
op: op,
typ: TypeCloudflareAccounts,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withCloudflareAccountsID sets the ID field of the mutation.
func withCloudflareAccountsID(id int) cloudflareaccountsOption {
return func(m *CloudflareAccountsMutation) {
var (
err error
once sync.Once
value *CloudflareAccounts
)
m.oldValue = func(ctx context.Context) (*CloudflareAccounts, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().CloudflareAccounts.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withCloudflareAccounts sets the old CloudflareAccounts of the mutation.
func withCloudflareAccounts(node *CloudflareAccounts) cloudflareaccountsOption {
return func(m *CloudflareAccountsMutation) {
m.oldValue = func(context.Context) (*CloudflareAccounts, 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 CloudflareAccountsMutation) 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 CloudflareAccountsMutation) 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 *CloudflareAccountsMutation) 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 *CloudflareAccountsMutation) 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().CloudflareAccounts.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 *CloudflareAccountsMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *CloudflareAccountsMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) 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
}
// ResetName resets all changes to the "name" field.
func (m *CloudflareAccountsMutation) ResetName() {
m.name = nil
}
// SetAccountID sets the "account_id" field.
func (m *CloudflareAccountsMutation) SetAccountID(s string) {
m.account_id = &s
}
// AccountID returns the value of the "account_id" field in the mutation.
func (m *CloudflareAccountsMutation) AccountID() (r string, exists bool) {
v := m.account_id
if v == nil {
return
}
return *v, true
}
// OldAccountID returns the old "account_id" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldAccountID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAccountID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
}
return oldValue.AccountID, nil
}
// ResetAccountID resets all changes to the "account_id" field.
func (m *CloudflareAccountsMutation) ResetAccountID() {
m.account_id = nil
}
// SetAPIToken sets the "api_token" field.
func (m *CloudflareAccountsMutation) SetAPIToken(s string) {
m.api_token = &s
}
// APIToken returns the value of the "api_token" field in the mutation.
func (m *CloudflareAccountsMutation) APIToken() (r string, exists bool) {
v := m.api_token
if v == nil {
return
}
return *v, true
}
// OldAPIToken returns the old "api_token" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldAPIToken(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAPIToken is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAPIToken requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAPIToken: %w", err)
}
return oldValue.APIToken, nil
}
// ResetAPIToken resets all changes to the "api_token" field.
func (m *CloudflareAccountsMutation) ResetAPIToken() {
m.api_token = nil
}
// SetEmail sets the "email" field.
func (m *CloudflareAccountsMutation) SetEmail(s string) {
m.email = &s
}
// Email returns the value of the "email" field in the mutation.
func (m *CloudflareAccountsMutation) Email() (r string, exists bool) {
v := m.email
if v == nil {
return
}
return *v, true
}
// OldEmail returns the old "email" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldEmail(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldEmail 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")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEmail: %w", err)
}
return oldValue.Email, nil
}
// ClearEmail clears the value of the "email" field.
func (m *CloudflareAccountsMutation) ClearEmail() {
m.email = nil
m.clearedFields[cloudflareaccounts.FieldEmail] = struct{}{}
}
// EmailCleared returns if the "email" field was cleared in this mutation.
func (m *CloudflareAccountsMutation) EmailCleared() bool {
_, ok := m.clearedFields[cloudflareaccounts.FieldEmail]
return ok
}
// ResetEmail resets all changes to the "email" field.
func (m *CloudflareAccountsMutation) ResetEmail() {
m.email = nil
delete(m.clearedFields, cloudflareaccounts.FieldEmail)
}
// SetStatus sets the "status" field.
func (m *CloudflareAccountsMutation) SetStatus(i int8) {
m.status = &i
m.addstatus = nil
}
// Status returns the value of the "status" field in the mutation.
func (m *CloudflareAccountsMutation) Status() (r int8, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldStatus(ctx context.Context) (v int8, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// AddStatus adds i to the "status" field.
func (m *CloudflareAccountsMutation) AddStatus(i int8) {
if m.addstatus != nil {
*m.addstatus += i
} else {
m.addstatus = &i
}
}
// AddedStatus returns the value that was added to the "status" field in this mutation.
func (m *CloudflareAccountsMutation) AddedStatus() (r int8, exists bool) {
v := m.addstatus
if v == nil {
return
}
return *v, true
}
// ResetStatus resets all changes to the "status" field.
func (m *CloudflareAccountsMutation) ResetStatus() {
m.status = nil
m.addstatus = nil
}
// SetRemark sets the "remark" field.
func (m *CloudflareAccountsMutation) SetRemark(s string) {
m.remark = &s
}
// Remark returns the value of the "remark" field in the mutation.
func (m *CloudflareAccountsMutation) Remark() (r string, exists bool) {
v := m.remark
if v == nil {
return
}
return *v, true
}
// OldRemark returns the old "remark" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldRemark(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRemark is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRemark requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRemark: %w", err)
}
return oldValue.Remark, nil
}
// ClearRemark clears the value of the "remark" field.
func (m *CloudflareAccountsMutation) ClearRemark() {
m.remark = nil
m.clearedFields[cloudflareaccounts.FieldRemark] = struct{}{}
}
// RemarkCleared returns if the "remark" field was cleared in this mutation.
func (m *CloudflareAccountsMutation) RemarkCleared() bool {
_, ok := m.clearedFields[cloudflareaccounts.FieldRemark]
return ok
}
// ResetRemark resets all changes to the "remark" field.
func (m *CloudflareAccountsMutation) ResetRemark() {
m.remark = nil
delete(m.clearedFields, cloudflareaccounts.FieldRemark)
}
// SetCreatedAt sets the "created_at" field.
func (m *CloudflareAccountsMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *CloudflareAccountsMutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
}
return *v, true
}
// OldCreatedAt returns the old "created_at" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
}
return oldValue.CreatedAt, nil
}
// ResetCreatedAt resets all changes to the "created_at" field.
func (m *CloudflareAccountsMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *CloudflareAccountsMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *CloudflareAccountsMutation) UpdatedAt() (r time.Time, exists bool) {
v := m.updated_at
if v == nil {
return
}
return *v, true
}
// OldUpdatedAt returns the old "updated_at" field's value of the CloudflareAccounts entity.
// If the CloudflareAccounts object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareAccountsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
}
return oldValue.UpdatedAt, nil
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *CloudflareAccountsMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// AddCloudflareBucketIDs adds the "cloudflare_buckets" edge to the CloudflareR2 entity by ids.
func (m *CloudflareAccountsMutation) AddCloudflareBucketIDs(ids ...int) {
if m.cloudflare_buckets == nil {
m.cloudflare_buckets = make(map[int]struct{})
}
for i := range ids {
m.cloudflare_buckets[ids[i]] = struct{}{}
}
}
// ClearCloudflareBuckets clears the "cloudflare_buckets" edge to the CloudflareR2 entity.
func (m *CloudflareAccountsMutation) ClearCloudflareBuckets() {
m.clearedcloudflare_buckets = true
}
// CloudflareBucketsCleared reports if the "cloudflare_buckets" edge to the CloudflareR2 entity was cleared.
func (m *CloudflareAccountsMutation) CloudflareBucketsCleared() bool {
return m.clearedcloudflare_buckets
}
// RemoveCloudflareBucketIDs removes the "cloudflare_buckets" edge to the CloudflareR2 entity by IDs.
func (m *CloudflareAccountsMutation) RemoveCloudflareBucketIDs(ids ...int) {
if m.removedcloudflare_buckets == nil {
m.removedcloudflare_buckets = make(map[int]struct{})
}
for i := range ids {
delete(m.cloudflare_buckets, ids[i])
m.removedcloudflare_buckets[ids[i]] = struct{}{}
}
}
// RemovedCloudflareBuckets returns the removed IDs of the "cloudflare_buckets" edge to the CloudflareR2 entity.
func (m *CloudflareAccountsMutation) RemovedCloudflareBucketsIDs() (ids []int) {
for id := range m.removedcloudflare_buckets {
ids = append(ids, id)
}
return
}
// CloudflareBucketsIDs returns the "cloudflare_buckets" edge IDs in the mutation.
func (m *CloudflareAccountsMutation) CloudflareBucketsIDs() (ids []int) {
for id := range m.cloudflare_buckets {
ids = append(ids, id)
}
return
}
// ResetCloudflareBuckets resets all changes to the "cloudflare_buckets" edge.
func (m *CloudflareAccountsMutation) ResetCloudflareBuckets() {
m.cloudflare_buckets = nil
m.clearedcloudflare_buckets = false
m.removedcloudflare_buckets = nil
}
// Where appends a list predicates to the CloudflareAccountsMutation builder.
func (m *CloudflareAccountsMutation) Where(ps ...predicate.CloudflareAccounts) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the CloudflareAccountsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *CloudflareAccountsMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.CloudflareAccounts, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *CloudflareAccountsMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *CloudflareAccountsMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (CloudflareAccounts).
func (m *CloudflareAccountsMutation) 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 *CloudflareAccountsMutation) Fields() []string {
fields := make([]string, 0, 8)
if m.name != nil {
fields = append(fields, cloudflareaccounts.FieldName)
}
if m.account_id != nil {
fields = append(fields, cloudflareaccounts.FieldAccountID)
}
if m.api_token != nil {
fields = append(fields, cloudflareaccounts.FieldAPIToken)
}
if m.email != nil {
fields = append(fields, cloudflareaccounts.FieldEmail)
}
if m.status != nil {
fields = append(fields, cloudflareaccounts.FieldStatus)
}
if m.remark != nil {
fields = append(fields, cloudflareaccounts.FieldRemark)
}
if m.created_at != nil {
fields = append(fields, cloudflareaccounts.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, cloudflareaccounts.FieldUpdatedAt)
}
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 *CloudflareAccountsMutation) Field(name string) (ent.Value, bool) {
switch name {
case cloudflareaccounts.FieldName:
return m.Name()
case cloudflareaccounts.FieldAccountID:
return m.AccountID()
case cloudflareaccounts.FieldAPIToken:
return m.APIToken()
case cloudflareaccounts.FieldEmail:
return m.Email()
case cloudflareaccounts.FieldStatus:
return m.Status()
case cloudflareaccounts.FieldRemark:
return m.Remark()
case cloudflareaccounts.FieldCreatedAt:
return m.CreatedAt()
case cloudflareaccounts.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *CloudflareAccountsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case cloudflareaccounts.FieldName:
return m.OldName(ctx)
case cloudflareaccounts.FieldAccountID:
return m.OldAccountID(ctx)
case cloudflareaccounts.FieldAPIToken:
return m.OldAPIToken(ctx)
case cloudflareaccounts.FieldEmail:
return m.OldEmail(ctx)
case cloudflareaccounts.FieldStatus:
return m.OldStatus(ctx)
case cloudflareaccounts.FieldRemark:
return m.OldRemark(ctx)
case cloudflareaccounts.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case cloudflareaccounts.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown CloudflareAccounts 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 *CloudflareAccountsMutation) SetField(name string, value ent.Value) error {
switch name {
case cloudflareaccounts.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case cloudflareaccounts.FieldAccountID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAccountID(v)
return nil
case cloudflareaccounts.FieldAPIToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAPIToken(v)
return nil
case cloudflareaccounts.FieldEmail:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEmail(v)
return nil
case cloudflareaccounts.FieldStatus:
v, ok := value.(int8)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case cloudflareaccounts.FieldRemark:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRemark(v)
return nil
case cloudflareaccounts.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
case cloudflareaccounts.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown CloudflareAccounts field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CloudflareAccountsMutation) AddedFields() []string {
var fields []string
if m.addstatus != nil {
fields = append(fields, cloudflareaccounts.FieldStatus)
}
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 *CloudflareAccountsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case cloudflareaccounts.FieldStatus:
return m.AddedStatus()
}
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 *CloudflareAccountsMutation) AddField(name string, value ent.Value) error {
switch name {
case cloudflareaccounts.FieldStatus:
v, ok := value.(int8)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddStatus(v)
return nil
}
return fmt.Errorf("unknown CloudflareAccounts numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CloudflareAccountsMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(cloudflareaccounts.FieldEmail) {
fields = append(fields, cloudflareaccounts.FieldEmail)
}
if m.FieldCleared(cloudflareaccounts.FieldRemark) {
fields = append(fields, cloudflareaccounts.FieldRemark)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CloudflareAccountsMutation) 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 *CloudflareAccountsMutation) ClearField(name string) error {
switch name {
case cloudflareaccounts.FieldEmail:
m.ClearEmail()
return nil
case cloudflareaccounts.FieldRemark:
m.ClearRemark()
return nil
}
return fmt.Errorf("unknown CloudflareAccounts 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 *CloudflareAccountsMutation) ResetField(name string) error {
switch name {
case cloudflareaccounts.FieldName:
m.ResetName()
return nil
case cloudflareaccounts.FieldAccountID:
m.ResetAccountID()
return nil
case cloudflareaccounts.FieldAPIToken:
m.ResetAPIToken()
return nil
case cloudflareaccounts.FieldEmail:
m.ResetEmail()
return nil
case cloudflareaccounts.FieldStatus:
m.ResetStatus()
return nil
case cloudflareaccounts.FieldRemark:
m.ResetRemark()
return nil
case cloudflareaccounts.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case cloudflareaccounts.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown CloudflareAccounts field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CloudflareAccountsMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.cloudflare_buckets != nil {
edges = append(edges, cloudflareaccounts.EdgeCloudflareBuckets)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CloudflareAccountsMutation) AddedIDs(name string) []ent.Value {
switch name {
case cloudflareaccounts.EdgeCloudflareBuckets:
ids := make([]ent.Value, 0, len(m.cloudflare_buckets))
for id := range m.cloudflare_buckets {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CloudflareAccountsMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
if m.removedcloudflare_buckets != nil {
edges = append(edges, cloudflareaccounts.EdgeCloudflareBuckets)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *CloudflareAccountsMutation) RemovedIDs(name string) []ent.Value {
switch name {
case cloudflareaccounts.EdgeCloudflareBuckets:
ids := make([]ent.Value, 0, len(m.removedcloudflare_buckets))
for id := range m.removedcloudflare_buckets {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CloudflareAccountsMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedcloudflare_buckets {
edges = append(edges, cloudflareaccounts.EdgeCloudflareBuckets)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CloudflareAccountsMutation) EdgeCleared(name string) bool {
switch name {
case cloudflareaccounts.EdgeCloudflareBuckets:
return m.clearedcloudflare_buckets
}
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 *CloudflareAccountsMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown CloudflareAccounts 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 *CloudflareAccountsMutation) ResetEdge(name string) error {
switch name {
case cloudflareaccounts.EdgeCloudflareBuckets:
m.ResetCloudflareBuckets()
return nil
}
return fmt.Errorf("unknown CloudflareAccounts edge %s", name)
}
// CloudflareR2Mutation represents an operation that mutates the CloudflareR2 nodes in the graph.
type CloudflareR2Mutation struct {
config
op Op
typ string
id *int
owner_id *string
name *string
location *string
storage_class *string
status *int8
addstatus *int8
payload_size *int64
addpayload_size *int64
metadata_size *int64
addmetadata_size *int64
object_count *int
addobject_count *int
remark *string
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
cloudflare_account *int
clearedcloudflare_account bool
done bool
oldValue func(context.Context) (*CloudflareR2, error)
predicates []predicate.CloudflareR2
}
var _ ent.Mutation = (*CloudflareR2Mutation)(nil)
// cloudflarer2Option allows management of the mutation configuration using functional options.
type cloudflarer2Option func(*CloudflareR2Mutation)
// newCloudflareR2Mutation creates new mutation for the CloudflareR2 entity.
func newCloudflareR2Mutation(c config, op Op, opts ...cloudflarer2Option) *CloudflareR2Mutation {
m := &CloudflareR2Mutation{
config: c,
op: op,
typ: TypeCloudflareR2,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withCloudflareR2ID sets the ID field of the mutation.
func withCloudflareR2ID(id int) cloudflarer2Option {
return func(m *CloudflareR2Mutation) {
var (
err error
once sync.Once
value *CloudflareR2
)
m.oldValue = func(ctx context.Context) (*CloudflareR2, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().CloudflareR2.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withCloudflareR2 sets the old CloudflareR2 of the mutation.
func withCloudflareR2(node *CloudflareR2) cloudflarer2Option {
return func(m *CloudflareR2Mutation) {
m.oldValue = func(context.Context) (*CloudflareR2, 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 CloudflareR2Mutation) 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 CloudflareR2Mutation) 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 *CloudflareR2Mutation) 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 *CloudflareR2Mutation) 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().CloudflareR2.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetOwnerID sets the "owner_id" field.
func (m *CloudflareR2Mutation) SetOwnerID(s string) {
m.owner_id = &s
}
// OwnerID returns the value of the "owner_id" field in the mutation.
func (m *CloudflareR2Mutation) OwnerID() (r string, exists bool) {
v := m.owner_id
if v == nil {
return
}
return *v, true
}
// OldOwnerID returns the old "owner_id" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldOwnerID(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOwnerID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOwnerID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOwnerID: %w", err)
}
return oldValue.OwnerID, nil
}
// ResetOwnerID resets all changes to the "owner_id" field.
func (m *CloudflareR2Mutation) ResetOwnerID() {
m.owner_id = nil
}
// SetName sets the "name" field.
func (m *CloudflareR2Mutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *CloudflareR2Mutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// OldName returns the old "name" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) 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
}
// ResetName resets all changes to the "name" field.
func (m *CloudflareR2Mutation) ResetName() {
m.name = nil
}
// SetLocation sets the "location" field.
func (m *CloudflareR2Mutation) SetLocation(s string) {
m.location = &s
}
// Location returns the value of the "location" field in the mutation.
func (m *CloudflareR2Mutation) Location() (r string, exists bool) {
v := m.location
if v == nil {
return
}
return *v, true
}
// OldLocation returns the old "location" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldLocation(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLocation is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLocation requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLocation: %w", err)
}
return oldValue.Location, nil
}
// ResetLocation resets all changes to the "location" field.
func (m *CloudflareR2Mutation) ResetLocation() {
m.location = nil
}
// SetStorageClass sets the "storage_class" field.
func (m *CloudflareR2Mutation) SetStorageClass(s string) {
m.storage_class = &s
}
// StorageClass returns the value of the "storage_class" field in the mutation.
func (m *CloudflareR2Mutation) StorageClass() (r string, exists bool) {
v := m.storage_class
if v == nil {
return
}
return *v, true
}
// OldStorageClass returns the old "storage_class" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldStorageClass(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStorageClass is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStorageClass requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStorageClass: %w", err)
}
return oldValue.StorageClass, nil
}
// ResetStorageClass resets all changes to the "storage_class" field.
func (m *CloudflareR2Mutation) ResetStorageClass() {
m.storage_class = nil
}
// SetStatus sets the "status" field.
func (m *CloudflareR2Mutation) SetStatus(i int8) {
m.status = &i
m.addstatus = nil
}
// Status returns the value of the "status" field in the mutation.
func (m *CloudflareR2Mutation) Status() (r int8, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldStatus(ctx context.Context) (v int8, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldStatus requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
}
return oldValue.Status, nil
}
// AddStatus adds i to the "status" field.
func (m *CloudflareR2Mutation) AddStatus(i int8) {
if m.addstatus != nil {
*m.addstatus += i
} else {
m.addstatus = &i
}
}
// AddedStatus returns the value that was added to the "status" field in this mutation.
func (m *CloudflareR2Mutation) AddedStatus() (r int8, exists bool) {
v := m.addstatus
if v == nil {
return
}
return *v, true
}
// ResetStatus resets all changes to the "status" field.
func (m *CloudflareR2Mutation) ResetStatus() {
m.status = nil
m.addstatus = nil
}
// SetPayloadSize sets the "payload_size" field.
func (m *CloudflareR2Mutation) SetPayloadSize(i int64) {
m.payload_size = &i
m.addpayload_size = nil
}
// PayloadSize returns the value of the "payload_size" field in the mutation.
func (m *CloudflareR2Mutation) PayloadSize() (r int64, exists bool) {
v := m.payload_size
if v == nil {
return
}
return *v, true
}
// OldPayloadSize returns the old "payload_size" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldPayloadSize(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPayloadSize is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPayloadSize requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPayloadSize: %w", err)
}
return oldValue.PayloadSize, nil
}
// AddPayloadSize adds i to the "payload_size" field.
func (m *CloudflareR2Mutation) AddPayloadSize(i int64) {
if m.addpayload_size != nil {
*m.addpayload_size += i
} else {
m.addpayload_size = &i
}
}
// AddedPayloadSize returns the value that was added to the "payload_size" field in this mutation.
func (m *CloudflareR2Mutation) AddedPayloadSize() (r int64, exists bool) {
v := m.addpayload_size
if v == nil {
return
}
return *v, true
}
// ResetPayloadSize resets all changes to the "payload_size" field.
func (m *CloudflareR2Mutation) ResetPayloadSize() {
m.payload_size = nil
m.addpayload_size = nil
}
// SetMetadataSize sets the "metadata_size" field.
func (m *CloudflareR2Mutation) SetMetadataSize(i int64) {
m.metadata_size = &i
m.addmetadata_size = nil
}
// MetadataSize returns the value of the "metadata_size" field in the mutation.
func (m *CloudflareR2Mutation) MetadataSize() (r int64, exists bool) {
v := m.metadata_size
if v == nil {
return
}
return *v, true
}
// OldMetadataSize returns the old "metadata_size" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldMetadataSize(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMetadataSize is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMetadataSize requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMetadataSize: %w", err)
}
return oldValue.MetadataSize, nil
}
// AddMetadataSize adds i to the "metadata_size" field.
func (m *CloudflareR2Mutation) AddMetadataSize(i int64) {
if m.addmetadata_size != nil {
*m.addmetadata_size += i
} else {
m.addmetadata_size = &i
}
}
// AddedMetadataSize returns the value that was added to the "metadata_size" field in this mutation.
func (m *CloudflareR2Mutation) AddedMetadataSize() (r int64, exists bool) {
v := m.addmetadata_size
if v == nil {
return
}
return *v, true
}
// ResetMetadataSize resets all changes to the "metadata_size" field.
func (m *CloudflareR2Mutation) ResetMetadataSize() {
m.metadata_size = nil
m.addmetadata_size = nil
}
// SetObjectCount sets the "object_count" field.
func (m *CloudflareR2Mutation) SetObjectCount(i int) {
m.object_count = &i
m.addobject_count = nil
}
// ObjectCount returns the value of the "object_count" field in the mutation.
func (m *CloudflareR2Mutation) ObjectCount() (r int, exists bool) {
v := m.object_count
if v == nil {
return
}
return *v, true
}
// OldObjectCount returns the old "object_count" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldObjectCount(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldObjectCount is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldObjectCount requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldObjectCount: %w", err)
}
return oldValue.ObjectCount, nil
}
// AddObjectCount adds i to the "object_count" field.
func (m *CloudflareR2Mutation) AddObjectCount(i int) {
if m.addobject_count != nil {
*m.addobject_count += i
} else {
m.addobject_count = &i
}
}
// AddedObjectCount returns the value that was added to the "object_count" field in this mutation.
func (m *CloudflareR2Mutation) AddedObjectCount() (r int, exists bool) {
v := m.addobject_count
if v == nil {
return
}
return *v, true
}
// ResetObjectCount resets all changes to the "object_count" field.
func (m *CloudflareR2Mutation) ResetObjectCount() {
m.object_count = nil
m.addobject_count = nil
}
// SetRemark sets the "remark" field.
func (m *CloudflareR2Mutation) SetRemark(s string) {
m.remark = &s
}
// Remark returns the value of the "remark" field in the mutation.
func (m *CloudflareR2Mutation) Remark() (r string, exists bool) {
v := m.remark
if v == nil {
return
}
return *v, true
}
// OldRemark returns the old "remark" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldRemark(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRemark is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRemark requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRemark: %w", err)
}
return oldValue.Remark, nil
}
// ClearRemark clears the value of the "remark" field.
func (m *CloudflareR2Mutation) ClearRemark() {
m.remark = nil
m.clearedFields[cloudflarer2.FieldRemark] = struct{}{}
}
// RemarkCleared returns if the "remark" field was cleared in this mutation.
func (m *CloudflareR2Mutation) RemarkCleared() bool {
_, ok := m.clearedFields[cloudflarer2.FieldRemark]
return ok
}
// ResetRemark resets all changes to the "remark" field.
func (m *CloudflareR2Mutation) ResetRemark() {
m.remark = nil
delete(m.clearedFields, cloudflarer2.FieldRemark)
}
// SetCreatedAt sets the "created_at" field.
func (m *CloudflareR2Mutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *CloudflareR2Mutation) CreatedAt() (r time.Time, exists bool) {
v := m.created_at
if v == nil {
return
}
return *v, true
}
// OldCreatedAt returns the old "created_at" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
}
return oldValue.CreatedAt, nil
}
// ResetCreatedAt resets all changes to the "created_at" field.
func (m *CloudflareR2Mutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *CloudflareR2Mutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *CloudflareR2Mutation) UpdatedAt() (r time.Time, exists bool) {
v := m.updated_at
if v == nil {
return
}
return *v, true
}
// OldUpdatedAt returns the old "updated_at" field's value of the CloudflareR2 entity.
// If the CloudflareR2 object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CloudflareR2Mutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
}
return oldValue.UpdatedAt, nil
}
// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *CloudflareR2Mutation) ResetUpdatedAt() {
m.updated_at = nil
}
// SetCloudflareAccountID sets the "cloudflare_account" edge to the CloudflareAccounts entity by id.
func (m *CloudflareR2Mutation) SetCloudflareAccountID(id int) {
m.cloudflare_account = &id
}
// ClearCloudflareAccount clears the "cloudflare_account" edge to the CloudflareAccounts entity.
func (m *CloudflareR2Mutation) ClearCloudflareAccount() {
m.clearedcloudflare_account = true
}
// CloudflareAccountCleared reports if the "cloudflare_account" edge to the CloudflareAccounts entity was cleared.
func (m *CloudflareR2Mutation) CloudflareAccountCleared() bool {
return m.clearedcloudflare_account
}
// CloudflareAccountID returns the "cloudflare_account" edge ID in the mutation.
func (m *CloudflareR2Mutation) CloudflareAccountID() (id int, exists bool) {
if m.cloudflare_account != nil {
return *m.cloudflare_account, true
}
return
}
// CloudflareAccountIDs returns the "cloudflare_account" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// CloudflareAccountID instead. It exists only for internal usage by the builders.
func (m *CloudflareR2Mutation) CloudflareAccountIDs() (ids []int) {
if id := m.cloudflare_account; id != nil {
ids = append(ids, *id)
}
return
}
// ResetCloudflareAccount resets all changes to the "cloudflare_account" edge.
func (m *CloudflareR2Mutation) ResetCloudflareAccount() {
m.cloudflare_account = nil
m.clearedcloudflare_account = false
}
// Where appends a list predicates to the CloudflareR2Mutation builder.
func (m *CloudflareR2Mutation) Where(ps ...predicate.CloudflareR2) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the CloudflareR2Mutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *CloudflareR2Mutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.CloudflareR2, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *CloudflareR2Mutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *CloudflareR2Mutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (CloudflareR2).
func (m *CloudflareR2Mutation) 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 *CloudflareR2Mutation) Fields() []string {
fields := make([]string, 0, 11)
if m.owner_id != nil {
fields = append(fields, cloudflarer2.FieldOwnerID)
}
if m.name != nil {
fields = append(fields, cloudflarer2.FieldName)
}
if m.location != nil {
fields = append(fields, cloudflarer2.FieldLocation)
}
if m.storage_class != nil {
fields = append(fields, cloudflarer2.FieldStorageClass)
}
if m.status != nil {
fields = append(fields, cloudflarer2.FieldStatus)
}
if m.payload_size != nil {
fields = append(fields, cloudflarer2.FieldPayloadSize)
}
if m.metadata_size != nil {
fields = append(fields, cloudflarer2.FieldMetadataSize)
}
if m.object_count != nil {
fields = append(fields, cloudflarer2.FieldObjectCount)
}
if m.remark != nil {
fields = append(fields, cloudflarer2.FieldRemark)
}
if m.created_at != nil {
fields = append(fields, cloudflarer2.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, cloudflarer2.FieldUpdatedAt)
}
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 *CloudflareR2Mutation) Field(name string) (ent.Value, bool) {
switch name {
case cloudflarer2.FieldOwnerID:
return m.OwnerID()
case cloudflarer2.FieldName:
return m.Name()
case cloudflarer2.FieldLocation:
return m.Location()
case cloudflarer2.FieldStorageClass:
return m.StorageClass()
case cloudflarer2.FieldStatus:
return m.Status()
case cloudflarer2.FieldPayloadSize:
return m.PayloadSize()
case cloudflarer2.FieldMetadataSize:
return m.MetadataSize()
case cloudflarer2.FieldObjectCount:
return m.ObjectCount()
case cloudflarer2.FieldRemark:
return m.Remark()
case cloudflarer2.FieldCreatedAt:
return m.CreatedAt()
case cloudflarer2.FieldUpdatedAt:
return m.UpdatedAt()
}
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 *CloudflareR2Mutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case cloudflarer2.FieldOwnerID:
return m.OldOwnerID(ctx)
case cloudflarer2.FieldName:
return m.OldName(ctx)
case cloudflarer2.FieldLocation:
return m.OldLocation(ctx)
case cloudflarer2.FieldStorageClass:
return m.OldStorageClass(ctx)
case cloudflarer2.FieldStatus:
return m.OldStatus(ctx)
case cloudflarer2.FieldPayloadSize:
return m.OldPayloadSize(ctx)
case cloudflarer2.FieldMetadataSize:
return m.OldMetadataSize(ctx)
case cloudflarer2.FieldObjectCount:
return m.OldObjectCount(ctx)
case cloudflarer2.FieldRemark:
return m.OldRemark(ctx)
case cloudflarer2.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case cloudflarer2.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown CloudflareR2 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 *CloudflareR2Mutation) SetField(name string, value ent.Value) error {
switch name {
case cloudflarer2.FieldOwnerID:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOwnerID(v)
return nil
case cloudflarer2.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case cloudflarer2.FieldLocation:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLocation(v)
return nil
case cloudflarer2.FieldStorageClass:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStorageClass(v)
return nil
case cloudflarer2.FieldStatus:
v, ok := value.(int8)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case cloudflarer2.FieldPayloadSize:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPayloadSize(v)
return nil
case cloudflarer2.FieldMetadataSize:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMetadataSize(v)
return nil
case cloudflarer2.FieldObjectCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetObjectCount(v)
return nil
case cloudflarer2.FieldRemark:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRemark(v)
return nil
case cloudflarer2.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
case cloudflarer2.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
}
return fmt.Errorf("unknown CloudflareR2 field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CloudflareR2Mutation) AddedFields() []string {
var fields []string
if m.addstatus != nil {
fields = append(fields, cloudflarer2.FieldStatus)
}
if m.addpayload_size != nil {
fields = append(fields, cloudflarer2.FieldPayloadSize)
}
if m.addmetadata_size != nil {
fields = append(fields, cloudflarer2.FieldMetadataSize)
}
if m.addobject_count != nil {
fields = append(fields, cloudflarer2.FieldObjectCount)
}
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 *CloudflareR2Mutation) AddedField(name string) (ent.Value, bool) {
switch name {
case cloudflarer2.FieldStatus:
return m.AddedStatus()
case cloudflarer2.FieldPayloadSize:
return m.AddedPayloadSize()
case cloudflarer2.FieldMetadataSize:
return m.AddedMetadataSize()
case cloudflarer2.FieldObjectCount:
return m.AddedObjectCount()
}
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 *CloudflareR2Mutation) AddField(name string, value ent.Value) error {
switch name {
case cloudflarer2.FieldStatus:
v, ok := value.(int8)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddStatus(v)
return nil
case cloudflarer2.FieldPayloadSize:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddPayloadSize(v)
return nil
case cloudflarer2.FieldMetadataSize:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddMetadataSize(v)
return nil
case cloudflarer2.FieldObjectCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddObjectCount(v)
return nil
}
return fmt.Errorf("unknown CloudflareR2 numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CloudflareR2Mutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(cloudflarer2.FieldRemark) {
fields = append(fields, cloudflarer2.FieldRemark)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CloudflareR2Mutation) 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 *CloudflareR2Mutation) ClearField(name string) error {
switch name {
case cloudflarer2.FieldRemark:
m.ClearRemark()
return nil
}
return fmt.Errorf("unknown CloudflareR2 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 *CloudflareR2Mutation) ResetField(name string) error {
switch name {
case cloudflarer2.FieldOwnerID:
m.ResetOwnerID()
return nil
case cloudflarer2.FieldName:
m.ResetName()
return nil
case cloudflarer2.FieldLocation:
m.ResetLocation()
return nil
case cloudflarer2.FieldStorageClass:
m.ResetStorageClass()
return nil
case cloudflarer2.FieldStatus:
m.ResetStatus()
return nil
case cloudflarer2.FieldPayloadSize:
m.ResetPayloadSize()
return nil
case cloudflarer2.FieldMetadataSize:
m.ResetMetadataSize()
return nil
case cloudflarer2.FieldObjectCount:
m.ResetObjectCount()
return nil
case cloudflarer2.FieldRemark:
m.ResetRemark()
return nil
case cloudflarer2.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case cloudflarer2.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown CloudflareR2 field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CloudflareR2Mutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.cloudflare_account != nil {
edges = append(edges, cloudflarer2.EdgeCloudflareAccount)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CloudflareR2Mutation) AddedIDs(name string) []ent.Value {
switch name {
case cloudflarer2.EdgeCloudflareAccount:
if id := m.cloudflare_account; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CloudflareR2Mutation) 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 *CloudflareR2Mutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CloudflareR2Mutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedcloudflare_account {
edges = append(edges, cloudflarer2.EdgeCloudflareAccount)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CloudflareR2Mutation) EdgeCleared(name string) bool {
switch name {
case cloudflarer2.EdgeCloudflareAccount:
return m.clearedcloudflare_account
}
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 *CloudflareR2Mutation) ClearEdge(name string) error {
switch name {
case cloudflarer2.EdgeCloudflareAccount:
m.ClearCloudflareAccount()
return nil
}
return fmt.Errorf("unknown CloudflareR2 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 *CloudflareR2Mutation) ResetEdge(name string) error {
switch name {
case cloudflarer2.EdgeCloudflareAccount:
m.ResetCloudflareAccount()
return nil
}
return fmt.Errorf("unknown CloudflareR2 edge %s", name)
}