Debian Codegraph @

ent/payloaddigest.go

raw
1 // Code generated by ent, DO NOT EDIT.
2
3 package ent
4
5 import (
6 "fmt"
7 "strings"
8
9 "entgo.io/ent"
10 "entgo.io/ent/dialect/sql"
11 "github.com/google/uuid"
12 "github.com/in-toto/archivista/ent/dsse"
13 "github.com/in-toto/archivista/ent/payloaddigest"
14 )
15
16 // PayloadDigest is the model entity for the PayloadDigest schema.
17 type PayloadDigest struct {
18 config `json:"-"`
19 // ID of the ent.
20 ID uuid.UUID `json:"id,omitempty"`
21 // Algorithm holds the value of the "algorithm" field.
22 Algorithm string `json:"algorithm,omitempty"`
23 // Value holds the value of the "value" field.
24 Value string `json:"value,omitempty"`
25 // Edges holds the relations/edges for other nodes in the graph.
26 // The values are being populated by the PayloadDigestQuery when eager-loading is set.
27 Edges PayloadDigestEdges `json:"edges"`
28 dsse_payload_digests *uuid.UUID
29 selectValues sql.SelectValues
30 }
31
32 // PayloadDigestEdges holds the relations/edges for other nodes in the graph.
33 type PayloadDigestEdges struct {
34 // Dsse holds the value of the dsse edge.
35 Dsse *Dsse `json:"dsse,omitempty"`
36 // loadedTypes holds the information for reporting if a
37 // type was loaded (or requested) in eager-loading or not.
38 loadedTypes [1]bool
39 // totalCount holds the count of the edges above.
40 totalCount [1]map[string]int
41 }
42
43 // DsseOrErr returns the Dsse value or an error if the edge
44 // was not loaded in eager-loading, or loaded but was not found.
45 func (e PayloadDigestEdges) DsseOrErr() (*Dsse, error) {
46 if e.Dsse != nil {
47 return e.Dsse, nil
48 } else if e.loadedTypes[0] {
49 return nil, &NotFoundError{label: dsse.Label}
50 }
51 return nil, &NotLoadedError{edge: "dsse"}
52 }
53
54 // scanValues returns the types for scanning values from sql.Rows.
55 func (*PayloadDigest) scanValues(columns []string) ([]any, error) {
56 values := make([]any, len(columns))
57 for i := range columns {
58 switch columns[i] {
59 case payloaddigest.FieldAlgorithm, payloaddigest.FieldValue:
60 values[i] = new(sql.NullString)
61 case payloaddigest.FieldID:
62 values[i] = new(uuid.UUID)
63 case payloaddigest.ForeignKeys[0]: // dsse_payload_digests
64 values[i] = &sql.NullScanner{S: new(uuid.UUID)}
65 default:
66 values[i] = new(sql.UnknownType)
67 }
68 }
69 return values, nil
70 }
71
72 // assignValues assigns the values that were returned from sql.Rows (after scanning)
73 // to the PayloadDigest fields.
74 func (_m *PayloadDigest) assignValues(columns []string, values []any) error {
75 if m, n := len(values), len(columns); m < n {
76 return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
77 }
78 for i := range columns {
79 switch columns[i] {
80 case payloaddigest.FieldID:
81 if value, ok := values[i].(*uuid.UUID); !ok {
82 return fmt.Errorf("unexpected type %T for field id", values[i])
83 } else if value != nil {
84 _m.ID = *value
85 }
86 case payloaddigest.FieldAlgorithm:
87 if value, ok := values[i].(*sql.NullString); !ok {
88 return fmt.Errorf("unexpected type %T for field algorithm", values[i])
89 } else if value.Valid {
90 _m.Algorithm = value.String
91 }
92 case payloaddigest.FieldValue:
93 if value, ok := values[i].(*sql.NullString); !ok {
94 return fmt.Errorf("unexpected type %T for field value", values[i])
95 } else if value.Valid {
96 _m.Value = value.String
97 }
98 case payloaddigest.ForeignKeys[0]:
99 if value, ok := values[i].(*sql.NullScanner); !ok {
100 return fmt.Errorf("unexpected type %T for field dsse_payload_digests", values[i])
101 } else if value.Valid {
102 _m.dsse_payload_digests = new(uuid.UUID)
103 *_m.dsse_payload_digests = *value.S.(*uuid.UUID)
104 }
105 default:
106 _m.selectValues.Set(columns[i], values[i])
107 }
108 }
109 return nil
110 }
111
112 // GetValue returns the ent.Value that was dynamically selected and assigned to the PayloadDigest.
113 // This includes values selected through modifiers, order, etc.
114 func (_m *PayloadDigest) GetValue(name string) (ent.Value, error) {
115 return _m.selectValues.Get(name)
116 }
117
118 // QueryDsse queries the "dsse" edge of the PayloadDigest entity.
119 func (_m *PayloadDigest) QueryDsse() *DsseQuery {
120 return NewPayloadDigestClient(_m.config).QueryDsse(_m)
121 }
122
123 // Update returns a builder for updating this PayloadDigest.
124 // Note that you need to call PayloadDigest.Unwrap() before calling this method if this PayloadDigest
125 // was returned from a transaction, and the transaction was committed or rolled back.
126 func (_m *PayloadDigest) Update() *PayloadDigestUpdateOne {
127 return NewPayloadDigestClient(_m.config).UpdateOne(_m)
128 }
129
130 // Unwrap unwraps the PayloadDigest entity that was returned from a transaction after it was closed,
131 // so that all future queries will be executed through the driver which created the transaction.
132 func (_m *PayloadDigest) Unwrap() *PayloadDigest {
133 _tx, ok := _m.config.driver.(*txDriver)
134 if !ok {
135 panic("ent: PayloadDigest is not a transactional entity")
136 }
137 _m.config.driver = _tx.drv
138 return _m
139 }
140
141 // String implements the fmt.Stringer.
142 func (_m *PayloadDigest) String() string {
143 var builder strings.Builder
144 builder.WriteString("PayloadDigest(")
145 builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
146 builder.WriteString("algorithm=")
147 builder.WriteString(_m.Algorithm)
148 builder.WriteString(", ")
149 builder.WriteString("value=")
150 builder.WriteString(_m.Value)
151 builder.WriteByte(')')
152 return builder.String()
153 }
154
155 // PayloadDigests is a parsable slice of PayloadDigest.
156 type PayloadDigests []*PayloadDigest