// Code generated by relspecgo. DO NOT EDIT.
package models

import (
	"fmt"
	resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
	"github.com/uptrace/bun"
)

type ModelPublicHook struct {
	bun.BaseModel `bun:"table:public.hook,alias:hook"`
	ID            resolvespec_common.SqlString    `bun:"id,type:varchar(36),pk," json:"id"` // UUID
	Active        bool                            `bun:"active,type:boolean,default:true,notnull," json:"active"`
	AllowInsecure bool                            `bun:"allow_insecure,type:boolean,default:false,notnull," json:"allow_insecure"` // Skip TLS certificate verification
	CreatedAt     resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
	DeletedAt     resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"`
	Description   resolvespec_common.SqlString    `bun:"description,type:text,nullzero," json:"description"`
	Events        resolvespec_common.SqlString    `bun:"events,type:text,nullzero," json:"events"`                      // JSON array of event types
	Headers       resolvespec_common.SqlString    `bun:"headers,type:text,nullzero," json:"headers"`                    // JSON encoded headers
	Method        resolvespec_common.SqlString    `bun:"method,type:varchar(10),default:'POST',notnull," json:"method"` // HTTP method
	Name          resolvespec_common.SqlString    `bun:"name,type:varchar(255),notnull," json:"name"`
	RetryCount    resolvespec_common.SqlInt32     `bun:"retry_count,type:int,default:3,notnull," json:"retry_count"`
	Secret        resolvespec_common.SqlString    `bun:"secret,type:varchar(255),nullzero," json:"secret"`    // HMAC signature secret
	Timeout       resolvespec_common.SqlInt32     `bun:"timeout,type:int,default:30,notnull," json:"timeout"` // Timeout in seconds
	UpdatedAt     resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
	URL           resolvespec_common.SqlString    `bun:"url,type:text,notnull," json:"url"`
	UserID        resolvespec_common.SqlString    `bun:"user_id,type:varchar(36),notnull," json:"user_id"`
	RelUserID     *ModelPublicUsers               `bun:"rel:has-one,join:user_id=id" json:"reluserid,omitempty"` // Has one ModelPublicUsers
}

// TableName returns the table name for ModelPublicHook
func (m ModelPublicHook) TableName() string {
	return "public.hook"
}

// TableNameOnly returns the table name without schema for ModelPublicHook
func (m ModelPublicHook) TableNameOnly() string {
	return "hook"
}

// SchemaName returns the schema name for ModelPublicHook
func (m ModelPublicHook) SchemaName() string {
	return "public"
}

// GetID returns the primary key value
func (m ModelPublicHook) GetID() int64 {
	return m.ID.Int64()
}

// GetIDStr returns the primary key as a string
func (m ModelPublicHook) GetIDStr() string {
	return fmt.Sprintf("%d", m.ID)
}

// SetID sets the primary key value
func (m ModelPublicHook) SetID(newid int64) {
	m.UpdateID(newid)
}

// UpdateID updates the primary key value
func (m *ModelPublicHook) UpdateID(newid int64) {
	m.ID.FromString(fmt.Sprintf("%d", newid))
}

// GetIDName returns the name of the primary key column
func (m ModelPublicHook) GetIDName() string {
	return "id"
}

// GetPrefix returns the table prefix
func (m ModelPublicHook) GetPrefix() string {
	return "HOO"
}
