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/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/safedep/vet/ent/reportlicense"
"github.com/safedep/vet/ent/reportpackage"
)
// ReportLicenseCreate is the builder for creating a ReportLicense entity.
type ReportLicenseCreate struct {
config
mutation *ReportLicenseMutation
hooks []Hook
}
// SetLicenseID sets the "license_id" field.
func (rlc *ReportLicenseCreate) SetLicenseID(s string) *ReportLicenseCreate {
rlc.mutation.SetLicenseID(s)
return rlc
}
// SetName sets the "name" field.
func (rlc *ReportLicenseCreate) SetName(s string) *ReportLicenseCreate {
rlc.mutation.SetName(s)
return rlc
}
// SetNillableName sets the "name" field if the given value is not nil.
func (rlc *ReportLicenseCreate) SetNillableName(s *string) *ReportLicenseCreate {
if s != nil {
rlc.SetName(*s)
}
return rlc
}
// SetSpdxID sets the "spdx_id" field.
func (rlc *ReportLicenseCreate) SetSpdxID(s string) *ReportLicenseCreate {
rlc.mutation.SetSpdxID(s)
return rlc
}
// SetNillableSpdxID sets the "spdx_id" field if the given value is not nil.
func (rlc *ReportLicenseCreate) SetNillableSpdxID(s *string) *ReportLicenseCreate {
if s != nil {
rlc.SetSpdxID(*s)
}
return rlc
}
// SetURL sets the "url" field.
func (rlc *ReportLicenseCreate) SetURL(s string) *ReportLicenseCreate {
rlc.mutation.SetURL(s)
return rlc
}
// SetNillableURL sets the "url" field if the given value is not nil.
func (rlc *ReportLicenseCreate) SetNillableURL(s *string) *ReportLicenseCreate {
if s != nil {
rlc.SetURL(*s)
}
return rlc
}
// SetCreatedAt sets the "created_at" field.
func (rlc *ReportLicenseCreate) SetCreatedAt(t time.Time) *ReportLicenseCreate {
rlc.mutation.SetCreatedAt(t)
return rlc
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (rlc *ReportLicenseCreate) SetNillableCreatedAt(t *time.Time) *ReportLicenseCreate {
if t != nil {
rlc.SetCreatedAt(*t)
}
return rlc
}
// SetUpdatedAt sets the "updated_at" field.
func (rlc *ReportLicenseCreate) SetUpdatedAt(t time.Time) *ReportLicenseCreate {
rlc.mutation.SetUpdatedAt(t)
return rlc
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (rlc *ReportLicenseCreate) SetNillableUpdatedAt(t *time.Time) *ReportLicenseCreate {
if t != nil {
rlc.SetUpdatedAt(*t)
}
return rlc
}
// SetPackageID sets the "package" edge to the ReportPackage entity by ID.
func (rlc *ReportLicenseCreate) SetPackageID(id int) *ReportLicenseCreate {
rlc.mutation.SetPackageID(id)
return rlc
}
// SetNillablePackageID sets the "package" edge to the ReportPackage entity by ID if the given value is not nil.
func (rlc *ReportLicenseCreate) SetNillablePackageID(id *int) *ReportLicenseCreate {
if id != nil {
rlc = rlc.SetPackageID(*id)
}
return rlc
}
// SetPackage sets the "package" edge to the ReportPackage entity.
func (rlc *ReportLicenseCreate) SetPackage(r *ReportPackage) *ReportLicenseCreate {
return rlc.SetPackageID(r.ID)
}
// Mutation returns the ReportLicenseMutation object of the builder.
func (rlc *ReportLicenseCreate) Mutation() *ReportLicenseMutation {
return rlc.mutation
}
// Save creates the ReportLicense in the database.
func (rlc *ReportLicenseCreate) Save(ctx context.Context) (*ReportLicense, error) {
return withHooks(ctx, rlc.sqlSave, rlc.mutation, rlc.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (rlc *ReportLicenseCreate) SaveX(ctx context.Context) *ReportLicense {
v, err := rlc.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (rlc *ReportLicenseCreate) Exec(ctx context.Context) error {
_, err := rlc.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (rlc *ReportLicenseCreate) ExecX(ctx context.Context) {
if err := rlc.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (rlc *ReportLicenseCreate) check() error {
if _, ok := rlc.mutation.LicenseID(); !ok {
return &ValidationError{Name: "license_id", err: errors.New(`ent: missing required field "ReportLicense.license_id"`)}
}
if v, ok := rlc.mutation.LicenseID(); ok {
if err := reportlicense.LicenseIDValidator(v); err != nil {
return &ValidationError{Name: "license_id", err: fmt.Errorf(`ent: validator failed for field "ReportLicense.license_id": %w`, err)}
}
}
return nil
}
func (rlc *ReportLicenseCreate) sqlSave(ctx context.Context) (*ReportLicense, error) {
if err := rlc.check(); err != nil {
return nil, err
}
_node, _spec := rlc.createSpec()
if err := sqlgraph.CreateNode(ctx, rlc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
rlc.mutation.id = &_node.ID
rlc.mutation.done = true
return _node, nil
}
func (rlc *ReportLicenseCreate) createSpec() (*ReportLicense, *sqlgraph.CreateSpec) {
var (
_node = &ReportLicense{config: rlc.config}
_spec = sqlgraph.NewCreateSpec(reportlicense.Table, sqlgraph.NewFieldSpec(reportlicense.FieldID, field.TypeInt))
)
if value, ok := rlc.mutation.LicenseID(); ok {
_spec.SetField(reportlicense.FieldLicenseID, field.TypeString, value)
_node.LicenseID = value
}
if value, ok := rlc.mutation.Name(); ok {
_spec.SetField(reportlicense.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := rlc.mutation.SpdxID(); ok {
_spec.SetField(reportlicense.FieldSpdxID, field.TypeString, value)
_node.SpdxID = value
}
if value, ok := rlc.mutation.URL(); ok {
_spec.SetField(reportlicense.FieldURL, field.TypeString, value)
_node.URL = value
}
if value, ok := rlc.mutation.CreatedAt(); ok {
_spec.SetField(reportlicense.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := rlc.mutation.UpdatedAt(); ok {
_spec.SetField(reportlicense.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if nodes := rlc.mutation.PackageIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportlicense.PackageTable,
Columns: []string{reportlicense.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)
}
_node.report_package_licenses = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// ReportLicenseCreateBulk is the builder for creating many ReportLicense entities in bulk.
type ReportLicenseCreateBulk struct {
config
err error
builders []*ReportLicenseCreate
}
// Save creates the ReportLicense entities in the database.
func (rlcb *ReportLicenseCreateBulk) Save(ctx context.Context) ([]*ReportLicense, error) {
if rlcb.err != nil {
return nil, rlcb.err
}
specs := make([]*sqlgraph.CreateSpec, len(rlcb.builders))
nodes := make([]*ReportLicense, len(rlcb.builders))
mutators := make([]Mutator, len(rlcb.builders))
for i := range rlcb.builders {
func(i int, root context.Context) {
builder := rlcb.builders[i]
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*ReportLicenseMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, rlcb.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, rlcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, rlcb.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (rlcb *ReportLicenseCreateBulk) SaveX(ctx context.Context) []*ReportLicense {
v, err := rlcb.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (rlcb *ReportLicenseCreateBulk) Exec(ctx context.Context) error {
_, err := rlcb.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (rlcb *ReportLicenseCreateBulk) ExecX(ctx context.Context) {
if err := rlcb.Exec(ctx); err != nil {
panic(err)
}
}