Debian Codegraph @

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