tlsfingerprintprofile.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "strings"
  7. "time"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. "github.com/Wei-Shaw/sub2api/ent/tlsfingerprintprofile"
  11. )
  12. // TLSFingerprintProfile is the model entity for the TLSFingerprintProfile schema.
  13. type TLSFingerprintProfile struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. ID int64 `json:"id,omitempty"`
  17. // CreatedAt holds the value of the "created_at" field.
  18. CreatedAt time.Time `json:"created_at,omitempty"`
  19. // UpdatedAt holds the value of the "updated_at" field.
  20. UpdatedAt time.Time `json:"updated_at,omitempty"`
  21. // Name holds the value of the "name" field.
  22. Name string `json:"name,omitempty"`
  23. // Description holds the value of the "description" field.
  24. Description *string `json:"description,omitempty"`
  25. // EnableGrease holds the value of the "enable_grease" field.
  26. EnableGrease bool `json:"enable_grease,omitempty"`
  27. // CipherSuites holds the value of the "cipher_suites" field.
  28. CipherSuites []uint16 `json:"cipher_suites,omitempty"`
  29. // Curves holds the value of the "curves" field.
  30. Curves []uint16 `json:"curves,omitempty"`
  31. // PointFormats holds the value of the "point_formats" field.
  32. PointFormats []uint16 `json:"point_formats,omitempty"`
  33. // SignatureAlgorithms holds the value of the "signature_algorithms" field.
  34. SignatureAlgorithms []uint16 `json:"signature_algorithms,omitempty"`
  35. // AlpnProtocols holds the value of the "alpn_protocols" field.
  36. AlpnProtocols []string `json:"alpn_protocols,omitempty"`
  37. // SupportedVersions holds the value of the "supported_versions" field.
  38. SupportedVersions []uint16 `json:"supported_versions,omitempty"`
  39. // KeyShareGroups holds the value of the "key_share_groups" field.
  40. KeyShareGroups []uint16 `json:"key_share_groups,omitempty"`
  41. // PskModes holds the value of the "psk_modes" field.
  42. PskModes []uint16 `json:"psk_modes,omitempty"`
  43. // Extensions holds the value of the "extensions" field.
  44. Extensions []uint16 `json:"extensions,omitempty"`
  45. selectValues sql.SelectValues
  46. }
  47. // scanValues returns the types for scanning values from sql.Rows.
  48. func (*TLSFingerprintProfile) scanValues(columns []string) ([]any, error) {
  49. values := make([]any, len(columns))
  50. for i := range columns {
  51. switch columns[i] {
  52. case tlsfingerprintprofile.FieldCipherSuites, tlsfingerprintprofile.FieldCurves, tlsfingerprintprofile.FieldPointFormats, tlsfingerprintprofile.FieldSignatureAlgorithms, tlsfingerprintprofile.FieldAlpnProtocols, tlsfingerprintprofile.FieldSupportedVersions, tlsfingerprintprofile.FieldKeyShareGroups, tlsfingerprintprofile.FieldPskModes, tlsfingerprintprofile.FieldExtensions:
  53. values[i] = new([]byte)
  54. case tlsfingerprintprofile.FieldEnableGrease:
  55. values[i] = new(sql.NullBool)
  56. case tlsfingerprintprofile.FieldID:
  57. values[i] = new(sql.NullInt64)
  58. case tlsfingerprintprofile.FieldName, tlsfingerprintprofile.FieldDescription:
  59. values[i] = new(sql.NullString)
  60. case tlsfingerprintprofile.FieldCreatedAt, tlsfingerprintprofile.FieldUpdatedAt:
  61. values[i] = new(sql.NullTime)
  62. default:
  63. values[i] = new(sql.UnknownType)
  64. }
  65. }
  66. return values, nil
  67. }
  68. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  69. // to the TLSFingerprintProfile fields.
  70. func (_m *TLSFingerprintProfile) assignValues(columns []string, values []any) error {
  71. if m, n := len(values), len(columns); m < n {
  72. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  73. }
  74. for i := range columns {
  75. switch columns[i] {
  76. case tlsfingerprintprofile.FieldID:
  77. value, ok := values[i].(*sql.NullInt64)
  78. if !ok {
  79. return fmt.Errorf("unexpected type %T for field id", value)
  80. }
  81. _m.ID = int64(value.Int64)
  82. case tlsfingerprintprofile.FieldCreatedAt:
  83. if value, ok := values[i].(*sql.NullTime); !ok {
  84. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  85. } else if value.Valid {
  86. _m.CreatedAt = value.Time
  87. }
  88. case tlsfingerprintprofile.FieldUpdatedAt:
  89. if value, ok := values[i].(*sql.NullTime); !ok {
  90. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  91. } else if value.Valid {
  92. _m.UpdatedAt = value.Time
  93. }
  94. case tlsfingerprintprofile.FieldName:
  95. if value, ok := values[i].(*sql.NullString); !ok {
  96. return fmt.Errorf("unexpected type %T for field name", values[i])
  97. } else if value.Valid {
  98. _m.Name = value.String
  99. }
  100. case tlsfingerprintprofile.FieldDescription:
  101. if value, ok := values[i].(*sql.NullString); !ok {
  102. return fmt.Errorf("unexpected type %T for field description", values[i])
  103. } else if value.Valid {
  104. _m.Description = new(string)
  105. *_m.Description = value.String
  106. }
  107. case tlsfingerprintprofile.FieldEnableGrease:
  108. if value, ok := values[i].(*sql.NullBool); !ok {
  109. return fmt.Errorf("unexpected type %T for field enable_grease", values[i])
  110. } else if value.Valid {
  111. _m.EnableGrease = value.Bool
  112. }
  113. case tlsfingerprintprofile.FieldCipherSuites:
  114. if value, ok := values[i].(*[]byte); !ok {
  115. return fmt.Errorf("unexpected type %T for field cipher_suites", values[i])
  116. } else if value != nil && len(*value) > 0 {
  117. if err := json.Unmarshal(*value, &_m.CipherSuites); err != nil {
  118. return fmt.Errorf("unmarshal field cipher_suites: %w", err)
  119. }
  120. }
  121. case tlsfingerprintprofile.FieldCurves:
  122. if value, ok := values[i].(*[]byte); !ok {
  123. return fmt.Errorf("unexpected type %T for field curves", values[i])
  124. } else if value != nil && len(*value) > 0 {
  125. if err := json.Unmarshal(*value, &_m.Curves); err != nil {
  126. return fmt.Errorf("unmarshal field curves: %w", err)
  127. }
  128. }
  129. case tlsfingerprintprofile.FieldPointFormats:
  130. if value, ok := values[i].(*[]byte); !ok {
  131. return fmt.Errorf("unexpected type %T for field point_formats", values[i])
  132. } else if value != nil && len(*value) > 0 {
  133. if err := json.Unmarshal(*value, &_m.PointFormats); err != nil {
  134. return fmt.Errorf("unmarshal field point_formats: %w", err)
  135. }
  136. }
  137. case tlsfingerprintprofile.FieldSignatureAlgorithms:
  138. if value, ok := values[i].(*[]byte); !ok {
  139. return fmt.Errorf("unexpected type %T for field signature_algorithms", values[i])
  140. } else if value != nil && len(*value) > 0 {
  141. if err := json.Unmarshal(*value, &_m.SignatureAlgorithms); err != nil {
  142. return fmt.Errorf("unmarshal field signature_algorithms: %w", err)
  143. }
  144. }
  145. case tlsfingerprintprofile.FieldAlpnProtocols:
  146. if value, ok := values[i].(*[]byte); !ok {
  147. return fmt.Errorf("unexpected type %T for field alpn_protocols", values[i])
  148. } else if value != nil && len(*value) > 0 {
  149. if err := json.Unmarshal(*value, &_m.AlpnProtocols); err != nil {
  150. return fmt.Errorf("unmarshal field alpn_protocols: %w", err)
  151. }
  152. }
  153. case tlsfingerprintprofile.FieldSupportedVersions:
  154. if value, ok := values[i].(*[]byte); !ok {
  155. return fmt.Errorf("unexpected type %T for field supported_versions", values[i])
  156. } else if value != nil && len(*value) > 0 {
  157. if err := json.Unmarshal(*value, &_m.SupportedVersions); err != nil {
  158. return fmt.Errorf("unmarshal field supported_versions: %w", err)
  159. }
  160. }
  161. case tlsfingerprintprofile.FieldKeyShareGroups:
  162. if value, ok := values[i].(*[]byte); !ok {
  163. return fmt.Errorf("unexpected type %T for field key_share_groups", values[i])
  164. } else if value != nil && len(*value) > 0 {
  165. if err := json.Unmarshal(*value, &_m.KeyShareGroups); err != nil {
  166. return fmt.Errorf("unmarshal field key_share_groups: %w", err)
  167. }
  168. }
  169. case tlsfingerprintprofile.FieldPskModes:
  170. if value, ok := values[i].(*[]byte); !ok {
  171. return fmt.Errorf("unexpected type %T for field psk_modes", values[i])
  172. } else if value != nil && len(*value) > 0 {
  173. if err := json.Unmarshal(*value, &_m.PskModes); err != nil {
  174. return fmt.Errorf("unmarshal field psk_modes: %w", err)
  175. }
  176. }
  177. case tlsfingerprintprofile.FieldExtensions:
  178. if value, ok := values[i].(*[]byte); !ok {
  179. return fmt.Errorf("unexpected type %T for field extensions", values[i])
  180. } else if value != nil && len(*value) > 0 {
  181. if err := json.Unmarshal(*value, &_m.Extensions); err != nil {
  182. return fmt.Errorf("unmarshal field extensions: %w", err)
  183. }
  184. }
  185. default:
  186. _m.selectValues.Set(columns[i], values[i])
  187. }
  188. }
  189. return nil
  190. }
  191. // Value returns the ent.Value that was dynamically selected and assigned to the TLSFingerprintProfile.
  192. // This includes values selected through modifiers, order, etc.
  193. func (_m *TLSFingerprintProfile) Value(name string) (ent.Value, error) {
  194. return _m.selectValues.Get(name)
  195. }
  196. // Update returns a builder for updating this TLSFingerprintProfile.
  197. // Note that you need to call TLSFingerprintProfile.Unwrap() before calling this method if this TLSFingerprintProfile
  198. // was returned from a transaction, and the transaction was committed or rolled back.
  199. func (_m *TLSFingerprintProfile) Update() *TLSFingerprintProfileUpdateOne {
  200. return NewTLSFingerprintProfileClient(_m.config).UpdateOne(_m)
  201. }
  202. // Unwrap unwraps the TLSFingerprintProfile entity that was returned from a transaction after it was closed,
  203. // so that all future queries will be executed through the driver which created the transaction.
  204. func (_m *TLSFingerprintProfile) Unwrap() *TLSFingerprintProfile {
  205. _tx, ok := _m.config.driver.(*txDriver)
  206. if !ok {
  207. panic("ent: TLSFingerprintProfile is not a transactional entity")
  208. }
  209. _m.config.driver = _tx.drv
  210. return _m
  211. }
  212. // String implements the fmt.Stringer.
  213. func (_m *TLSFingerprintProfile) String() string {
  214. var builder strings.Builder
  215. builder.WriteString("TLSFingerprintProfile(")
  216. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  217. builder.WriteString("created_at=")
  218. builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
  219. builder.WriteString(", ")
  220. builder.WriteString("updated_at=")
  221. builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
  222. builder.WriteString(", ")
  223. builder.WriteString("name=")
  224. builder.WriteString(_m.Name)
  225. builder.WriteString(", ")
  226. if v := _m.Description; v != nil {
  227. builder.WriteString("description=")
  228. builder.WriteString(*v)
  229. }
  230. builder.WriteString(", ")
  231. builder.WriteString("enable_grease=")
  232. builder.WriteString(fmt.Sprintf("%v", _m.EnableGrease))
  233. builder.WriteString(", ")
  234. builder.WriteString("cipher_suites=")
  235. builder.WriteString(fmt.Sprintf("%v", _m.CipherSuites))
  236. builder.WriteString(", ")
  237. builder.WriteString("curves=")
  238. builder.WriteString(fmt.Sprintf("%v", _m.Curves))
  239. builder.WriteString(", ")
  240. builder.WriteString("point_formats=")
  241. builder.WriteString(fmt.Sprintf("%v", _m.PointFormats))
  242. builder.WriteString(", ")
  243. builder.WriteString("signature_algorithms=")
  244. builder.WriteString(fmt.Sprintf("%v", _m.SignatureAlgorithms))
  245. builder.WriteString(", ")
  246. builder.WriteString("alpn_protocols=")
  247. builder.WriteString(fmt.Sprintf("%v", _m.AlpnProtocols))
  248. builder.WriteString(", ")
  249. builder.WriteString("supported_versions=")
  250. builder.WriteString(fmt.Sprintf("%v", _m.SupportedVersions))
  251. builder.WriteString(", ")
  252. builder.WriteString("key_share_groups=")
  253. builder.WriteString(fmt.Sprintf("%v", _m.KeyShareGroups))
  254. builder.WriteString(", ")
  255. builder.WriteString("psk_modes=")
  256. builder.WriteString(fmt.Sprintf("%v", _m.PskModes))
  257. builder.WriteString(", ")
  258. builder.WriteString("extensions=")
  259. builder.WriteString(fmt.Sprintf("%v", _m.Extensions))
  260. builder.WriteByte(')')
  261. return builder.String()
  262. }
  263. // TLSFingerprintProfiles is a parsable slice of TLSFingerprintProfile.
  264. type TLSFingerprintProfiles []*TLSFingerprintProfile