models

package
v0.0.0-...-5ba556e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectionStatusOnline  = "online"
	ConnectionStatusOffline = "offline"
)

Variables

View Source
var (
	ErrNotFound      = fmt.Errorf("resource not found")
	ErrAlreadyExists = fmt.Errorf("resource already exists")
)
View Source
var DB *gorm.DB

This makes the DB generally available to the application This is safe to access from multiple goroutines

Functions

func CreateGuardRailRules

func CreateGuardRailRules(rule *GuardRailRules) error

func CreateUser

func CreateUser(user User) error

func DeleteConnection

func DeleteConnection(orgID, name string) error

func DeleteGuardRailRules

func DeleteGuardRailRules(orgID, ruleID string) error

func DeleteUser

func DeleteUser(orgID, subject string) error

func DeleteUserGroupsByUserID

func DeleteUserGroupsByUserID(userID string) error

func InitDatabaseConnection

func InitDatabaseConnection() error

func InsertUserGroups

func InsertUserGroups(userGroups []UserGroup) error

func UpdateGuardRailRules

func UpdateGuardRailRules(r *GuardRailRules) error

func UpdateUser

func UpdateUser(user *User) error

func UpdateUserAndUserGroups

func UpdateUserAndUserGroups(user *User, userGroups []UserGroup) error

func UpsertConnection

func UpsertConnection(c *Connection) error

Types

type Connection

type Connection struct {
	OrgID              string            `gorm:"column:org_id"`
	ID                 string            `gorm:"column:id"`
	AgentID            sql.NullString    `gorm:"column:agent_id"`
	Name               string            `gorm:"column:name"`
	Command            pq.StringArray    `gorm:"column:command;type:text[]"`
	Type               string            `gorm:"column:type"`
	SubType            sql.NullString    `gorm:"column:subtype"`
	Status             string            `gorm:"column:status"`
	ManagedBy          sql.NullString    `gorm:"column:managed_by"`
	Tags               pq.StringArray    `gorm:"column:_tags;type:text[]"`
	AccessModeRunbooks string            `gorm:"column:access_mode_runbooks"`
	AccessModeExec     string            `gorm:"column:access_mode_exec"`
	AccessModeConnect  string            `gorm:"column:access_mode_connect"`
	AccessSchema       string            `gorm:"column:access_schema"`
	Envs               map[string]string `gorm:"column:envs;serializer:json;->"`
	GuardRailRules     pq.StringArray    `gorm:"column:guardrail_rules;type:text[];->"`

	// Read Only fields
	RedactEnabled bool           `gorm:"column:redact_enabled;->"`
	Reviewers     pq.StringArray `gorm:"column:reviewers;type:text[];->"`
	RedactTypes   pq.StringArray `gorm:"column:redact_types;type:text[];->"`
	AgentMode     string         `gorm:"column:agent_mode;->"`
	AgentName     string         `gorm:"column:agent_name;->"`
}

func GetConnectionByNameOrID

func GetConnectionByNameOrID(orgID, nameOrID string) (*Connection, error)

func ListConnections

func ListConnections(orgID string, opts ConnectionFilterOption) ([]Connection, error)

func (Connection) AsSecrets

func (c Connection) AsSecrets() map[string]any

type ConnectionFilterOption

type ConnectionFilterOption struct {
	Type      string
	SubType   string
	ManagedBy string
	AgentID   string
	Tags      []string
}

ConnectionOption each attribute set applies an AND operator logic

func (ConnectionFilterOption) GetTagsAsArray

func (o ConnectionFilterOption) GetTagsAsArray() any

type ConnectionGuardRailRules

type ConnectionGuardRailRules struct {
	OrgID string `gorm:"column:org_id"`
	ID    string `gorm:"column:id"`
	Name  string `gorm:"column:name"`

	// Read Only Fields
	GuardRailInputRules  []byte `gorm:"column:guardrail_input_rules;->"`
	GuardRailOutputRules []byte `gorm:"column:guardrail_output_rules;->"`
}

func GetConnectionGuardRailRules

func GetConnectionGuardRailRules(orgID, name string) (*ConnectionGuardRailRules, error)

type EnvVars

type EnvVars struct {
	ID    string            `gorm:"column:id"`
	OrgID string            `gorm:"column:org_id"`
	Envs  map[string]string `gorm:"column:envs;serializer:json"`
}

type ErrNotFoundGuardRailRules

type ErrNotFoundGuardRailRules struct {
	// contains filtered or unexported fields
}

func (*ErrNotFoundGuardRailRules) Error

func (e *ErrNotFoundGuardRailRules) Error() string

type GuardRailRules

type GuardRailRules struct {
	OrgID       string         `gorm:"column:org_id"`
	ID          string         `gorm:"column:id"`
	Name        string         `gorm:"column:name"`
	Description string         `gorm:"column:description"`
	Input       map[string]any `gorm:"column:input;serializer:json"`
	Output      map[string]any `gorm:"column:output;serializer:json"`
	CreatedAt   time.Time      `gorm:"column:created_at"`
	UpdatedAt   time.Time      `gorm:"column:updated_at"`
}

func GetGuardRailRules

func GetGuardRailRules(orgID, ruleID string) (*GuardRailRules, error)

func ListGuardRailRules

func ListGuardRailRules(orgID string) ([]*GuardRailRules, error)

type JiraIntegration

type JiraIntegration struct {
	ID         string                `json:"id"`
	OrgID      string                `json:"org_id"`
	URL        string                `json:"url"`
	User       string                `json:"user"`
	APIToken   string                `json:"api_token"`
	ProjectKey string                `json:"project_key"`
	Status     JiraIntegrationStatus `json:"status"`
	CreatedAt  time.Time             `json:"created_at"`
	UpdatedAt  time.Time             `json:"updated_at"`
}

func CreateJiraIntegration

func CreateJiraIntegration(orgID string, jiraIntegration *JiraIntegration) (*JiraIntegration, error)

func GetJiraIntegration

func GetJiraIntegration(orgID string) (*JiraIntegration, error)

func UpdateJiraIntegration

func UpdateJiraIntegration(orgID string, jiraIntegration *JiraIntegration) (*JiraIntegration, error)

type JiraIntegrationStatus

type JiraIntegrationStatus string
const (
	JiraIntegrationStatusActive   JiraIntegrationStatus = "enabled"
	JiraIntegrationStatusInactive JiraIntegrationStatus = "disabled"
)

type User

type User struct {
	ID             string
	OrgID          string
	Subject        string
	Name           string
	Picture        string
	Email          string
	Verified       bool
	Status         string
	SlackID        string
	HashedPassword string
}

func GetInvitedUserByEmail

func GetInvitedUserByEmail(email string) (*User, error)

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

func GetUserByEmailAndOrg

func GetUserByEmailAndOrg(email, orgID string) (*User, error)

func GetUserByOrgIDAndSlackID

func GetUserByOrgIDAndSlackID(orgID, slackID string) (*User, error)

func GetUserBySubjectAndOrg

func GetUserBySubjectAndOrg(subject, orgID string) (*User, error)

func ListUsers

func ListUsers(orgID string) ([]User, error)

type UserGroup

type UserGroup struct {
	OrgID            string
	UserID           string
	ServiceAccountId sql.NullString
	Name             string
}

func GetUserGroupsByOrgID

func GetUserGroupsByOrgID(orgID string) ([]UserGroup, error)

func GetUserGroupsByUserID

func GetUserGroupsByUserID(userID string) ([]UserGroup, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL