Debian Codegraph @

ent/client.go

raw
1 // Code generated by ent, DO NOT EDIT.
2
3 package ent
4
5 import (
6 "context"
7 "errors"
8 "fmt"
9 "log"
10 "reflect"
11
12 "github.com/google/uuid"
13 "github.com/in-toto/archivista/ent/migrate"
14
15 "entgo.io/ent"
16 "entgo.io/ent/dialect"
17 "entgo.io/ent/dialect/sql"
18 "entgo.io/ent/dialect/sql/sqlgraph"
19 "github.com/in-toto/archivista/ent/attestation"
20 "github.com/in-toto/archivista/ent/attestationcollection"
21 "github.com/in-toto/archivista/ent/attestationpolicy"
22 "github.com/in-toto/archivista/ent/dsse"
23 "github.com/in-toto/archivista/ent/payloaddigest"
24 "github.com/in-toto/archivista/ent/signature"
25 "github.com/in-toto/archivista/ent/statement"
26 "github.com/in-toto/archivista/ent/subject"
27 "github.com/in-toto/archivista/ent/subjectdigest"
28 "github.com/in-toto/archivista/ent/timestamp"
29 )
30
31 // Client is the client that holds all ent builders.
32 type Client struct {
33 config
34 // Schema is the client for creating, migrating and dropping schema.
35 Schema *migrate.Schema
36 // Attestation is the client for interacting with the Attestation builders.
37 Attestation *AttestationClient
38 // AttestationCollection is the client for interacting with the AttestationCollection builders.
39 AttestationCollection *AttestationCollectionClient
40 // AttestationPolicy is the client for interacting with the AttestationPolicy builders.
41 AttestationPolicy *AttestationPolicyClient
42 // Dsse is the client for interacting with the Dsse builders.
43 Dsse *DsseClient
44 // PayloadDigest is the client for interacting with the PayloadDigest builders.
45 PayloadDigest *PayloadDigestClient
46 // Signature is the client for interacting with the Signature builders.
47 Signature *SignatureClient
48 // Statement is the client for interacting with the Statement builders.
49 Statement *StatementClient
50 // Subject is the client for interacting with the Subject builders.
51 Subject *SubjectClient
52 // SubjectDigest is the client for interacting with the SubjectDigest builders.
53 SubjectDigest *SubjectDigestClient
54 // Timestamp is the client for interacting with the Timestamp builders.
55 Timestamp *TimestampClient
56 }
57
58 // NewClient creates a new client configured with the given options.
59 func NewClient(opts ...Option) *Client {
60 client := &Client{config: newConfig(opts...)}
61 client.init()
62 return client
63 }
64
65 func (c *Client) init() {
66 c.Schema = migrate.NewSchema(c.driver)
67 c.Attestation = NewAttestationClient(c.config)
68 c.AttestationCollection = NewAttestationCollectionClient(c.config)
69 c.AttestationPolicy = NewAttestationPolicyClient(c.config)
70 c.Dsse = NewDsseClient(c.config)
71 c.PayloadDigest = NewPayloadDigestClient(c.config)
72 c.Signature = NewSignatureClient(c.config)
73 c.Statement = NewStatementClient(c.config)
74 c.Subject = NewSubjectClient(c.config)
75 c.SubjectDigest = NewSubjectDigestClient(c.config)
76 c.Timestamp = NewTimestampClient(c.config)
77 }
78
79 type (
80 // config is the configuration for the client and its builder.
81 config struct {
82 // driver used for executing database requests.
83 driver dialect.Driver
84 // debug enable a debug logging.
85 debug bool
86 // log used for logging on debug mode.
87 log func(...any)
88 // hooks to execute on mutations.
89 hooks *hooks
90 // interceptors to execute on queries.
91 inters *inters
92 }
93 // Option function to configure the client.
94 Option func(*config)
95 )
96
97 // newConfig creates a new config for the client.
98 func newConfig(opts ...Option) config {
99 cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
100 cfg.options(opts...)
101 return cfg
102 }
103
104 // options applies the options on the config object.
105 func (c *config) options(opts ...Option) {
106 for _, opt := range opts {
107 opt(c)
108 }
109 if c.debug {
110 c.driver = dialect.Debug(c.driver, c.log)
111 }
112 }
113
114 // Debug enables debug logging on the ent.Driver.
115 func Debug() Option {
116 return func(c *config) {
117 c.debug = true
118 }
119 }
120
121 // Log sets the logging function for debug mode.
122 func Log(fn func(...any)) Option {
123 return func(c *config) {
124 c.log = fn
125 }
126 }
127
128 // Driver configures the client driver.
129 func Driver(driver dialect.Driver) Option {
130 return func(c *config) {
131 c.driver = driver
132 }
133 }
134
135 // Open opens a database/sql.DB specified by the driver name and
136 // the data source name, and returns a new client attached to it.
137 // Optional parameters can be added for configuring the client.
138 func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
139 switch driverName {
140 case dialect.MySQL, dialect.Postgres, dialect.SQLite:
141 drv, err := sql.Open(driverName, dataSourceName)
142 if err != nil {
143 return nil, err
144 }
145 return NewClient(append(options, Driver(drv))...), nil
146 default:
147 return nil, fmt.Errorf("unsupported driver: %q", driverName)
148 }
149 }
150
151 // ErrTxStarted is returned when trying to start a new transaction from a transactional client.
152 var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
153
154 // Tx returns a new transactional client. The provided context
155 // is used until the transaction is committed or rolled back.
156 func (c *Client) Tx(ctx context.Context) (*Tx, error) {
157 if _, ok := c.driver.(*txDriver); ok {
158 return nil, ErrTxStarted
159 }
160 tx, err := newTx(ctx, c.driver)
161 if err != nil {
162 return nil, fmt.Errorf("ent: starting a transaction: %w", err)
163 }
164 cfg := c.config
165 cfg.driver = tx
166 return &Tx{
167 ctx: ctx,
168 config: cfg,
169 Attestation: NewAttestationClient(cfg),
170 AttestationCollection: NewAttestationCollectionClient(cfg),
171 AttestationPolicy: NewAttestationPolicyClient(cfg),
172 Dsse: NewDsseClient(cfg),
173 PayloadDigest: NewPayloadDigestClient(cfg),
174 Signature: NewSignatureClient(cfg),
175 Statement: NewStatementClient(cfg),
176 Subject: NewSubjectClient(cfg),
177 SubjectDigest: NewSubjectDigestClient(cfg),
178 Timestamp: NewTimestampClient(cfg),
179 }, nil
180 }
181
182 // BeginTx returns a transactional client with specified options.
183 func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
184 if _, ok := c.driver.(*txDriver); ok {
185 return nil, errors.New("ent: cannot start a transaction within a transaction")
186 }
187 tx, err := c.driver.(interface {
188 BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
189 }).BeginTx(ctx, opts)
190 if err != nil {
191 return nil, fmt.Errorf("ent: starting a transaction: %w", err)
192 }
193 cfg := c.config
194 cfg.driver = &txDriver{tx: tx, drv: c.driver}
195 return &Tx{
196 ctx: ctx,
197 config: cfg,
198 Attestation: NewAttestationClient(cfg),
199 AttestationCollection: NewAttestationCollectionClient(cfg),
200 AttestationPolicy: NewAttestationPolicyClient(cfg),
201 Dsse: NewDsseClient(cfg),
202 PayloadDigest: NewPayloadDigestClient(cfg),
203 Signature: NewSignatureClient(cfg),
204 Statement: NewStatementClient(cfg),
205 Subject: NewSubjectClient(cfg),
206 SubjectDigest: NewSubjectDigestClient(cfg),
207 Timestamp: NewTimestampClient(cfg),
208 }, nil
209 }
210
211 // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
212 //
213 // client.Debug().
214 // Attestation.
215 // Query().
216 // Count(ctx)
217 func (c *Client) Debug() *Client {
218 if c.debug {
219 return c
220 }
221 cfg := c.config
222 cfg.driver = dialect.Debug(c.driver, c.log)
223 client := &Client{config: cfg}
224 client.init()
225 return client
226 }
227
228 // Close closes the database connection and prevents new queries from starting.
229 func (c *Client) Close() error {
230 return c.driver.Close()
231 }
232
233 // Use adds the mutation hooks to all the entity clients.
234 // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
235 func (c *Client) Use(hooks ...Hook) {
236 for _, n := range []interface{ Use(...Hook) }{
237 c.Attestation, c.AttestationCollection, c.AttestationPolicy, c.Dsse,
238 c.PayloadDigest, c.Signature, c.Statement, c.Subject, c.SubjectDigest,
239 c.Timestamp,
240 } {
241 n.Use(hooks...)
242 }
243 }
244
245 // Intercept adds the query interceptors to all the entity clients.
246 // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
247 func (c *Client) Intercept(interceptors ...Interceptor) {
248 for _, n := range []interface{ Intercept(...Interceptor) }{
249 c.Attestation, c.AttestationCollection, c.AttestationPolicy, c.Dsse,
250 c.PayloadDigest, c.Signature, c.Statement, c.Subject, c.SubjectDigest,
251 c.Timestamp,
252 } {
253 n.Intercept(interceptors...)
254 }
255 }
256
257 // Mutate implements the ent.Mutator interface.
258 func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
259 switch m := m.(type) {
260 case *AttestationMutation:
261 return c.Attestation.mutate(ctx, m)
262 case *AttestationCollectionMutation:
263 return c.AttestationCollection.mutate(ctx, m)
264 case *AttestationPolicyMutation:
265 return c.AttestationPolicy.mutate(ctx, m)
266 case *DsseMutation:
267 return c.Dsse.mutate(ctx, m)
268 case *PayloadDigestMutation:
269 return c.PayloadDigest.mutate(ctx, m)
270 case *SignatureMutation:
271 return c.Signature.mutate(ctx, m)
272 case *StatementMutation:
273 return c.Statement.mutate(ctx, m)
274 case *SubjectMutation:
275 return c.Subject.mutate(ctx, m)
276 case *SubjectDigestMutation:
277 return c.SubjectDigest.mutate(ctx, m)
278 case *TimestampMutation:
279 return c.Timestamp.mutate(ctx, m)
280 default:
281 return nil, fmt.Errorf("ent: unknown mutation type %T", m)
282 }
283 }
284
285 // AttestationClient is a client for the Attestation schema.
286 type AttestationClient struct {
287 config
288 }
289
290 // NewAttestationClient returns a client for the Attestation from the given config.
291 func NewAttestationClient(c config) *AttestationClient {
292 return &AttestationClient{config: c}
293 }
294
295 // Use adds a list of mutation hooks to the hooks stack.
296 // A call to `Use(f, g, h)` equals to `attestation.Hooks(f(g(h())))`.
297 func (c *AttestationClient) Use(hooks ...Hook) {
298 c.hooks.Attestation = append(c.hooks.Attestation, hooks...)
299 }
300
301 // Intercept adds a list of query interceptors to the interceptors stack.
302 // A call to `Intercept(f, g, h)` equals to `attestation.Intercept(f(g(h())))`.
303 func (c *AttestationClient) Intercept(interceptors ...Interceptor) {
304 c.inters.Attestation = append(c.inters.Attestation, interceptors...)
305 }
306
307 // Create returns a builder for creating a Attestation entity.
308 func (c *AttestationClient) Create() *AttestationCreate {
309 mutation := newAttestationMutation(c.config, OpCreate)
310 return &AttestationCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
311 }
312
313 // CreateBulk returns a builder for creating a bulk of Attestation entities.
314 func (c *AttestationClient) CreateBulk(builders ...*AttestationCreate) *AttestationCreateBulk {
315 return &AttestationCreateBulk{config: c.config, builders: builders}
316 }
317
318 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
319 // a builder and applies setFunc on it.
320 func (c *AttestationClient) MapCreateBulk(slice any, setFunc func(*AttestationCreate, int)) *AttestationCreateBulk {
321 rv := reflect.ValueOf(slice)
322 if rv.Kind() != reflect.Slice {
323 return &AttestationCreateBulk{err: fmt.Errorf("calling to AttestationClient.MapCreateBulk with wrong type %T, need slice", slice)}
324 }
325 builders := make([]*AttestationCreate, rv.Len())
326 for i := 0; i < rv.Len(); i++ {
327 builders[i] = c.Create()
328 setFunc(builders[i], i)
329 }
330 return &AttestationCreateBulk{config: c.config, builders: builders}
331 }
332
333 // Update returns an update builder for Attestation.
334 func (c *AttestationClient) Update() *AttestationUpdate {
335 mutation := newAttestationMutation(c.config, OpUpdate)
336 return &AttestationUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
337 }
338
339 // UpdateOne returns an update builder for the given entity.
340 func (c *AttestationClient) UpdateOne(_m *Attestation) *AttestationUpdateOne {
341 mutation := newAttestationMutation(c.config, OpUpdateOne, withAttestation(_m))
342 return &AttestationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
343 }
344
345 // UpdateOneID returns an update builder for the given id.
346 func (c *AttestationClient) UpdateOneID(id uuid.UUID) *AttestationUpdateOne {
347 mutation := newAttestationMutation(c.config, OpUpdateOne, withAttestationID(id))
348 return &AttestationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
349 }
350
351 // Delete returns a delete builder for Attestation.
352 func (c *AttestationClient) Delete() *AttestationDelete {
353 mutation := newAttestationMutation(c.config, OpDelete)
354 return &AttestationDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
355 }
356
357 // DeleteOne returns a builder for deleting the given entity.
358 func (c *AttestationClient) DeleteOne(_m *Attestation) *AttestationDeleteOne {
359 return c.DeleteOneID(_m.ID)
360 }
361
362 // DeleteOneID returns a builder for deleting the given entity by its id.
363 func (c *AttestationClient) DeleteOneID(id uuid.UUID) *AttestationDeleteOne {
364 builder := c.Delete().Where(attestation.ID(id))
365 builder.mutation.id = &id
366 builder.mutation.op = OpDeleteOne
367 return &AttestationDeleteOne{builder}
368 }
369
370 // Query returns a query builder for Attestation.
371 func (c *AttestationClient) Query() *AttestationQuery {
372 return &AttestationQuery{
373 config: c.config,
374 ctx: &QueryContext{Type: TypeAttestation},
375 inters: c.Interceptors(),
376 }
377 }
378
379 // Get returns a Attestation entity by its id.
380 func (c *AttestationClient) Get(ctx context.Context, id uuid.UUID) (*Attestation, error) {
381 return c.Query().Where(attestation.ID(id)).Only(ctx)
382 }
383
384 // GetX is like Get, but panics if an error occurs.
385 func (c *AttestationClient) GetX(ctx context.Context, id uuid.UUID) *Attestation {
386 obj, err := c.Get(ctx, id)
387 if err != nil {
388 panic(err)
389 }
390 return obj
391 }
392
393 // QueryAttestationCollection queries the attestation_collection edge of a Attestation.
394 func (c *AttestationClient) QueryAttestationCollection(_m *Attestation) *AttestationCollectionQuery {
395 query := (&AttestationCollectionClient{config: c.config}).Query()
396 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
397 id := _m.ID
398 step := sqlgraph.NewStep(
399 sqlgraph.From(attestation.Table, attestation.FieldID, id),
400 sqlgraph.To(attestationcollection.Table, attestationcollection.FieldID),
401 sqlgraph.Edge(sqlgraph.M2O, true, attestation.AttestationCollectionTable, attestation.AttestationCollectionColumn),
402 )
403 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
404 return fromV, nil
405 }
406 return query
407 }
408
409 // Hooks returns the client hooks.
410 func (c *AttestationClient) Hooks() []Hook {
411 return c.hooks.Attestation
412 }
413
414 // Interceptors returns the client interceptors.
415 func (c *AttestationClient) Interceptors() []Interceptor {
416 return c.inters.Attestation
417 }
418
419 func (c *AttestationClient) mutate(ctx context.Context, m *AttestationMutation) (Value, error) {
420 switch m.Op() {
421 case OpCreate:
422 return (&AttestationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
423 case OpUpdate:
424 return (&AttestationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
425 case OpUpdateOne:
426 return (&AttestationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
427 case OpDelete, OpDeleteOne:
428 return (&AttestationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
429 default:
430 return nil, fmt.Errorf("ent: unknown Attestation mutation op: %q", m.Op())
431 }
432 }
433
434 // AttestationCollectionClient is a client for the AttestationCollection schema.
435 type AttestationCollectionClient struct {
436 config
437 }
438
439 // NewAttestationCollectionClient returns a client for the AttestationCollection from the given config.
440 func NewAttestationCollectionClient(c config) *AttestationCollectionClient {
441 return &AttestationCollectionClient{config: c}
442 }
443
444 // Use adds a list of mutation hooks to the hooks stack.
445 // A call to `Use(f, g, h)` equals to `attestationcollection.Hooks(f(g(h())))`.
446 func (c *AttestationCollectionClient) Use(hooks ...Hook) {
447 c.hooks.AttestationCollection = append(c.hooks.AttestationCollection, hooks...)
448 }
449
450 // Intercept adds a list of query interceptors to the interceptors stack.
451 // A call to `Intercept(f, g, h)` equals to `attestationcollection.Intercept(f(g(h())))`.
452 func (c *AttestationCollectionClient) Intercept(interceptors ...Interceptor) {
453 c.inters.AttestationCollection = append(c.inters.AttestationCollection, interceptors...)
454 }
455
456 // Create returns a builder for creating a AttestationCollection entity.
457 func (c *AttestationCollectionClient) Create() *AttestationCollectionCreate {
458 mutation := newAttestationCollectionMutation(c.config, OpCreate)
459 return &AttestationCollectionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
460 }
461
462 // CreateBulk returns a builder for creating a bulk of AttestationCollection entities.
463 func (c *AttestationCollectionClient) CreateBulk(builders ...*AttestationCollectionCreate) *AttestationCollectionCreateBulk {
464 return &AttestationCollectionCreateBulk{config: c.config, builders: builders}
465 }
466
467 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
468 // a builder and applies setFunc on it.
469 func (c *AttestationCollectionClient) MapCreateBulk(slice any, setFunc func(*AttestationCollectionCreate, int)) *AttestationCollectionCreateBulk {
470 rv := reflect.ValueOf(slice)
471 if rv.Kind() != reflect.Slice {
472 return &AttestationCollectionCreateBulk{err: fmt.Errorf("calling to AttestationCollectionClient.MapCreateBulk with wrong type %T, need slice", slice)}
473 }
474 builders := make([]*AttestationCollectionCreate, rv.Len())
475 for i := 0; i < rv.Len(); i++ {
476 builders[i] = c.Create()
477 setFunc(builders[i], i)
478 }
479 return &AttestationCollectionCreateBulk{config: c.config, builders: builders}
480 }
481
482 // Update returns an update builder for AttestationCollection.
483 func (c *AttestationCollectionClient) Update() *AttestationCollectionUpdate {
484 mutation := newAttestationCollectionMutation(c.config, OpUpdate)
485 return &AttestationCollectionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
486 }
487
488 // UpdateOne returns an update builder for the given entity.
489 func (c *AttestationCollectionClient) UpdateOne(_m *AttestationCollection) *AttestationCollectionUpdateOne {
490 mutation := newAttestationCollectionMutation(c.config, OpUpdateOne, withAttestationCollection(_m))
491 return &AttestationCollectionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
492 }
493
494 // UpdateOneID returns an update builder for the given id.
495 func (c *AttestationCollectionClient) UpdateOneID(id uuid.UUID) *AttestationCollectionUpdateOne {
496 mutation := newAttestationCollectionMutation(c.config, OpUpdateOne, withAttestationCollectionID(id))
497 return &AttestationCollectionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
498 }
499
500 // Delete returns a delete builder for AttestationCollection.
501 func (c *AttestationCollectionClient) Delete() *AttestationCollectionDelete {
502 mutation := newAttestationCollectionMutation(c.config, OpDelete)
503 return &AttestationCollectionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
504 }
505
506 // DeleteOne returns a builder for deleting the given entity.
507 func (c *AttestationCollectionClient) DeleteOne(_m *AttestationCollection) *AttestationCollectionDeleteOne {
508 return c.DeleteOneID(_m.ID)
509 }
510
511 // DeleteOneID returns a builder for deleting the given entity by its id.
512 func (c *AttestationCollectionClient) DeleteOneID(id uuid.UUID) *AttestationCollectionDeleteOne {
513 builder := c.Delete().Where(attestationcollection.ID(id))
514 builder.mutation.id = &id
515 builder.mutation.op = OpDeleteOne
516 return &AttestationCollectionDeleteOne{builder}
517 }
518
519 // Query returns a query builder for AttestationCollection.
520 func (c *AttestationCollectionClient) Query() *AttestationCollectionQuery {
521 return &AttestationCollectionQuery{
522 config: c.config,
523 ctx: &QueryContext{Type: TypeAttestationCollection},
524 inters: c.Interceptors(),
525 }
526 }
527
528 // Get returns a AttestationCollection entity by its id.
529 func (c *AttestationCollectionClient) Get(ctx context.Context, id uuid.UUID) (*AttestationCollection, error) {
530 return c.Query().Where(attestationcollection.ID(id)).Only(ctx)
531 }
532
533 // GetX is like Get, but panics if an error occurs.
534 func (c *AttestationCollectionClient) GetX(ctx context.Context, id uuid.UUID) *AttestationCollection {
535 obj, err := c.Get(ctx, id)
536 if err != nil {
537 panic(err)
538 }
539 return obj
540 }
541
542 // QueryAttestations queries the attestations edge of a AttestationCollection.
543 func (c *AttestationCollectionClient) QueryAttestations(_m *AttestationCollection) *AttestationQuery {
544 query := (&AttestationClient{config: c.config}).Query()
545 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
546 id := _m.ID
547 step := sqlgraph.NewStep(
548 sqlgraph.From(attestationcollection.Table, attestationcollection.FieldID, id),
549 sqlgraph.To(attestation.Table, attestation.FieldID),
550 sqlgraph.Edge(sqlgraph.O2M, false, attestationcollection.AttestationsTable, attestationcollection.AttestationsColumn),
551 )
552 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
553 return fromV, nil
554 }
555 return query
556 }
557
558 // QueryStatement queries the statement edge of a AttestationCollection.
559 func (c *AttestationCollectionClient) QueryStatement(_m *AttestationCollection) *StatementQuery {
560 query := (&StatementClient{config: c.config}).Query()
561 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
562 id := _m.ID
563 step := sqlgraph.NewStep(
564 sqlgraph.From(attestationcollection.Table, attestationcollection.FieldID, id),
565 sqlgraph.To(statement.Table, statement.FieldID),
566 sqlgraph.Edge(sqlgraph.O2O, true, attestationcollection.StatementTable, attestationcollection.StatementColumn),
567 )
568 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
569 return fromV, nil
570 }
571 return query
572 }
573
574 // Hooks returns the client hooks.
575 func (c *AttestationCollectionClient) Hooks() []Hook {
576 return c.hooks.AttestationCollection
577 }
578
579 // Interceptors returns the client interceptors.
580 func (c *AttestationCollectionClient) Interceptors() []Interceptor {
581 return c.inters.AttestationCollection
582 }
583
584 func (c *AttestationCollectionClient) mutate(ctx context.Context, m *AttestationCollectionMutation) (Value, error) {
585 switch m.Op() {
586 case OpCreate:
587 return (&AttestationCollectionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
588 case OpUpdate:
589 return (&AttestationCollectionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
590 case OpUpdateOne:
591 return (&AttestationCollectionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
592 case OpDelete, OpDeleteOne:
593 return (&AttestationCollectionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
594 default:
595 return nil, fmt.Errorf("ent: unknown AttestationCollection mutation op: %q", m.Op())
596 }
597 }
598
599 // AttestationPolicyClient is a client for the AttestationPolicy schema.
600 type AttestationPolicyClient struct {
601 config
602 }
603
604 // NewAttestationPolicyClient returns a client for the AttestationPolicy from the given config.
605 func NewAttestationPolicyClient(c config) *AttestationPolicyClient {
606 return &AttestationPolicyClient{config: c}
607 }
608
609 // Use adds a list of mutation hooks to the hooks stack.
610 // A call to `Use(f, g, h)` equals to `attestationpolicy.Hooks(f(g(h())))`.
611 func (c *AttestationPolicyClient) Use(hooks ...Hook) {
612 c.hooks.AttestationPolicy = append(c.hooks.AttestationPolicy, hooks...)
613 }
614
615 // Intercept adds a list of query interceptors to the interceptors stack.
616 // A call to `Intercept(f, g, h)` equals to `attestationpolicy.Intercept(f(g(h())))`.
617 func (c *AttestationPolicyClient) Intercept(interceptors ...Interceptor) {
618 c.inters.AttestationPolicy = append(c.inters.AttestationPolicy, interceptors...)
619 }
620
621 // Create returns a builder for creating a AttestationPolicy entity.
622 func (c *AttestationPolicyClient) Create() *AttestationPolicyCreate {
623 mutation := newAttestationPolicyMutation(c.config, OpCreate)
624 return &AttestationPolicyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
625 }
626
627 // CreateBulk returns a builder for creating a bulk of AttestationPolicy entities.
628 func (c *AttestationPolicyClient) CreateBulk(builders ...*AttestationPolicyCreate) *AttestationPolicyCreateBulk {
629 return &AttestationPolicyCreateBulk{config: c.config, builders: builders}
630 }
631
632 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
633 // a builder and applies setFunc on it.
634 func (c *AttestationPolicyClient) MapCreateBulk(slice any, setFunc func(*AttestationPolicyCreate, int)) *AttestationPolicyCreateBulk {
635 rv := reflect.ValueOf(slice)
636 if rv.Kind() != reflect.Slice {
637 return &AttestationPolicyCreateBulk{err: fmt.Errorf("calling to AttestationPolicyClient.MapCreateBulk with wrong type %T, need slice", slice)}
638 }
639 builders := make([]*AttestationPolicyCreate, rv.Len())
640 for i := 0; i < rv.Len(); i++ {
641 builders[i] = c.Create()
642 setFunc(builders[i], i)
643 }
644 return &AttestationPolicyCreateBulk{config: c.config, builders: builders}
645 }
646
647 // Update returns an update builder for AttestationPolicy.
648 func (c *AttestationPolicyClient) Update() *AttestationPolicyUpdate {
649 mutation := newAttestationPolicyMutation(c.config, OpUpdate)
650 return &AttestationPolicyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
651 }
652
653 // UpdateOne returns an update builder for the given entity.
654 func (c *AttestationPolicyClient) UpdateOne(_m *AttestationPolicy) *AttestationPolicyUpdateOne {
655 mutation := newAttestationPolicyMutation(c.config, OpUpdateOne, withAttestationPolicy(_m))
656 return &AttestationPolicyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
657 }
658
659 // UpdateOneID returns an update builder for the given id.
660 func (c *AttestationPolicyClient) UpdateOneID(id uuid.UUID) *AttestationPolicyUpdateOne {
661 mutation := newAttestationPolicyMutation(c.config, OpUpdateOne, withAttestationPolicyID(id))
662 return &AttestationPolicyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
663 }
664
665 // Delete returns a delete builder for AttestationPolicy.
666 func (c *AttestationPolicyClient) Delete() *AttestationPolicyDelete {
667 mutation := newAttestationPolicyMutation(c.config, OpDelete)
668 return &AttestationPolicyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
669 }
670
671 // DeleteOne returns a builder for deleting the given entity.
672 func (c *AttestationPolicyClient) DeleteOne(_m *AttestationPolicy) *AttestationPolicyDeleteOne {
673 return c.DeleteOneID(_m.ID)
674 }
675
676 // DeleteOneID returns a builder for deleting the given entity by its id.
677 func (c *AttestationPolicyClient) DeleteOneID(id uuid.UUID) *AttestationPolicyDeleteOne {
678 builder := c.Delete().Where(attestationpolicy.ID(id))
679 builder.mutation.id = &id
680 builder.mutation.op = OpDeleteOne
681 return &AttestationPolicyDeleteOne{builder}
682 }
683
684 // Query returns a query builder for AttestationPolicy.
685 func (c *AttestationPolicyClient) Query() *AttestationPolicyQuery {
686 return &AttestationPolicyQuery{
687 config: c.config,
688 ctx: &QueryContext{Type: TypeAttestationPolicy},
689 inters: c.Interceptors(),
690 }
691 }
692
693 // Get returns a AttestationPolicy entity by its id.
694 func (c *AttestationPolicyClient) Get(ctx context.Context, id uuid.UUID) (*AttestationPolicy, error) {
695 return c.Query().Where(attestationpolicy.ID(id)).Only(ctx)
696 }
697
698 // GetX is like Get, but panics if an error occurs.
699 func (c *AttestationPolicyClient) GetX(ctx context.Context, id uuid.UUID) *AttestationPolicy {
700 obj, err := c.Get(ctx, id)
701 if err != nil {
702 panic(err)
703 }
704 return obj
705 }
706
707 // QueryStatement queries the statement edge of a AttestationPolicy.
708 func (c *AttestationPolicyClient) QueryStatement(_m *AttestationPolicy) *StatementQuery {
709 query := (&StatementClient{config: c.config}).Query()
710 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
711 id := _m.ID
712 step := sqlgraph.NewStep(
713 sqlgraph.From(attestationpolicy.Table, attestationpolicy.FieldID, id),
714 sqlgraph.To(statement.Table, statement.FieldID),
715 sqlgraph.Edge(sqlgraph.O2O, true, attestationpolicy.StatementTable, attestationpolicy.StatementColumn),
716 )
717 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
718 return fromV, nil
719 }
720 return query
721 }
722
723 // Hooks returns the client hooks.
724 func (c *AttestationPolicyClient) Hooks() []Hook {
725 return c.hooks.AttestationPolicy
726 }
727
728 // Interceptors returns the client interceptors.
729 func (c *AttestationPolicyClient) Interceptors() []Interceptor {
730 return c.inters.AttestationPolicy
731 }
732
733 func (c *AttestationPolicyClient) mutate(ctx context.Context, m *AttestationPolicyMutation) (Value, error) {
734 switch m.Op() {
735 case OpCreate:
736 return (&AttestationPolicyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
737 case OpUpdate:
738 return (&AttestationPolicyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
739 case OpUpdateOne:
740 return (&AttestationPolicyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
741 case OpDelete, OpDeleteOne:
742 return (&AttestationPolicyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
743 default:
744 return nil, fmt.Errorf("ent: unknown AttestationPolicy mutation op: %q", m.Op())
745 }
746 }
747
748 // DsseClient is a client for the Dsse schema.
749 type DsseClient struct {
750 config
751 }
752
753 // NewDsseClient returns a client for the Dsse from the given config.
754 func NewDsseClient(c config) *DsseClient {
755 return &DsseClient{config: c}
756 }
757
758 // Use adds a list of mutation hooks to the hooks stack.
759 // A call to `Use(f, g, h)` equals to `dsse.Hooks(f(g(h())))`.
760 func (c *DsseClient) Use(hooks ...Hook) {
761 c.hooks.Dsse = append(c.hooks.Dsse, hooks...)
762 }
763
764 // Intercept adds a list of query interceptors to the interceptors stack.
765 // A call to `Intercept(f, g, h)` equals to `dsse.Intercept(f(g(h())))`.
766 func (c *DsseClient) Intercept(interceptors ...Interceptor) {
767 c.inters.Dsse = append(c.inters.Dsse, interceptors...)
768 }
769
770 // Create returns a builder for creating a Dsse entity.
771 func (c *DsseClient) Create() *DsseCreate {
772 mutation := newDsseMutation(c.config, OpCreate)
773 return &DsseCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
774 }
775
776 // CreateBulk returns a builder for creating a bulk of Dsse entities.
777 func (c *DsseClient) CreateBulk(builders ...*DsseCreate) *DsseCreateBulk {
778 return &DsseCreateBulk{config: c.config, builders: builders}
779 }
780
781 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
782 // a builder and applies setFunc on it.
783 func (c *DsseClient) MapCreateBulk(slice any, setFunc func(*DsseCreate, int)) *DsseCreateBulk {
784 rv := reflect.ValueOf(slice)
785 if rv.Kind() != reflect.Slice {
786 return &DsseCreateBulk{err: fmt.Errorf("calling to DsseClient.MapCreateBulk with wrong type %T, need slice", slice)}
787 }
788 builders := make([]*DsseCreate, rv.Len())
789 for i := 0; i < rv.Len(); i++ {
790 builders[i] = c.Create()
791 setFunc(builders[i], i)
792 }
793 return &DsseCreateBulk{config: c.config, builders: builders}
794 }
795
796 // Update returns an update builder for Dsse.
797 func (c *DsseClient) Update() *DsseUpdate {
798 mutation := newDsseMutation(c.config, OpUpdate)
799 return &DsseUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
800 }
801
802 // UpdateOne returns an update builder for the given entity.
803 func (c *DsseClient) UpdateOne(_m *Dsse) *DsseUpdateOne {
804 mutation := newDsseMutation(c.config, OpUpdateOne, withDsse(_m))
805 return &DsseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
806 }
807
808 // UpdateOneID returns an update builder for the given id.
809 func (c *DsseClient) UpdateOneID(id uuid.UUID) *DsseUpdateOne {
810 mutation := newDsseMutation(c.config, OpUpdateOne, withDsseID(id))
811 return &DsseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
812 }
813
814 // Delete returns a delete builder for Dsse.
815 func (c *DsseClient) Delete() *DsseDelete {
816 mutation := newDsseMutation(c.config, OpDelete)
817 return &DsseDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
818 }
819
820 // DeleteOne returns a builder for deleting the given entity.
821 func (c *DsseClient) DeleteOne(_m *Dsse) *DsseDeleteOne {
822 return c.DeleteOneID(_m.ID)
823 }
824
825 // DeleteOneID returns a builder for deleting the given entity by its id.
826 func (c *DsseClient) DeleteOneID(id uuid.UUID) *DsseDeleteOne {
827 builder := c.Delete().Where(dsse.ID(id))
828 builder.mutation.id = &id
829 builder.mutation.op = OpDeleteOne
830 return &DsseDeleteOne{builder}
831 }
832
833 // Query returns a query builder for Dsse.
834 func (c *DsseClient) Query() *DsseQuery {
835 return &DsseQuery{
836 config: c.config,
837 ctx: &QueryContext{Type: TypeDsse},
838 inters: c.Interceptors(),
839 }
840 }
841
842 // Get returns a Dsse entity by its id.
843 func (c *DsseClient) Get(ctx context.Context, id uuid.UUID) (*Dsse, error) {
844 return c.Query().Where(dsse.ID(id)).Only(ctx)
845 }
846
847 // GetX is like Get, but panics if an error occurs.
848 func (c *DsseClient) GetX(ctx context.Context, id uuid.UUID) *Dsse {
849 obj, err := c.Get(ctx, id)
850 if err != nil {
851 panic(err)
852 }
853 return obj
854 }
855
856 // QueryStatement queries the statement edge of a Dsse.
857 func (c *DsseClient) QueryStatement(_m *Dsse) *StatementQuery {
858 query := (&StatementClient{config: c.config}).Query()
859 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
860 id := _m.ID
861 step := sqlgraph.NewStep(
862 sqlgraph.From(dsse.Table, dsse.FieldID, id),
863 sqlgraph.To(statement.Table, statement.FieldID),
864 sqlgraph.Edge(sqlgraph.M2O, false, dsse.StatementTable, dsse.StatementColumn),
865 )
866 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
867 return fromV, nil
868 }
869 return query
870 }
871
872 // QuerySignatures queries the signatures edge of a Dsse.
873 func (c *DsseClient) QuerySignatures(_m *Dsse) *SignatureQuery {
874 query := (&SignatureClient{config: c.config}).Query()
875 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
876 id := _m.ID
877 step := sqlgraph.NewStep(
878 sqlgraph.From(dsse.Table, dsse.FieldID, id),
879 sqlgraph.To(signature.Table, signature.FieldID),
880 sqlgraph.Edge(sqlgraph.O2M, false, dsse.SignaturesTable, dsse.SignaturesColumn),
881 )
882 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
883 return fromV, nil
884 }
885 return query
886 }
887
888 // QueryPayloadDigests queries the payload_digests edge of a Dsse.
889 func (c *DsseClient) QueryPayloadDigests(_m *Dsse) *PayloadDigestQuery {
890 query := (&PayloadDigestClient{config: c.config}).Query()
891 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
892 id := _m.ID
893 step := sqlgraph.NewStep(
894 sqlgraph.From(dsse.Table, dsse.FieldID, id),
895 sqlgraph.To(payloaddigest.Table, payloaddigest.FieldID),
896 sqlgraph.Edge(sqlgraph.O2M, false, dsse.PayloadDigestsTable, dsse.PayloadDigestsColumn),
897 )
898 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
899 return fromV, nil
900 }
901 return query
902 }
903
904 // Hooks returns the client hooks.
905 func (c *DsseClient) Hooks() []Hook {
906 return c.hooks.Dsse
907 }
908
909 // Interceptors returns the client interceptors.
910 func (c *DsseClient) Interceptors() []Interceptor {
911 return c.inters.Dsse
912 }
913
914 func (c *DsseClient) mutate(ctx context.Context, m *DsseMutation) (Value, error) {
915 switch m.Op() {
916 case OpCreate:
917 return (&DsseCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
918 case OpUpdate:
919 return (&DsseUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
920 case OpUpdateOne:
921 return (&DsseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
922 case OpDelete, OpDeleteOne:
923 return (&DsseDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
924 default:
925 return nil, fmt.Errorf("ent: unknown Dsse mutation op: %q", m.Op())
926 }
927 }
928
929 // PayloadDigestClient is a client for the PayloadDigest schema.
930 type PayloadDigestClient struct {
931 config
932 }
933
934 // NewPayloadDigestClient returns a client for the PayloadDigest from the given config.
935 func NewPayloadDigestClient(c config) *PayloadDigestClient {
936 return &PayloadDigestClient{config: c}
937 }
938
939 // Use adds a list of mutation hooks to the hooks stack.
940 // A call to `Use(f, g, h)` equals to `payloaddigest.Hooks(f(g(h())))`.
941 func (c *PayloadDigestClient) Use(hooks ...Hook) {
942 c.hooks.PayloadDigest = append(c.hooks.PayloadDigest, hooks...)
943 }
944
945 // Intercept adds a list of query interceptors to the interceptors stack.
946 // A call to `Intercept(f, g, h)` equals to `payloaddigest.Intercept(f(g(h())))`.
947 func (c *PayloadDigestClient) Intercept(interceptors ...Interceptor) {
948 c.inters.PayloadDigest = append(c.inters.PayloadDigest, interceptors...)
949 }
950
951 // Create returns a builder for creating a PayloadDigest entity.
952 func (c *PayloadDigestClient) Create() *PayloadDigestCreate {
953 mutation := newPayloadDigestMutation(c.config, OpCreate)
954 return &PayloadDigestCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
955 }
956
957 // CreateBulk returns a builder for creating a bulk of PayloadDigest entities.
958 func (c *PayloadDigestClient) CreateBulk(builders ...*PayloadDigestCreate) *PayloadDigestCreateBulk {
959 return &PayloadDigestCreateBulk{config: c.config, builders: builders}
960 }
961
962 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
963 // a builder and applies setFunc on it.
964 func (c *PayloadDigestClient) MapCreateBulk(slice any, setFunc func(*PayloadDigestCreate, int)) *PayloadDigestCreateBulk {
965 rv := reflect.ValueOf(slice)
966 if rv.Kind() != reflect.Slice {
967 return &PayloadDigestCreateBulk{err: fmt.Errorf("calling to PayloadDigestClient.MapCreateBulk with wrong type %T, need slice", slice)}
968 }
969 builders := make([]*PayloadDigestCreate, rv.Len())
970 for i := 0; i < rv.Len(); i++ {
971 builders[i] = c.Create()
972 setFunc(builders[i], i)
973 }
974 return &PayloadDigestCreateBulk{config: c.config, builders: builders}
975 }
976
977 // Update returns an update builder for PayloadDigest.
978 func (c *PayloadDigestClient) Update() *PayloadDigestUpdate {
979 mutation := newPayloadDigestMutation(c.config, OpUpdate)
980 return &PayloadDigestUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
981 }
982
983 // UpdateOne returns an update builder for the given entity.
984 func (c *PayloadDigestClient) UpdateOne(_m *PayloadDigest) *PayloadDigestUpdateOne {
985 mutation := newPayloadDigestMutation(c.config, OpUpdateOne, withPayloadDigest(_m))
986 return &PayloadDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
987 }
988
989 // UpdateOneID returns an update builder for the given id.
990 func (c *PayloadDigestClient) UpdateOneID(id uuid.UUID) *PayloadDigestUpdateOne {
991 mutation := newPayloadDigestMutation(c.config, OpUpdateOne, withPayloadDigestID(id))
992 return &PayloadDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
993 }
994
995 // Delete returns a delete builder for PayloadDigest.
996 func (c *PayloadDigestClient) Delete() *PayloadDigestDelete {
997 mutation := newPayloadDigestMutation(c.config, OpDelete)
998 return &PayloadDigestDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
999 }
1000
1001 // DeleteOne returns a builder for deleting the given entity.
1002 func (c *PayloadDigestClient) DeleteOne(_m *PayloadDigest) *PayloadDigestDeleteOne {
1003 return c.DeleteOneID(_m.ID)
1004 }
1005
1006 // DeleteOneID returns a builder for deleting the given entity by its id.
1007 func (c *PayloadDigestClient) DeleteOneID(id uuid.UUID) *PayloadDigestDeleteOne {
1008 builder := c.Delete().Where(payloaddigest.ID(id))
1009 builder.mutation.id = &id
1010 builder.mutation.op = OpDeleteOne
1011 return &PayloadDigestDeleteOne{builder}
1012 }
1013
1014 // Query returns a query builder for PayloadDigest.
1015 func (c *PayloadDigestClient) Query() *PayloadDigestQuery {
1016 return &PayloadDigestQuery{
1017 config: c.config,
1018 ctx: &QueryContext{Type: TypePayloadDigest},
1019 inters: c.Interceptors(),
1020 }
1021 }
1022
1023 // Get returns a PayloadDigest entity by its id.
1024 func (c *PayloadDigestClient) Get(ctx context.Context, id uuid.UUID) (*PayloadDigest, error) {
1025 return c.Query().Where(payloaddigest.ID(id)).Only(ctx)
1026 }
1027
1028 // GetX is like Get, but panics if an error occurs.
1029 func (c *PayloadDigestClient) GetX(ctx context.Context, id uuid.UUID) *PayloadDigest {
1030 obj, err := c.Get(ctx, id)
1031 if err != nil {
1032 panic(err)
1033 }
1034 return obj
1035 }
1036
1037 // QueryDsse queries the dsse edge of a PayloadDigest.
1038 func (c *PayloadDigestClient) QueryDsse(_m *PayloadDigest) *DsseQuery {
1039 query := (&DsseClient{config: c.config}).Query()
1040 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1041 id := _m.ID
1042 step := sqlgraph.NewStep(
1043 sqlgraph.From(payloaddigest.Table, payloaddigest.FieldID, id),
1044 sqlgraph.To(dsse.Table, dsse.FieldID),
1045 sqlgraph.Edge(sqlgraph.M2O, true, payloaddigest.DsseTable, payloaddigest.DsseColumn),
1046 )
1047 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1048 return fromV, nil
1049 }
1050 return query
1051 }
1052
1053 // Hooks returns the client hooks.
1054 func (c *PayloadDigestClient) Hooks() []Hook {
1055 return c.hooks.PayloadDigest
1056 }
1057
1058 // Interceptors returns the client interceptors.
1059 func (c *PayloadDigestClient) Interceptors() []Interceptor {
1060 return c.inters.PayloadDigest
1061 }
1062
1063 func (c *PayloadDigestClient) mutate(ctx context.Context, m *PayloadDigestMutation) (Value, error) {
1064 switch m.Op() {
1065 case OpCreate:
1066 return (&PayloadDigestCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1067 case OpUpdate:
1068 return (&PayloadDigestUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1069 case OpUpdateOne:
1070 return (&PayloadDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1071 case OpDelete, OpDeleteOne:
1072 return (&PayloadDigestDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
1073 default:
1074 return nil, fmt.Errorf("ent: unknown PayloadDigest mutation op: %q", m.Op())
1075 }
1076 }
1077
1078 // SignatureClient is a client for the Signature schema.
1079 type SignatureClient struct {
1080 config
1081 }
1082
1083 // NewSignatureClient returns a client for the Signature from the given config.
1084 func NewSignatureClient(c config) *SignatureClient {
1085 return &SignatureClient{config: c}
1086 }
1087
1088 // Use adds a list of mutation hooks to the hooks stack.
1089 // A call to `Use(f, g, h)` equals to `signature.Hooks(f(g(h())))`.
1090 func (c *SignatureClient) Use(hooks ...Hook) {
1091 c.hooks.Signature = append(c.hooks.Signature, hooks...)
1092 }
1093
1094 // Intercept adds a list of query interceptors to the interceptors stack.
1095 // A call to `Intercept(f, g, h)` equals to `signature.Intercept(f(g(h())))`.
1096 func (c *SignatureClient) Intercept(interceptors ...Interceptor) {
1097 c.inters.Signature = append(c.inters.Signature, interceptors...)
1098 }
1099
1100 // Create returns a builder for creating a Signature entity.
1101 func (c *SignatureClient) Create() *SignatureCreate {
1102 mutation := newSignatureMutation(c.config, OpCreate)
1103 return &SignatureCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1104 }
1105
1106 // CreateBulk returns a builder for creating a bulk of Signature entities.
1107 func (c *SignatureClient) CreateBulk(builders ...*SignatureCreate) *SignatureCreateBulk {
1108 return &SignatureCreateBulk{config: c.config, builders: builders}
1109 }
1110
1111 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1112 // a builder and applies setFunc on it.
1113 func (c *SignatureClient) MapCreateBulk(slice any, setFunc func(*SignatureCreate, int)) *SignatureCreateBulk {
1114 rv := reflect.ValueOf(slice)
1115 if rv.Kind() != reflect.Slice {
1116 return &SignatureCreateBulk{err: fmt.Errorf("calling to SignatureClient.MapCreateBulk with wrong type %T, need slice", slice)}
1117 }
1118 builders := make([]*SignatureCreate, rv.Len())
1119 for i := 0; i < rv.Len(); i++ {
1120 builders[i] = c.Create()
1121 setFunc(builders[i], i)
1122 }
1123 return &SignatureCreateBulk{config: c.config, builders: builders}
1124 }
1125
1126 // Update returns an update builder for Signature.
1127 func (c *SignatureClient) Update() *SignatureUpdate {
1128 mutation := newSignatureMutation(c.config, OpUpdate)
1129 return &SignatureUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1130 }
1131
1132 // UpdateOne returns an update builder for the given entity.
1133 func (c *SignatureClient) UpdateOne(_m *Signature) *SignatureUpdateOne {
1134 mutation := newSignatureMutation(c.config, OpUpdateOne, withSignature(_m))
1135 return &SignatureUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1136 }
1137
1138 // UpdateOneID returns an update builder for the given id.
1139 func (c *SignatureClient) UpdateOneID(id uuid.UUID) *SignatureUpdateOne {
1140 mutation := newSignatureMutation(c.config, OpUpdateOne, withSignatureID(id))
1141 return &SignatureUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1142 }
1143
1144 // Delete returns a delete builder for Signature.
1145 func (c *SignatureClient) Delete() *SignatureDelete {
1146 mutation := newSignatureMutation(c.config, OpDelete)
1147 return &SignatureDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
1148 }
1149
1150 // DeleteOne returns a builder for deleting the given entity.
1151 func (c *SignatureClient) DeleteOne(_m *Signature) *SignatureDeleteOne {
1152 return c.DeleteOneID(_m.ID)
1153 }
1154
1155 // DeleteOneID returns a builder for deleting the given entity by its id.
1156 func (c *SignatureClient) DeleteOneID(id uuid.UUID) *SignatureDeleteOne {
1157 builder := c.Delete().Where(signature.ID(id))
1158 builder.mutation.id = &id
1159 builder.mutation.op = OpDeleteOne
1160 return &SignatureDeleteOne{builder}
1161 }
1162
1163 // Query returns a query builder for Signature.
1164 func (c *SignatureClient) Query() *SignatureQuery {
1165 return &SignatureQuery{
1166 config: c.config,
1167 ctx: &QueryContext{Type: TypeSignature},
1168 inters: c.Interceptors(),
1169 }
1170 }
1171
1172 // Get returns a Signature entity by its id.
1173 func (c *SignatureClient) Get(ctx context.Context, id uuid.UUID) (*Signature, error) {
1174 return c.Query().Where(signature.ID(id)).Only(ctx)
1175 }
1176
1177 // GetX is like Get, but panics if an error occurs.
1178 func (c *SignatureClient) GetX(ctx context.Context, id uuid.UUID) *Signature {
1179 obj, err := c.Get(ctx, id)
1180 if err != nil {
1181 panic(err)
1182 }
1183 return obj
1184 }
1185
1186 // QueryDsse queries the dsse edge of a Signature.
1187 func (c *SignatureClient) QueryDsse(_m *Signature) *DsseQuery {
1188 query := (&DsseClient{config: c.config}).Query()
1189 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1190 id := _m.ID
1191 step := sqlgraph.NewStep(
1192 sqlgraph.From(signature.Table, signature.FieldID, id),
1193 sqlgraph.To(dsse.Table, dsse.FieldID),
1194 sqlgraph.Edge(sqlgraph.M2O, true, signature.DsseTable, signature.DsseColumn),
1195 )
1196 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1197 return fromV, nil
1198 }
1199 return query
1200 }
1201
1202 // QueryTimestamps queries the timestamps edge of a Signature.
1203 func (c *SignatureClient) QueryTimestamps(_m *Signature) *TimestampQuery {
1204 query := (&TimestampClient{config: c.config}).Query()
1205 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1206 id := _m.ID
1207 step := sqlgraph.NewStep(
1208 sqlgraph.From(signature.Table, signature.FieldID, id),
1209 sqlgraph.To(timestamp.Table, timestamp.FieldID),
1210 sqlgraph.Edge(sqlgraph.O2M, false, signature.TimestampsTable, signature.TimestampsColumn),
1211 )
1212 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1213 return fromV, nil
1214 }
1215 return query
1216 }
1217
1218 // Hooks returns the client hooks.
1219 func (c *SignatureClient) Hooks() []Hook {
1220 return c.hooks.Signature
1221 }
1222
1223 // Interceptors returns the client interceptors.
1224 func (c *SignatureClient) Interceptors() []Interceptor {
1225 return c.inters.Signature
1226 }
1227
1228 func (c *SignatureClient) mutate(ctx context.Context, m *SignatureMutation) (Value, error) {
1229 switch m.Op() {
1230 case OpCreate:
1231 return (&SignatureCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1232 case OpUpdate:
1233 return (&SignatureUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1234 case OpUpdateOne:
1235 return (&SignatureUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1236 case OpDelete, OpDeleteOne:
1237 return (&SignatureDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
1238 default:
1239 return nil, fmt.Errorf("ent: unknown Signature mutation op: %q", m.Op())
1240 }
1241 }
1242
1243 // StatementClient is a client for the Statement schema.
1244 type StatementClient struct {
1245 config
1246 }
1247
1248 // NewStatementClient returns a client for the Statement from the given config.
1249 func NewStatementClient(c config) *StatementClient {
1250 return &StatementClient{config: c}
1251 }
1252
1253 // Use adds a list of mutation hooks to the hooks stack.
1254 // A call to `Use(f, g, h)` equals to `statement.Hooks(f(g(h())))`.
1255 func (c *StatementClient) Use(hooks ...Hook) {
1256 c.hooks.Statement = append(c.hooks.Statement, hooks...)
1257 }
1258
1259 // Intercept adds a list of query interceptors to the interceptors stack.
1260 // A call to `Intercept(f, g, h)` equals to `statement.Intercept(f(g(h())))`.
1261 func (c *StatementClient) Intercept(interceptors ...Interceptor) {
1262 c.inters.Statement = append(c.inters.Statement, interceptors...)
1263 }
1264
1265 // Create returns a builder for creating a Statement entity.
1266 func (c *StatementClient) Create() *StatementCreate {
1267 mutation := newStatementMutation(c.config, OpCreate)
1268 return &StatementCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1269 }
1270
1271 // CreateBulk returns a builder for creating a bulk of Statement entities.
1272 func (c *StatementClient) CreateBulk(builders ...*StatementCreate) *StatementCreateBulk {
1273 return &StatementCreateBulk{config: c.config, builders: builders}
1274 }
1275
1276 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1277 // a builder and applies setFunc on it.
1278 func (c *StatementClient) MapCreateBulk(slice any, setFunc func(*StatementCreate, int)) *StatementCreateBulk {
1279 rv := reflect.ValueOf(slice)
1280 if rv.Kind() != reflect.Slice {
1281 return &StatementCreateBulk{err: fmt.Errorf("calling to StatementClient.MapCreateBulk with wrong type %T, need slice", slice)}
1282 }
1283 builders := make([]*StatementCreate, rv.Len())
1284 for i := 0; i < rv.Len(); i++ {
1285 builders[i] = c.Create()
1286 setFunc(builders[i], i)
1287 }
1288 return &StatementCreateBulk{config: c.config, builders: builders}
1289 }
1290
1291 // Update returns an update builder for Statement.
1292 func (c *StatementClient) Update() *StatementUpdate {
1293 mutation := newStatementMutation(c.config, OpUpdate)
1294 return &StatementUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1295 }
1296
1297 // UpdateOne returns an update builder for the given entity.
1298 func (c *StatementClient) UpdateOne(_m *Statement) *StatementUpdateOne {
1299 mutation := newStatementMutation(c.config, OpUpdateOne, withStatement(_m))
1300 return &StatementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1301 }
1302
1303 // UpdateOneID returns an update builder for the given id.
1304 func (c *StatementClient) UpdateOneID(id uuid.UUID) *StatementUpdateOne {
1305 mutation := newStatementMutation(c.config, OpUpdateOne, withStatementID(id))
1306 return &StatementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1307 }
1308
1309 // Delete returns a delete builder for Statement.
1310 func (c *StatementClient) Delete() *StatementDelete {
1311 mutation := newStatementMutation(c.config, OpDelete)
1312 return &StatementDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
1313 }
1314
1315 // DeleteOne returns a builder for deleting the given entity.
1316 func (c *StatementClient) DeleteOne(_m *Statement) *StatementDeleteOne {
1317 return c.DeleteOneID(_m.ID)
1318 }
1319
1320 // DeleteOneID returns a builder for deleting the given entity by its id.
1321 func (c *StatementClient) DeleteOneID(id uuid.UUID) *StatementDeleteOne {
1322 builder := c.Delete().Where(statement.ID(id))
1323 builder.mutation.id = &id
1324 builder.mutation.op = OpDeleteOne
1325 return &StatementDeleteOne{builder}
1326 }
1327
1328 // Query returns a query builder for Statement.
1329 func (c *StatementClient) Query() *StatementQuery {
1330 return &StatementQuery{
1331 config: c.config,
1332 ctx: &QueryContext{Type: TypeStatement},
1333 inters: c.Interceptors(),
1334 }
1335 }
1336
1337 // Get returns a Statement entity by its id.
1338 func (c *StatementClient) Get(ctx context.Context, id uuid.UUID) (*Statement, error) {
1339 return c.Query().Where(statement.ID(id)).Only(ctx)
1340 }
1341
1342 // GetX is like Get, but panics if an error occurs.
1343 func (c *StatementClient) GetX(ctx context.Context, id uuid.UUID) *Statement {
1344 obj, err := c.Get(ctx, id)
1345 if err != nil {
1346 panic(err)
1347 }
1348 return obj
1349 }
1350
1351 // QuerySubjects queries the subjects edge of a Statement.
1352 func (c *StatementClient) QuerySubjects(_m *Statement) *SubjectQuery {
1353 query := (&SubjectClient{config: c.config}).Query()
1354 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1355 id := _m.ID
1356 step := sqlgraph.NewStep(
1357 sqlgraph.From(statement.Table, statement.FieldID, id),
1358 sqlgraph.To(subject.Table, subject.FieldID),
1359 sqlgraph.Edge(sqlgraph.O2M, false, statement.SubjectsTable, statement.SubjectsColumn),
1360 )
1361 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1362 return fromV, nil
1363 }
1364 return query
1365 }
1366
1367 // QueryPolicy queries the policy edge of a Statement.
1368 func (c *StatementClient) QueryPolicy(_m *Statement) *AttestationPolicyQuery {
1369 query := (&AttestationPolicyClient{config: c.config}).Query()
1370 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1371 id := _m.ID
1372 step := sqlgraph.NewStep(
1373 sqlgraph.From(statement.Table, statement.FieldID, id),
1374 sqlgraph.To(attestationpolicy.Table, attestationpolicy.FieldID),
1375 sqlgraph.Edge(sqlgraph.O2O, false, statement.PolicyTable, statement.PolicyColumn),
1376 )
1377 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1378 return fromV, nil
1379 }
1380 return query
1381 }
1382
1383 // QueryAttestationCollections queries the attestation_collections edge of a Statement.
1384 func (c *StatementClient) QueryAttestationCollections(_m *Statement) *AttestationCollectionQuery {
1385 query := (&AttestationCollectionClient{config: c.config}).Query()
1386 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1387 id := _m.ID
1388 step := sqlgraph.NewStep(
1389 sqlgraph.From(statement.Table, statement.FieldID, id),
1390 sqlgraph.To(attestationcollection.Table, attestationcollection.FieldID),
1391 sqlgraph.Edge(sqlgraph.O2O, false, statement.AttestationCollectionsTable, statement.AttestationCollectionsColumn),
1392 )
1393 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1394 return fromV, nil
1395 }
1396 return query
1397 }
1398
1399 // QueryDsse queries the dsse edge of a Statement.
1400 func (c *StatementClient) QueryDsse(_m *Statement) *DsseQuery {
1401 query := (&DsseClient{config: c.config}).Query()
1402 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1403 id := _m.ID
1404 step := sqlgraph.NewStep(
1405 sqlgraph.From(statement.Table, statement.FieldID, id),
1406 sqlgraph.To(dsse.Table, dsse.FieldID),
1407 sqlgraph.Edge(sqlgraph.O2M, true, statement.DsseTable, statement.DsseColumn),
1408 )
1409 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1410 return fromV, nil
1411 }
1412 return query
1413 }
1414
1415 // Hooks returns the client hooks.
1416 func (c *StatementClient) Hooks() []Hook {
1417 return c.hooks.Statement
1418 }
1419
1420 // Interceptors returns the client interceptors.
1421 func (c *StatementClient) Interceptors() []Interceptor {
1422 return c.inters.Statement
1423 }
1424
1425 func (c *StatementClient) mutate(ctx context.Context, m *StatementMutation) (Value, error) {
1426 switch m.Op() {
1427 case OpCreate:
1428 return (&StatementCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1429 case OpUpdate:
1430 return (&StatementUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1431 case OpUpdateOne:
1432 return (&StatementUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1433 case OpDelete, OpDeleteOne:
1434 return (&StatementDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
1435 default:
1436 return nil, fmt.Errorf("ent: unknown Statement mutation op: %q", m.Op())
1437 }
1438 }
1439
1440 // SubjectClient is a client for the Subject schema.
1441 type SubjectClient struct {
1442 config
1443 }
1444
1445 // NewSubjectClient returns a client for the Subject from the given config.
1446 func NewSubjectClient(c config) *SubjectClient {
1447 return &SubjectClient{config: c}
1448 }
1449
1450 // Use adds a list of mutation hooks to the hooks stack.
1451 // A call to `Use(f, g, h)` equals to `subject.Hooks(f(g(h())))`.
1452 func (c *SubjectClient) Use(hooks ...Hook) {
1453 c.hooks.Subject = append(c.hooks.Subject, hooks...)
1454 }
1455
1456 // Intercept adds a list of query interceptors to the interceptors stack.
1457 // A call to `Intercept(f, g, h)` equals to `subject.Intercept(f(g(h())))`.
1458 func (c *SubjectClient) Intercept(interceptors ...Interceptor) {
1459 c.inters.Subject = append(c.inters.Subject, interceptors...)
1460 }
1461
1462 // Create returns a builder for creating a Subject entity.
1463 func (c *SubjectClient) Create() *SubjectCreate {
1464 mutation := newSubjectMutation(c.config, OpCreate)
1465 return &SubjectCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1466 }
1467
1468 // CreateBulk returns a builder for creating a bulk of Subject entities.
1469 func (c *SubjectClient) CreateBulk(builders ...*SubjectCreate) *SubjectCreateBulk {
1470 return &SubjectCreateBulk{config: c.config, builders: builders}
1471 }
1472
1473 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1474 // a builder and applies setFunc on it.
1475 func (c *SubjectClient) MapCreateBulk(slice any, setFunc func(*SubjectCreate, int)) *SubjectCreateBulk {
1476 rv := reflect.ValueOf(slice)
1477 if rv.Kind() != reflect.Slice {
1478 return &SubjectCreateBulk{err: fmt.Errorf("calling to SubjectClient.MapCreateBulk with wrong type %T, need slice", slice)}
1479 }
1480 builders := make([]*SubjectCreate, rv.Len())
1481 for i := 0; i < rv.Len(); i++ {
1482 builders[i] = c.Create()
1483 setFunc(builders[i], i)
1484 }
1485 return &SubjectCreateBulk{config: c.config, builders: builders}
1486 }
1487
1488 // Update returns an update builder for Subject.
1489 func (c *SubjectClient) Update() *SubjectUpdate {
1490 mutation := newSubjectMutation(c.config, OpUpdate)
1491 return &SubjectUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1492 }
1493
1494 // UpdateOne returns an update builder for the given entity.
1495 func (c *SubjectClient) UpdateOne(_m *Subject) *SubjectUpdateOne {
1496 mutation := newSubjectMutation(c.config, OpUpdateOne, withSubject(_m))
1497 return &SubjectUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1498 }
1499
1500 // UpdateOneID returns an update builder for the given id.
1501 func (c *SubjectClient) UpdateOneID(id uuid.UUID) *SubjectUpdateOne {
1502 mutation := newSubjectMutation(c.config, OpUpdateOne, withSubjectID(id))
1503 return &SubjectUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1504 }
1505
1506 // Delete returns a delete builder for Subject.
1507 func (c *SubjectClient) Delete() *SubjectDelete {
1508 mutation := newSubjectMutation(c.config, OpDelete)
1509 return &SubjectDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
1510 }
1511
1512 // DeleteOne returns a builder for deleting the given entity.
1513 func (c *SubjectClient) DeleteOne(_m *Subject) *SubjectDeleteOne {
1514 return c.DeleteOneID(_m.ID)
1515 }
1516
1517 // DeleteOneID returns a builder for deleting the given entity by its id.
1518 func (c *SubjectClient) DeleteOneID(id uuid.UUID) *SubjectDeleteOne {
1519 builder := c.Delete().Where(subject.ID(id))
1520 builder.mutation.id = &id
1521 builder.mutation.op = OpDeleteOne
1522 return &SubjectDeleteOne{builder}
1523 }
1524
1525 // Query returns a query builder for Subject.
1526 func (c *SubjectClient) Query() *SubjectQuery {
1527 return &SubjectQuery{
1528 config: c.config,
1529 ctx: &QueryContext{Type: TypeSubject},
1530 inters: c.Interceptors(),
1531 }
1532 }
1533
1534 // Get returns a Subject entity by its id.
1535 func (c *SubjectClient) Get(ctx context.Context, id uuid.UUID) (*Subject, error) {
1536 return c.Query().Where(subject.ID(id)).Only(ctx)
1537 }
1538
1539 // GetX is like Get, but panics if an error occurs.
1540 func (c *SubjectClient) GetX(ctx context.Context, id uuid.UUID) *Subject {
1541 obj, err := c.Get(ctx, id)
1542 if err != nil {
1543 panic(err)
1544 }
1545 return obj
1546 }
1547
1548 // QuerySubjectDigests queries the subject_digests edge of a Subject.
1549 func (c *SubjectClient) QuerySubjectDigests(_m *Subject) *SubjectDigestQuery {
1550 query := (&SubjectDigestClient{config: c.config}).Query()
1551 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1552 id := _m.ID
1553 step := sqlgraph.NewStep(
1554 sqlgraph.From(subject.Table, subject.FieldID, id),
1555 sqlgraph.To(subjectdigest.Table, subjectdigest.FieldID),
1556 sqlgraph.Edge(sqlgraph.O2M, false, subject.SubjectDigestsTable, subject.SubjectDigestsColumn),
1557 )
1558 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1559 return fromV, nil
1560 }
1561 return query
1562 }
1563
1564 // QueryStatement queries the statement edge of a Subject.
1565 func (c *SubjectClient) QueryStatement(_m *Subject) *StatementQuery {
1566 query := (&StatementClient{config: c.config}).Query()
1567 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1568 id := _m.ID
1569 step := sqlgraph.NewStep(
1570 sqlgraph.From(subject.Table, subject.FieldID, id),
1571 sqlgraph.To(statement.Table, statement.FieldID),
1572 sqlgraph.Edge(sqlgraph.M2O, true, subject.StatementTable, subject.StatementColumn),
1573 )
1574 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1575 return fromV, nil
1576 }
1577 return query
1578 }
1579
1580 // Hooks returns the client hooks.
1581 func (c *SubjectClient) Hooks() []Hook {
1582 return c.hooks.Subject
1583 }
1584
1585 // Interceptors returns the client interceptors.
1586 func (c *SubjectClient) Interceptors() []Interceptor {
1587 return c.inters.Subject
1588 }
1589
1590 func (c *SubjectClient) mutate(ctx context.Context, m *SubjectMutation) (Value, error) {
1591 switch m.Op() {
1592 case OpCreate:
1593 return (&SubjectCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1594 case OpUpdate:
1595 return (&SubjectUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1596 case OpUpdateOne:
1597 return (&SubjectUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1598 case OpDelete, OpDeleteOne:
1599 return (&SubjectDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
1600 default:
1601 return nil, fmt.Errorf("ent: unknown Subject mutation op: %q", m.Op())
1602 }
1603 }
1604
1605 // SubjectDigestClient is a client for the SubjectDigest schema.
1606 type SubjectDigestClient struct {
1607 config
1608 }
1609
1610 // NewSubjectDigestClient returns a client for the SubjectDigest from the given config.
1611 func NewSubjectDigestClient(c config) *SubjectDigestClient {
1612 return &SubjectDigestClient{config: c}
1613 }
1614
1615 // Use adds a list of mutation hooks to the hooks stack.
1616 // A call to `Use(f, g, h)` equals to `subjectdigest.Hooks(f(g(h())))`.
1617 func (c *SubjectDigestClient) Use(hooks ...Hook) {
1618 c.hooks.SubjectDigest = append(c.hooks.SubjectDigest, hooks...)
1619 }
1620
1621 // Intercept adds a list of query interceptors to the interceptors stack.
1622 // A call to `Intercept(f, g, h)` equals to `subjectdigest.Intercept(f(g(h())))`.
1623 func (c *SubjectDigestClient) Intercept(interceptors ...Interceptor) {
1624 c.inters.SubjectDigest = append(c.inters.SubjectDigest, interceptors...)
1625 }
1626
1627 // Create returns a builder for creating a SubjectDigest entity.
1628 func (c *SubjectDigestClient) Create() *SubjectDigestCreate {
1629 mutation := newSubjectDigestMutation(c.config, OpCreate)
1630 return &SubjectDigestCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1631 }
1632
1633 // CreateBulk returns a builder for creating a bulk of SubjectDigest entities.
1634 func (c *SubjectDigestClient) CreateBulk(builders ...*SubjectDigestCreate) *SubjectDigestCreateBulk {
1635 return &SubjectDigestCreateBulk{config: c.config, builders: builders}
1636 }
1637
1638 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1639 // a builder and applies setFunc on it.
1640 func (c *SubjectDigestClient) MapCreateBulk(slice any, setFunc func(*SubjectDigestCreate, int)) *SubjectDigestCreateBulk {
1641 rv := reflect.ValueOf(slice)
1642 if rv.Kind() != reflect.Slice {
1643 return &SubjectDigestCreateBulk{err: fmt.Errorf("calling to SubjectDigestClient.MapCreateBulk with wrong type %T, need slice", slice)}
1644 }
1645 builders := make([]*SubjectDigestCreate, rv.Len())
1646 for i := 0; i < rv.Len(); i++ {
1647 builders[i] = c.Create()
1648 setFunc(builders[i], i)
1649 }
1650 return &SubjectDigestCreateBulk{config: c.config, builders: builders}
1651 }
1652
1653 // Update returns an update builder for SubjectDigest.
1654 func (c *SubjectDigestClient) Update() *SubjectDigestUpdate {
1655 mutation := newSubjectDigestMutation(c.config, OpUpdate)
1656 return &SubjectDigestUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1657 }
1658
1659 // UpdateOne returns an update builder for the given entity.
1660 func (c *SubjectDigestClient) UpdateOne(_m *SubjectDigest) *SubjectDigestUpdateOne {
1661 mutation := newSubjectDigestMutation(c.config, OpUpdateOne, withSubjectDigest(_m))
1662 return &SubjectDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1663 }
1664
1665 // UpdateOneID returns an update builder for the given id.
1666 func (c *SubjectDigestClient) UpdateOneID(id uuid.UUID) *SubjectDigestUpdateOne {
1667 mutation := newSubjectDigestMutation(c.config, OpUpdateOne, withSubjectDigestID(id))
1668 return &SubjectDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1669 }
1670
1671 // Delete returns a delete builder for SubjectDigest.
1672 func (c *SubjectDigestClient) Delete() *SubjectDigestDelete {
1673 mutation := newSubjectDigestMutation(c.config, OpDelete)
1674 return &SubjectDigestDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
1675 }
1676
1677 // DeleteOne returns a builder for deleting the given entity.
1678 func (c *SubjectDigestClient) DeleteOne(_m *SubjectDigest) *SubjectDigestDeleteOne {
1679 return c.DeleteOneID(_m.ID)
1680 }
1681
1682 // DeleteOneID returns a builder for deleting the given entity by its id.
1683 func (c *SubjectDigestClient) DeleteOneID(id uuid.UUID) *SubjectDigestDeleteOne {
1684 builder := c.Delete().Where(subjectdigest.ID(id))
1685 builder.mutation.id = &id
1686 builder.mutation.op = OpDeleteOne
1687 return &SubjectDigestDeleteOne{builder}
1688 }
1689
1690 // Query returns a query builder for SubjectDigest.
1691 func (c *SubjectDigestClient) Query() *SubjectDigestQuery {
1692 return &SubjectDigestQuery{
1693 config: c.config,
1694 ctx: &QueryContext{Type: TypeSubjectDigest},
1695 inters: c.Interceptors(),
1696 }
1697 }
1698
1699 // Get returns a SubjectDigest entity by its id.
1700 func (c *SubjectDigestClient) Get(ctx context.Context, id uuid.UUID) (*SubjectDigest, error) {
1701 return c.Query().Where(subjectdigest.ID(id)).Only(ctx)
1702 }
1703
1704 // GetX is like Get, but panics if an error occurs.
1705 func (c *SubjectDigestClient) GetX(ctx context.Context, id uuid.UUID) *SubjectDigest {
1706 obj, err := c.Get(ctx, id)
1707 if err != nil {
1708 panic(err)
1709 }
1710 return obj
1711 }
1712
1713 // QuerySubject queries the subject edge of a SubjectDigest.
1714 func (c *SubjectDigestClient) QuerySubject(_m *SubjectDigest) *SubjectQuery {
1715 query := (&SubjectClient{config: c.config}).Query()
1716 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1717 id := _m.ID
1718 step := sqlgraph.NewStep(
1719 sqlgraph.From(subjectdigest.Table, subjectdigest.FieldID, id),
1720 sqlgraph.To(subject.Table, subject.FieldID),
1721 sqlgraph.Edge(sqlgraph.M2O, true, subjectdigest.SubjectTable, subjectdigest.SubjectColumn),
1722 )
1723 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1724 return fromV, nil
1725 }
1726 return query
1727 }
1728
1729 // Hooks returns the client hooks.
1730 func (c *SubjectDigestClient) Hooks() []Hook {
1731 return c.hooks.SubjectDigest
1732 }
1733
1734 // Interceptors returns the client interceptors.
1735 func (c *SubjectDigestClient) Interceptors() []Interceptor {
1736 return c.inters.SubjectDigest
1737 }
1738
1739 func (c *SubjectDigestClient) mutate(ctx context.Context, m *SubjectDigestMutation) (Value, error) {
1740 switch m.Op() {
1741 case OpCreate:
1742 return (&SubjectDigestCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1743 case OpUpdate:
1744 return (&SubjectDigestUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1745 case OpUpdateOne:
1746 return (&SubjectDigestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1747 case OpDelete, OpDeleteOne:
1748 return (&SubjectDigestDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
1749 default:
1750 return nil, fmt.Errorf("ent: unknown SubjectDigest mutation op: %q", m.Op())
1751 }
1752 }
1753
1754 // TimestampClient is a client for the Timestamp schema.
1755 type TimestampClient struct {
1756 config
1757 }
1758
1759 // NewTimestampClient returns a client for the Timestamp from the given config.
1760 func NewTimestampClient(c config) *TimestampClient {
1761 return &TimestampClient{config: c}
1762 }
1763
1764 // Use adds a list of mutation hooks to the hooks stack.
1765 // A call to `Use(f, g, h)` equals to `timestamp.Hooks(f(g(h())))`.
1766 func (c *TimestampClient) Use(hooks ...Hook) {
1767 c.hooks.Timestamp = append(c.hooks.Timestamp, hooks...)
1768 }
1769
1770 // Intercept adds a list of query interceptors to the interceptors stack.
1771 // A call to `Intercept(f, g, h)` equals to `timestamp.Intercept(f(g(h())))`.
1772 func (c *TimestampClient) Intercept(interceptors ...Interceptor) {
1773 c.inters.Timestamp = append(c.inters.Timestamp, interceptors...)
1774 }
1775
1776 // Create returns a builder for creating a Timestamp entity.
1777 func (c *TimestampClient) Create() *TimestampCreate {
1778 mutation := newTimestampMutation(c.config, OpCreate)
1779 return &TimestampCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1780 }
1781
1782 // CreateBulk returns a builder for creating a bulk of Timestamp entities.
1783 func (c *TimestampClient) CreateBulk(builders ...*TimestampCreate) *TimestampCreateBulk {
1784 return &TimestampCreateBulk{config: c.config, builders: builders}
1785 }
1786
1787 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1788 // a builder and applies setFunc on it.
1789 func (c *TimestampClient) MapCreateBulk(slice any, setFunc func(*TimestampCreate, int)) *TimestampCreateBulk {
1790 rv := reflect.ValueOf(slice)
1791 if rv.Kind() != reflect.Slice {
1792 return &TimestampCreateBulk{err: fmt.Errorf("calling to TimestampClient.MapCreateBulk with wrong type %T, need slice", slice)}
1793 }
1794 builders := make([]*TimestampCreate, rv.Len())
1795 for i := 0; i < rv.Len(); i++ {
1796 builders[i] = c.Create()
1797 setFunc(builders[i], i)
1798 }
1799 return &TimestampCreateBulk{config: c.config, builders: builders}
1800 }
1801
1802 // Update returns an update builder for Timestamp.
1803 func (c *TimestampClient) Update() *TimestampUpdate {
1804 mutation := newTimestampMutation(c.config, OpUpdate)
1805 return &TimestampUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
1806 }
1807
1808 // UpdateOne returns an update builder for the given entity.
1809 func (c *TimestampClient) UpdateOne(_m *Timestamp) *TimestampUpdateOne {
1810 mutation := newTimestampMutation(c.config, OpUpdateOne, withTimestamp(_m))
1811 return &TimestampUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1812 }
1813
1814 // UpdateOneID returns an update builder for the given id.
1815 func (c *TimestampClient) UpdateOneID(id uuid.UUID) *TimestampUpdateOne {
1816 mutation := newTimestampMutation(c.config, OpUpdateOne, withTimestampID(id))
1817 return &TimestampUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
1818 }
1819
1820 // Delete returns a delete builder for Timestamp.
1821 func (c *TimestampClient) Delete() *TimestampDelete {
1822 mutation := newTimestampMutation(c.config, OpDelete)
1823 return &TimestampDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
1824 }
1825
1826 // DeleteOne returns a builder for deleting the given entity.
1827 func (c *TimestampClient) DeleteOne(_m *Timestamp) *TimestampDeleteOne {
1828 return c.DeleteOneID(_m.ID)
1829 }
1830
1831 // DeleteOneID returns a builder for deleting the given entity by its id.
1832 func (c *TimestampClient) DeleteOneID(id uuid.UUID) *TimestampDeleteOne {
1833 builder := c.Delete().Where(timestamp.ID(id))
1834 builder.mutation.id = &id
1835 builder.mutation.op = OpDeleteOne
1836 return &TimestampDeleteOne{builder}
1837 }
1838
1839 // Query returns a query builder for Timestamp.
1840 func (c *TimestampClient) Query() *TimestampQuery {
1841 return &TimestampQuery{
1842 config: c.config,
1843 ctx: &QueryContext{Type: TypeTimestamp},
1844 inters: c.Interceptors(),
1845 }
1846 }
1847
1848 // Get returns a Timestamp entity by its id.
1849 func (c *TimestampClient) Get(ctx context.Context, id uuid.UUID) (*Timestamp, error) {
1850 return c.Query().Where(timestamp.ID(id)).Only(ctx)
1851 }
1852
1853 // GetX is like Get, but panics if an error occurs.
1854 func (c *TimestampClient) GetX(ctx context.Context, id uuid.UUID) *Timestamp {
1855 obj, err := c.Get(ctx, id)
1856 if err != nil {
1857 panic(err)
1858 }
1859 return obj
1860 }
1861
1862 // QuerySignature queries the signature edge of a Timestamp.
1863 func (c *TimestampClient) QuerySignature(_m *Timestamp) *SignatureQuery {
1864 query := (&SignatureClient{config: c.config}).Query()
1865 query.path = func(context.Context) (fromV *sql.Selector, _ error) {
1866 id := _m.ID
1867 step := sqlgraph.NewStep(
1868 sqlgraph.From(timestamp.Table, timestamp.FieldID, id),
1869 sqlgraph.To(signature.Table, signature.FieldID),
1870 sqlgraph.Edge(sqlgraph.M2O, true, timestamp.SignatureTable, timestamp.SignatureColumn),
1871 )
1872 fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
1873 return fromV, nil
1874 }
1875 return query
1876 }
1877
1878 // Hooks returns the client hooks.
1879 func (c *TimestampClient) Hooks() []Hook {
1880 return c.hooks.Timestamp
1881 }
1882
1883 // Interceptors returns the client interceptors.
1884 func (c *TimestampClient) Interceptors() []Interceptor {
1885 return c.inters.Timestamp
1886 }
1887
1888 func (c *TimestampClient) mutate(ctx context.Context, m *TimestampMutation) (Value, error) {
1889 switch m.Op() {
1890 case OpCreate:
1891 return (&TimestampCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1892 case OpUpdate:
1893 return (&TimestampUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1894 case OpUpdateOne:
1895 return (&TimestampUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
1896 case OpDelete, OpDeleteOne:
1897 return (&TimestampDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
1898 default:
1899 return nil, fmt.Errorf("ent: unknown Timestamp mutation op: %q", m.Op())
1900 }
1901 }
1902
1903 // hooks and interceptors per client, for fast access.
1904 type (
1905 hooks struct {
1906 Attestation, AttestationCollection, AttestationPolicy, Dsse, PayloadDigest,
1907 Signature, Statement, Subject, SubjectDigest, Timestamp []ent.Hook
1908 }
1909 inters struct {
1910 Attestation, AttestationCollection, AttestationPolicy, Dsse, PayloadDigest,
1911 Signature, Statement, Subject, SubjectDigest, Timestamp []ent.Interceptor
1912 }
1913 )