// Code generated by entc, DO NOT EDIT.

package testbedinfo

import (
	"fmt"
	"time"

	"github.com/pingcap/test-infra/common/model"
)

const (
	// Label holds the string label denoting the testbedinfo type in the database.
	Label = "testbed_info"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreatedAt holds the string denoting the createdat field in the database.
	FieldCreatedAt = "created_at"
	// FieldUpdatedAt holds the string denoting the updatedat field in the database.
	FieldUpdatedAt = "updated_at"
	// FieldName holds the string denoting the name field in the database.
	FieldName = "name"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldPlanExecutionID holds the string denoting the planexecutionid field in the database.
	FieldPlanExecutionID = "plan_execution_id"
	// FieldURL holds the string denoting the url field in the database.
	FieldURL = "url"
	// FieldLeaseDDL holds the string denoting the leaseddl field in the database.
	FieldLeaseDDL = "lease_ddl"
	// FieldInitiatedAt holds the string denoting the initiatedat field in the database.
	FieldInitiatedAt = "initiated_at"
	// FieldReleasedAt holds the string denoting the releasedat field in the database.
	FieldReleasedAt = "released_at"
	// FieldReleasedBy holds the string denoting the releasedby field in the database.
	FieldReleasedBy = "released_by"
	// FieldPhysicalResourceRequest holds the string denoting the physicalresourcerequest field in the database.
	FieldPhysicalResourceRequest = "physical_resource_request"
	// FieldResourceItems holds the string denoting the resourceitems field in the database.
	FieldResourceItems = "resource_items"
	// FieldType holds the string denoting the type field in the database.
	FieldType = "type"
	// FieldSetUpLogURL holds the string denoting the setuplogurl field in the database.
	FieldSetUpLogURL = "set_up_log_url"
	// FieldResourcePoolID holds the string denoting the resourcepoolid field in the database.
	FieldResourcePoolID = "resource_pool_id"
	// Table holds the table name of the testbedinfo in the database.
	Table = "testbed_infos"
)

// Columns holds all SQL columns for testbedinfo fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldName,
	FieldStatus,
	FieldPlanExecutionID,
	FieldURL,
	FieldLeaseDDL,
	FieldInitiatedAt,
	FieldReleasedAt,
	FieldReleasedBy,
	FieldPhysicalResourceRequest,
	FieldResourceItems,
	FieldType,
	FieldSetUpLogURL,
	FieldResourcePoolID,
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	return false
}

var (
	// DefaultCreatedAt holds the default value on creation for the "createdAt" field.
	DefaultCreatedAt func() time.Time
	// DefaultUpdatedAt holds the default value on creation for the "updatedAt" field.
	DefaultUpdatedAt func() time.Time
	// UpdateDefaultUpdatedAt holds the default value on update for the "updatedAt" field.
	UpdateDefaultUpdatedAt func() time.Time
	// NameValidator is a validator for the "name" field. It is called by the builders before save.
	NameValidator func(string) error
	// PlanExecutionIDValidator is a validator for the "planExecutionID" field. It is called by the builders before save.
	PlanExecutionIDValidator func(uint64) error
	// DefaultURL holds the default value on creation for the "url" field.
	DefaultURL string
	// DefaultSetUpLogURL holds the default value on creation for the "setUpLogURL" field.
	DefaultSetUpLogURL string
	// ResourcePoolIDValidator is a validator for the "resourcePoolID" field. It is called by the builders before save.
	ResourcePoolIDValidator func(uint64) error
)

const DefaultStatus model.TestBedInfoStatus = "INITIATING"

// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
func StatusValidator(s model.TestBedInfoStatus) error {
	switch s {
	case "INITIATING", "READY", "RELEASED", "ERROR":
		return nil
	default:
		return fmt.Errorf("testbedinfo: invalid enum value for status field: %q", s)
	}
}

const DefaultType model.TestBedInfoType = "NORMAL"

// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type model.TestBedInfoType) error {
	switch _type {
	case "NORMAL", "RESTORE_MONITOR":
		return nil
	default:
		return fmt.Errorf("testbedinfo: invalid enum value for type field: %q", _type)
	}
}
