We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/safedep/vet'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/safedep/vet/ent/predicate"
"github.com/safedep/vet/ent/reportpackage"
"github.com/safedep/vet/ent/reportslsaprovenance"
)
// ReportSlsaProvenanceUpdate is the builder for updating ReportSlsaProvenance entities.
type ReportSlsaProvenanceUpdate struct {
config
hooks []Hook
mutation *ReportSlsaProvenanceMutation
}
// Where appends a list predicates to the ReportSlsaProvenanceUpdate builder.
func (rspu *ReportSlsaProvenanceUpdate) Where(ps ...predicate.ReportSlsaProvenance) *ReportSlsaProvenanceUpdate {
rspu.mutation.Where(ps...)
return rspu
}
// SetSourceRepository sets the "source_repository" field.
func (rspu *ReportSlsaProvenanceUpdate) SetSourceRepository(s string) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetSourceRepository(s)
return rspu
}
// SetNillableSourceRepository sets the "source_repository" field if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillableSourceRepository(s *string) *ReportSlsaProvenanceUpdate {
if s != nil {
rspu.SetSourceRepository(*s)
}
return rspu
}
// SetCommitSha sets the "commit_sha" field.
func (rspu *ReportSlsaProvenanceUpdate) SetCommitSha(s string) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetCommitSha(s)
return rspu
}
// SetNillableCommitSha sets the "commit_sha" field if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillableCommitSha(s *string) *ReportSlsaProvenanceUpdate {
if s != nil {
rspu.SetCommitSha(*s)
}
return rspu
}
// SetURL sets the "url" field.
func (rspu *ReportSlsaProvenanceUpdate) SetURL(s string) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetURL(s)
return rspu
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillableURL(s *string) *ReportSlsaProvenanceUpdate {
if s != nil {
rspu.SetURL(*s)
}
return rspu
}
// SetVerified sets the "verified" field.
func (rspu *ReportSlsaProvenanceUpdate) SetVerified(b bool) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetVerified(b)
return rspu
}
// SetNillableVerified sets the "verified" field if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillableVerified(b *bool) *ReportSlsaProvenanceUpdate {
if b != nil {
rspu.SetVerified(*b)
}
return rspu
}
// SetCreatedAt sets the "created_at" field.
func (rspu *ReportSlsaProvenanceUpdate) SetCreatedAt(t time.Time) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetCreatedAt(t)
return rspu
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillableCreatedAt(t *time.Time) *ReportSlsaProvenanceUpdate {
if t != nil {
rspu.SetCreatedAt(*t)
}
return rspu
}
// ClearCreatedAt clears the value of the "created_at" field.
func (rspu *ReportSlsaProvenanceUpdate) ClearCreatedAt() *ReportSlsaProvenanceUpdate {
rspu.mutation.ClearCreatedAt()
return rspu
}
// SetUpdatedAt sets the "updated_at" field.
func (rspu *ReportSlsaProvenanceUpdate) SetUpdatedAt(t time.Time) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetUpdatedAt(t)
return rspu
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillableUpdatedAt(t *time.Time) *ReportSlsaProvenanceUpdate {
if t != nil {
rspu.SetUpdatedAt(*t)
}
return rspu
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (rspu *ReportSlsaProvenanceUpdate) ClearUpdatedAt() *ReportSlsaProvenanceUpdate {
rspu.mutation.ClearUpdatedAt()
return rspu
}
// SetPackageID sets the "package" edge to the ReportPackage entity by ID.
func (rspu *ReportSlsaProvenanceUpdate) SetPackageID(id int) *ReportSlsaProvenanceUpdate {
rspu.mutation.SetPackageID(id)
return rspu
}
// SetNillablePackageID sets the "package" edge to the ReportPackage entity by ID if the given value is not nil.
func (rspu *ReportSlsaProvenanceUpdate) SetNillablePackageID(id *int) *ReportSlsaProvenanceUpdate {
if id != nil {
rspu = rspu.SetPackageID(*id)
}
return rspu
}
// SetPackage sets the "package" edge to the ReportPackage entity.
func (rspu *ReportSlsaProvenanceUpdate) SetPackage(r *ReportPackage) *ReportSlsaProvenanceUpdate {
return rspu.SetPackageID(r.ID)
}
// Mutation returns the ReportSlsaProvenanceMutation object of the builder.
func (rspu *ReportSlsaProvenanceUpdate) Mutation() *ReportSlsaProvenanceMutation {
return rspu.mutation
}
// ClearPackage clears the "package" edge to the ReportPackage entity.
func (rspu *ReportSlsaProvenanceUpdate) ClearPackage() *ReportSlsaProvenanceUpdate {
rspu.mutation.ClearPackage()
return rspu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (rspu *ReportSlsaProvenanceUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, rspu.sqlSave, rspu.mutation, rspu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (rspu *ReportSlsaProvenanceUpdate) SaveX(ctx context.Context) int {
affected, err := rspu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (rspu *ReportSlsaProvenanceUpdate) Exec(ctx context.Context) error {
_, err := rspu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (rspu *ReportSlsaProvenanceUpdate) ExecX(ctx context.Context) {
if err := rspu.Exec(ctx); err != nil {
panic(err)
}
}
func (rspu *ReportSlsaProvenanceUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := sqlgraph.NewUpdateSpec(reportslsaprovenance.Table, reportslsaprovenance.Columns, sqlgraph.NewFieldSpec(reportslsaprovenance.FieldID, field.TypeInt))
if ps := rspu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := rspu.mutation.SourceRepository(); ok {
_spec.SetField(reportslsaprovenance.FieldSourceRepository, field.TypeString, value)
}
if value, ok := rspu.mutation.CommitSha(); ok {
_spec.SetField(reportslsaprovenance.FieldCommitSha, field.TypeString, value)
}
if value, ok := rspu.mutation.URL(); ok {
_spec.SetField(reportslsaprovenance.FieldURL, field.TypeString, value)
}
if value, ok := rspu.mutation.Verified(); ok {
_spec.SetField(reportslsaprovenance.FieldVerified, field.TypeBool, value)
}
if value, ok := rspu.mutation.CreatedAt(); ok {
_spec.SetField(reportslsaprovenance.FieldCreatedAt, field.TypeTime, value)
}
if rspu.mutation.CreatedAtCleared() {
_spec.ClearField(reportslsaprovenance.FieldCreatedAt, field.TypeTime)
}
if value, ok := rspu.mutation.UpdatedAt(); ok {
_spec.SetField(reportslsaprovenance.FieldUpdatedAt, field.TypeTime, value)
}
if rspu.mutation.UpdatedAtCleared() {
_spec.ClearField(reportslsaprovenance.FieldUpdatedAt, field.TypeTime)
}
if rspu.mutation.PackageCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportslsaprovenance.PackageTable,
Columns: []string{reportslsaprovenance.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := rspu.mutation.PackageIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportslsaprovenance.PackageTable,
Columns: []string{reportslsaprovenance.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, rspu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{reportslsaprovenance.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
rspu.mutation.done = true
return n, nil
}
// ReportSlsaProvenanceUpdateOne is the builder for updating a single ReportSlsaProvenance entity.
type ReportSlsaProvenanceUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ReportSlsaProvenanceMutation
}
// SetSourceRepository sets the "source_repository" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetSourceRepository(s string) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetSourceRepository(s)
return rspuo
}
// SetNillableSourceRepository sets the "source_repository" field if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillableSourceRepository(s *string) *ReportSlsaProvenanceUpdateOne {
if s != nil {
rspuo.SetSourceRepository(*s)
}
return rspuo
}
// SetCommitSha sets the "commit_sha" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetCommitSha(s string) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetCommitSha(s)
return rspuo
}
// SetNillableCommitSha sets the "commit_sha" field if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillableCommitSha(s *string) *ReportSlsaProvenanceUpdateOne {
if s != nil {
rspuo.SetCommitSha(*s)
}
return rspuo
}
// SetURL sets the "url" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetURL(s string) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetURL(s)
return rspuo
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillableURL(s *string) *ReportSlsaProvenanceUpdateOne {
if s != nil {
rspuo.SetURL(*s)
}
return rspuo
}
// SetVerified sets the "verified" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetVerified(b bool) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetVerified(b)
return rspuo
}
// SetNillableVerified sets the "verified" field if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillableVerified(b *bool) *ReportSlsaProvenanceUpdateOne {
if b != nil {
rspuo.SetVerified(*b)
}
return rspuo
}
// SetCreatedAt sets the "created_at" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetCreatedAt(t time.Time) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetCreatedAt(t)
return rspuo
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillableCreatedAt(t *time.Time) *ReportSlsaProvenanceUpdateOne {
if t != nil {
rspuo.SetCreatedAt(*t)
}
return rspuo
}
// ClearCreatedAt clears the value of the "created_at" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) ClearCreatedAt() *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.ClearCreatedAt()
return rspuo
}
// SetUpdatedAt sets the "updated_at" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetUpdatedAt(t time.Time) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetUpdatedAt(t)
return rspuo
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillableUpdatedAt(t *time.Time) *ReportSlsaProvenanceUpdateOne {
if t != nil {
rspuo.SetUpdatedAt(*t)
}
return rspuo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (rspuo *ReportSlsaProvenanceUpdateOne) ClearUpdatedAt() *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.ClearUpdatedAt()
return rspuo
}
// SetPackageID sets the "package" edge to the ReportPackage entity by ID.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetPackageID(id int) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.SetPackageID(id)
return rspuo
}
// SetNillablePackageID sets the "package" edge to the ReportPackage entity by ID if the given value is not nil.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetNillablePackageID(id *int) *ReportSlsaProvenanceUpdateOne {
if id != nil {
rspuo = rspuo.SetPackageID(*id)
}
return rspuo
}
// SetPackage sets the "package" edge to the ReportPackage entity.
func (rspuo *ReportSlsaProvenanceUpdateOne) SetPackage(r *ReportPackage) *ReportSlsaProvenanceUpdateOne {
return rspuo.SetPackageID(r.ID)
}
// Mutation returns the ReportSlsaProvenanceMutation object of the builder.
func (rspuo *ReportSlsaProvenanceUpdateOne) Mutation() *ReportSlsaProvenanceMutation {
return rspuo.mutation
}
// ClearPackage clears the "package" edge to the ReportPackage entity.
func (rspuo *ReportSlsaProvenanceUpdateOne) ClearPackage() *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.ClearPackage()
return rspuo
}
// Where appends a list predicates to the ReportSlsaProvenanceUpdate builder.
func (rspuo *ReportSlsaProvenanceUpdateOne) Where(ps ...predicate.ReportSlsaProvenance) *ReportSlsaProvenanceUpdateOne {
rspuo.mutation.Where(ps...)
return rspuo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (rspuo *ReportSlsaProvenanceUpdateOne) Select(field string, fields ...string) *ReportSlsaProvenanceUpdateOne {
rspuo.fields = append([]string{field}, fields...)
return rspuo
}
// Save executes the query and returns the updated ReportSlsaProvenance entity.
func (rspuo *ReportSlsaProvenanceUpdateOne) Save(ctx context.Context) (*ReportSlsaProvenance, error) {
return withHooks(ctx, rspuo.sqlSave, rspuo.mutation, rspuo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (rspuo *ReportSlsaProvenanceUpdateOne) SaveX(ctx context.Context) *ReportSlsaProvenance {
node, err := rspuo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (rspuo *ReportSlsaProvenanceUpdateOne) Exec(ctx context.Context) error {
_, err := rspuo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (rspuo *ReportSlsaProvenanceUpdateOne) ExecX(ctx context.Context) {
if err := rspuo.Exec(ctx); err != nil {
panic(err)
}
}
func (rspuo *ReportSlsaProvenanceUpdateOne) sqlSave(ctx context.Context) (_node *ReportSlsaProvenance, err error) {
_spec := sqlgraph.NewUpdateSpec(reportslsaprovenance.Table, reportslsaprovenance.Columns, sqlgraph.NewFieldSpec(reportslsaprovenance.FieldID, field.TypeInt))
id, ok := rspuo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ReportSlsaProvenance.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := rspuo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, reportslsaprovenance.FieldID)
for _, f := range fields {
if !reportslsaprovenance.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != reportslsaprovenance.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := rspuo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := rspuo.mutation.SourceRepository(); ok {
_spec.SetField(reportslsaprovenance.FieldSourceRepository, field.TypeString, value)
}
if value, ok := rspuo.mutation.CommitSha(); ok {
_spec.SetField(reportslsaprovenance.FieldCommitSha, field.TypeString, value)
}
if value, ok := rspuo.mutation.URL(); ok {
_spec.SetField(reportslsaprovenance.FieldURL, field.TypeString, value)
}
if value, ok := rspuo.mutation.Verified(); ok {
_spec.SetField(reportslsaprovenance.FieldVerified, field.TypeBool, value)
}
if value, ok := rspuo.mutation.CreatedAt(); ok {
_spec.SetField(reportslsaprovenance.FieldCreatedAt, field.TypeTime, value)
}
if rspuo.mutation.CreatedAtCleared() {
_spec.ClearField(reportslsaprovenance.FieldCreatedAt, field.TypeTime)
}
if value, ok := rspuo.mutation.UpdatedAt(); ok {
_spec.SetField(reportslsaprovenance.FieldUpdatedAt, field.TypeTime, value)
}
if rspuo.mutation.UpdatedAtCleared() {
_spec.ClearField(reportslsaprovenance.FieldUpdatedAt, field.TypeTime)
}
if rspuo.mutation.PackageCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportslsaprovenance.PackageTable,
Columns: []string{reportslsaprovenance.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := rspuo.mutation.PackageIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportslsaprovenance.PackageTable,
Columns: []string{reportslsaprovenance.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &ReportSlsaProvenance{config: rspuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, rspuo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{reportslsaprovenance.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
rspuo.mutation.done = true
return _node, nil
}