// Code generated by ent, DO NOT EDIT. package ent import ( "encoding/json" "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "github.com/Wei-Shaw/sub2api/ent/tlsfingerprintprofile" ) // TLSFingerprintProfile is the model entity for the TLSFingerprintProfile schema. type TLSFingerprintProfile struct { config `json:"-"` // ID of the ent. ID int64 `json:"id,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Description holds the value of the "description" field. Description *string `json:"description,omitempty"` // EnableGrease holds the value of the "enable_grease" field. EnableGrease bool `json:"enable_grease,omitempty"` // CipherSuites holds the value of the "cipher_suites" field. CipherSuites []uint16 `json:"cipher_suites,omitempty"` // Curves holds the value of the "curves" field. Curves []uint16 `json:"curves,omitempty"` // PointFormats holds the value of the "point_formats" field. PointFormats []uint16 `json:"point_formats,omitempty"` // SignatureAlgorithms holds the value of the "signature_algorithms" field. SignatureAlgorithms []uint16 `json:"signature_algorithms,omitempty"` // AlpnProtocols holds the value of the "alpn_protocols" field. AlpnProtocols []string `json:"alpn_protocols,omitempty"` // SupportedVersions holds the value of the "supported_versions" field. SupportedVersions []uint16 `json:"supported_versions,omitempty"` // KeyShareGroups holds the value of the "key_share_groups" field. KeyShareGroups []uint16 `json:"key_share_groups,omitempty"` // PskModes holds the value of the "psk_modes" field. PskModes []uint16 `json:"psk_modes,omitempty"` // Extensions holds the value of the "extensions" field. Extensions []uint16 `json:"extensions,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*TLSFingerprintProfile) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case tlsfingerprintprofile.FieldCipherSuites, tlsfingerprintprofile.FieldCurves, tlsfingerprintprofile.FieldPointFormats, tlsfingerprintprofile.FieldSignatureAlgorithms, tlsfingerprintprofile.FieldAlpnProtocols, tlsfingerprintprofile.FieldSupportedVersions, tlsfingerprintprofile.FieldKeyShareGroups, tlsfingerprintprofile.FieldPskModes, tlsfingerprintprofile.FieldExtensions: values[i] = new([]byte) case tlsfingerprintprofile.FieldEnableGrease: values[i] = new(sql.NullBool) case tlsfingerprintprofile.FieldID: values[i] = new(sql.NullInt64) case tlsfingerprintprofile.FieldName, tlsfingerprintprofile.FieldDescription: values[i] = new(sql.NullString) case tlsfingerprintprofile.FieldCreatedAt, tlsfingerprintprofile.FieldUpdatedAt: 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 TLSFingerprintProfile fields. func (_m *TLSFingerprintProfile) 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 tlsfingerprintprofile.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } _m.ID = int64(value.Int64) case tlsfingerprintprofile.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field created_at", values[i]) } else if value.Valid { _m.CreatedAt = value.Time } case tlsfingerprintprofile.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = value.Time } case tlsfingerprintprofile.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { _m.Name = value.String } case tlsfingerprintprofile.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { _m.Description = new(string) *_m.Description = value.String } case tlsfingerprintprofile.FieldEnableGrease: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field enable_grease", values[i]) } else if value.Valid { _m.EnableGrease = value.Bool } case tlsfingerprintprofile.FieldCipherSuites: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field cipher_suites", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.CipherSuites); err != nil { return fmt.Errorf("unmarshal field cipher_suites: %w", err) } } case tlsfingerprintprofile.FieldCurves: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field curves", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.Curves); err != nil { return fmt.Errorf("unmarshal field curves: %w", err) } } case tlsfingerprintprofile.FieldPointFormats: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field point_formats", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.PointFormats); err != nil { return fmt.Errorf("unmarshal field point_formats: %w", err) } } case tlsfingerprintprofile.FieldSignatureAlgorithms: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field signature_algorithms", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.SignatureAlgorithms); err != nil { return fmt.Errorf("unmarshal field signature_algorithms: %w", err) } } case tlsfingerprintprofile.FieldAlpnProtocols: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field alpn_protocols", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.AlpnProtocols); err != nil { return fmt.Errorf("unmarshal field alpn_protocols: %w", err) } } case tlsfingerprintprofile.FieldSupportedVersions: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field supported_versions", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.SupportedVersions); err != nil { return fmt.Errorf("unmarshal field supported_versions: %w", err) } } case tlsfingerprintprofile.FieldKeyShareGroups: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field key_share_groups", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.KeyShareGroups); err != nil { return fmt.Errorf("unmarshal field key_share_groups: %w", err) } } case tlsfingerprintprofile.FieldPskModes: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field psk_modes", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.PskModes); err != nil { return fmt.Errorf("unmarshal field psk_modes: %w", err) } } case tlsfingerprintprofile.FieldExtensions: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field extensions", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &_m.Extensions); err != nil { return fmt.Errorf("unmarshal field extensions: %w", err) } } default: _m.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the TLSFingerprintProfile. // This includes values selected through modifiers, order, etc. func (_m *TLSFingerprintProfile) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this TLSFingerprintProfile. // Note that you need to call TLSFingerprintProfile.Unwrap() before calling this method if this TLSFingerprintProfile // was returned from a transaction, and the transaction was committed or rolled back. func (_m *TLSFingerprintProfile) Update() *TLSFingerprintProfileUpdateOne { return NewTLSFingerprintProfileClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the TLSFingerprintProfile 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 (_m *TLSFingerprintProfile) Unwrap() *TLSFingerprintProfile { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: TLSFingerprintProfile is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *TLSFingerprintProfile) String() string { var builder strings.Builder builder.WriteString("TLSFingerprintProfile(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("created_at=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(_m.Name) builder.WriteString(", ") if v := _m.Description; v != nil { builder.WriteString("description=") builder.WriteString(*v) } builder.WriteString(", ") builder.WriteString("enable_grease=") builder.WriteString(fmt.Sprintf("%v", _m.EnableGrease)) builder.WriteString(", ") builder.WriteString("cipher_suites=") builder.WriteString(fmt.Sprintf("%v", _m.CipherSuites)) builder.WriteString(", ") builder.WriteString("curves=") builder.WriteString(fmt.Sprintf("%v", _m.Curves)) builder.WriteString(", ") builder.WriteString("point_formats=") builder.WriteString(fmt.Sprintf("%v", _m.PointFormats)) builder.WriteString(", ") builder.WriteString("signature_algorithms=") builder.WriteString(fmt.Sprintf("%v", _m.SignatureAlgorithms)) builder.WriteString(", ") builder.WriteString("alpn_protocols=") builder.WriteString(fmt.Sprintf("%v", _m.AlpnProtocols)) builder.WriteString(", ") builder.WriteString("supported_versions=") builder.WriteString(fmt.Sprintf("%v", _m.SupportedVersions)) builder.WriteString(", ") builder.WriteString("key_share_groups=") builder.WriteString(fmt.Sprintf("%v", _m.KeyShareGroups)) builder.WriteString(", ") builder.WriteString("psk_modes=") builder.WriteString(fmt.Sprintf("%v", _m.PskModes)) builder.WriteString(", ") builder.WriteString("extensions=") builder.WriteString(fmt.Sprintf("%v", _m.Extensions)) builder.WriteByte(')') return builder.String() } // TLSFingerprintProfiles is a parsable slice of TLSFingerprintProfile. type TLSFingerprintProfiles []*TLSFingerprintProfile