models

package
v0.1.1-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OIDCLoginType UserLoginType = "oidc"
	// Password based login
	StandardLoginType UserLoginType = "standard"

	SuperuserUserRole UserRoleType = "superuser"
	StandardUserRole  UserRoleType = "user"
)
View Source
const TimeFormat = "2006-01-02T15:04:05Z"

Variables

This section is empty.

Functions

func AlphanumericSpace

func AlphanumericSpace(fl validator.FieldLevel) bool

func AlphanumericUnderscore

func AlphanumericUnderscore(fl validator.FieldLevel) bool

func ConvertToSchedulerFlow

func ConvertToSchedulerFlow(ctx context.Context, f Flow, namespaceUUID uuid.UUID, getNodesByNames func(context.Context, []string, uuid.UUID) ([]Node, error)) (scheduler.Flow, error)

ConvertToSchedulerFlow converts a Flow to scheduler.Flow

func MarshalFlow

func MarshalFlow(f Flow, format FlowFormat) ([]byte, error)

MarshalFlow marshals a flow to either YAML or HUML format

Types

type Action

type Action struct {
	ID        string         `yaml:"id" huml:"id" validate:"required,alphanum_underscore"`
	Name      string         `yaml:"name" huml:"name" validate:"required"`
	Executor  string         `yaml:"executor" huml:"executor" validate:"required,oneof=script docker"`
	With      map[string]any `yaml:"with" huml:"with" validate:"required"`
	Approval  bool           `yaml:"approval" huml:"approval"`
	Variables []Variable     `yaml:"variables" huml:"variables"`
	On        []string       `yaml:"on" huml:"on"`
}

func SchedulerActionToAction

func SchedulerActionToAction(a scheduler.Action) Action

type ApprovalDetails

type ApprovalDetails struct {
	ApprovalRequest
	DecidedBy string
	Inputs    json.RawMessage
	FlowName  string
	FlowID    string
	CreatedAt string
	UpdatedAt string
}

type ApprovalPaginationDetails

type ApprovalPaginationDetails struct {
	ApprovalRequest
	FlowName  string
	CreatedAt string
	UpdatedAt string
}

type ApprovalRequest

type ApprovalRequest struct {
	UUID        string
	ActionID    string
	Status      ApprovalType
	ExecID      string
	RequestedBy string
}

func (ApprovalRequest) MarshalBinary

func (a ApprovalRequest) MarshalBinary() ([]byte, error)

func (*ApprovalRequest) UnmarshalBinary

func (a *ApprovalRequest) UnmarshalBinary(data []byte) error

type ApprovalType

type ApprovalType string
const (
	ApprovalStatusPending  ApprovalType = "pending"
	ApprovalStatusApproved ApprovalType = "approved"
	ApprovalStatusRejected ApprovalType = "rejected"
)

type AuthMethod

type AuthMethod string
const (
	AuthMethodPrivateKey AuthMethod = "private_key"
	AuthMethodPassword   AuthMethod = "password"
)

type Credential

type Credential struct {
	ID            string
	Name          string
	KeyType       string
	KeyData       string
	NamespaceUUID string
	LastAccessed  string
}

type Execution

type Execution struct {
	Input       map[string]interface{} `json:"input"`
	ExecID      string                 `json:"exec_id"`
	Version     int64                  `json:"version"`
	ErrorMsg    string                 `json:"error_msg"`
	TriggeredBy string                 `json:"triggered_by"`
}

type ExecutionCheckpoint

type ExecutionCheckpoint struct {
	ActionID string
	Err      string
	Results  map[string]string
}

func (ExecutionCheckpoint) MarshalBinary

func (ec ExecutionCheckpoint) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface. It serializes the ExecutionCheckpoint into a binary format.

func (*ExecutionCheckpoint) UnmarshalBinary

func (ec *ExecutionCheckpoint) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. It deserializes the binary data back into an ExecutionCheckpoint.

type ExecutionStatus

type ExecutionStatus string
const (
	ExecutionStatusCancelled ExecutionStatus = "cancelled"
	ExecutionStatusPending   ExecutionStatus = "pending"
	ExecutionStatusCompleted ExecutionStatus = "completed"
	ExecutionStatusErrored   ExecutionStatus = "errored"
)

type ExecutionSummary

type ExecutionSummary struct {
	ExecID          string
	FlowName        string
	FlowID          string
	Status          ExecutionStatus
	Input           json.RawMessage
	TriggerType     string
	TriggeredByName string
	TriggeredByID   string
	CurrentActionID string
	CreatedAt       time.Time
	CompletedAt     time.Time
}

func (ExecutionSummary) Duration

func (e ExecutionSummary) Duration() string

type Flow

type Flow struct {
	Meta      Metadata   `yaml:"metadata" huml:"metadata" validate:"required"`
	Inputs    []Input    `yaml:"inputs" huml:"inputs" validate:"required,dive"`
	Actions   []Action   `yaml:"actions" huml:"actions" validate:"required,dive"`
	Outputs   []Output   `yaml:"outputs" huml:"outputs"`
	Schedules []Schedule `yaml:"schedules" huml:"schedules" validate:"omitempty,dive"`
}

func UnmarshalFlow

func UnmarshalFlow(data []byte, format FlowFormat) (Flow, error)

UnmarshalFlow unmarshals flow data from either YAML or HUML format

func (Flow) GetActionIndexByID

func (f Flow) GetActionIndexByID(id string) (int, error)

func (Flow) IsApprovalRequired

func (f Flow) IsApprovalRequired() bool

func (Flow) IsSchedulable

func (f Flow) IsSchedulable() bool

func (Flow) Validate

func (f Flow) Validate() error

func (Flow) ValidateInput

func (f Flow) ValidateInput(inputs map[string]interface{}) *FlowValidationError

type FlowFormat

type FlowFormat string

FlowFormat represents the file format for flows

const (
	FlowFormatYAML FlowFormat = "yaml"
	FlowFormatHUML FlowFormat = "huml"
)

type FlowSecret

type FlowSecret struct {
	ID            string
	FlowID        int32
	Key           string
	Value         string // Only populated when creating/updating, not when listing
	Description   string
	NamespaceUUID string
	CreatedAt     string
	UpdatedAt     string
}

func RepoFlowSecretByUUIDToFlowSecret

func RepoFlowSecretByUUIDToFlowSecret(repoSecret repo.GetFlowSecretByUUIDRow) FlowSecret

func RepoFlowSecretListToFlowSecret

func RepoFlowSecretListToFlowSecret(repoSecrets []repo.ListFlowSecretsRow) []FlowSecret

func RepoFlowSecretToFlowSecret

func RepoFlowSecretToFlowSecret(repoSecret repo.FlowSecret) FlowSecret

type FlowValidationError

type FlowValidationError struct {
	FieldName string
	Msg       string
	Err       error
}

func (*FlowValidationError) Error

func (f *FlowValidationError) Error() string

type Group

type Group struct {
	ID          string `json:"uuid"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type GroupNamespaceAccess

type GroupNamespaceAccess struct {
	ID            int32     `json:"id"`
	GroupUUID     string    `json:"group_uuid"`
	NamespaceUUID string    `json:"namespace_uuid"`
	CreatedAt     time.Time `json:"created_at"`
}

type GroupWithUsers

type GroupWithUsers struct {
	Group
	Users []User
}

type Input

type Input struct {
	Name        string    `yaml:"name" huml:"name" json:"name" validate:"required,alphanum_underscore"`
	Type        InputType `yaml:"type" huml:"type" json:"type" validate:"required,oneof=string number password file datetime checkbox select"`
	Label       string    `yaml:"label" huml:"label" json:"label"`
	Description string    `yaml:"description" huml:"description" json:"description"`
	Validation  string    `yaml:"validation" huml:"validation" json:"validation"`
	Required    bool      `yaml:"required" huml:"required" json:"required"`
	Default     string    `yaml:"default" huml:"default" json:"default"`
	Options     []string  `yaml:"options" huml:"options" json:"options"`
}

type InputType

type InputType string
const (
	INPUT_TYPE_STRING   InputType = "string"
	INPUT_TYPE_NUMBER   InputType = "number"
	INPUT_TYPE_PASSWORD InputType = "password"
	INPUT_TYPE_FILE     InputType = "file"
	INPUT_TYPE_DATETIME InputType = "datetime"
	INPUT_TYPE_CHECKBOX InputType = "checkbox"
	INPUT_TYPE_SELECT   InputType = "select"
)

type LogMessage

type LogMessage struct {
	Message    string
	Results    map[string]string
	Checkpoint bool
	ID         string
	Err        string
}

type MessageType

type MessageType string
const (
	LogMessageType       MessageType = "log"
	ErrMessageType       MessageType = "error"
	ResultMessageType    MessageType = "result"
	ApprovalMessageType  MessageType = "approval"
	CancelledMessageType MessageType = "cancelled"
)

type Metadata

type Metadata struct {
	ID           string `yaml:"id" huml:"id" validate:"required,alphanum_underscore"`
	DBID         int32  `yaml:"-" huml:"-"`
	Name         string `yaml:"name" huml:"name" validate:"required"`
	Description  string `yaml:"description" huml:"description"`
	SrcDir       string `yaml:"-" huml:"-"`
	Namespace    string `yaml:"namespace" huml:"namespace"`
	AllowOverlap bool   `yaml:"allow_overlap" huml:"allow_overlap"`
}

type Namespace

type Namespace struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type NamespaceMember

type NamespaceMember struct {
	ID          string
	SubjectID   string
	SubjectType string
	NamespaceID string
	Role        NamespaceRole
	CreatedAt   string
	UpdatedAt   string
	Name        string
}

type NamespaceRole

type NamespaceRole string
const (
	NamespaceRoleUser     NamespaceRole = "user"
	NamespaceRoleReviewer NamespaceRole = "reviewer"
	NamespaceRoleAdmin    NamespaceRole = "admin"
)

type NamespaceWithRole

type NamespaceWithRole struct {
	Namespace Namespace     `json:"namespace"`
	Role      NamespaceRole `json:"role"`
}

type Node

type Node struct {
	ID             string
	Name           string
	Hostname       string
	Port           int
	Username       string
	OSFamily       string
	ConnectionType string
	Tags           []string
	Auth           NodeAuth
	NamespaceUUID  string
}

type NodeAuth

type NodeAuth struct {
	CredentialID string
	Method       AuthMethod
	Key          string
}

type NodeStats

type NodeStats struct {
	TotalHosts int64 `json:"total_hosts"`
	SSHHosts   int64 `json:"ssh_hosts"`
	QSSHHosts  int64 `json:"qssh_hosts"`
}

type Output

type Output map[string]any

type RBACAction

type RBACAction string
const (
	RBACActionView    RBACAction = "view"
	RBACActionExecute RBACAction = "execute"
	RBACActionApprove RBACAction = "approve"
	RBACActionUpdate  RBACAction = "update"
	RBACActionDelete  RBACAction = "delete"
	RBACActionCreate  RBACAction = "create"
)

type Resource

type Resource string
const (
	ResourceFlow       Resource = "flow"
	ResourceFlowSecret Resource = "flow_secret"
	ResourceNode       Resource = "node"
	ResourceCredential Resource = "credential"
	ResourceMember     Resource = "member"
	ResourceExecution  Resource = "execution"
	ResourceApproval   Resource = "approval"
	ResourceNamespace  Resource = "namespace"
)

type Schedule

type Schedule struct {
	Cron     string `yaml:"cron" huml:"cron" json:"cron" validate:"required,cron"`
	Timezone string `yaml:"timezone" huml:"timezone" json:"timezone" validate:"required,timezone"`
}

type StreamMessage

type StreamMessage struct {
	ActionID  string      `json:"action_id"`
	MType     MessageType `json:"message_type"`
	NodeID    string      `json:"node_id"`
	Val       string      `json:"value"`
	Timestamp string      `json:"timestamp"`
}

func (StreamMessage) MarshalBinary

func (s StreamMessage) MarshalBinary() ([]byte, error)

func (*StreamMessage) UnmarshalBinary

func (s *StreamMessage) UnmarshalBinary(data []byte) error

type User

type User struct {
	ID        string        `json:"uuid"`
	Username  string        `json:"username"`
	Name      string        `json:"name"`
	LoginType UserLoginType `json:"login_type"`
	Role      UserRoleType  `json:"role"`
	// contains filtered or unexported fields
}

func (User) CheckPassword

func (u User) CheckPassword(password string) error

func (User) WithPassword

func (u User) WithPassword(password string) User

WithPassword sets the user password, the password should be hashed

type UserInfo

type UserInfo struct {
	ID       string   `json:"id"`
	Username string   `json:"email"`
	Name     string   `json:"name"`
	Role     string   `json:"role"`
	Groups   []string `json:"groups"`
}

func (UserInfo) HasGroup

func (u UserInfo) HasGroup(groupUUID string) bool

type UserLoginType

type UserLoginType string

type UserRoleType

type UserRoleType string

type UserSearchResult

type UserSearchResult struct {
	Users      []UserWithGroups `json:"users"`
	PageCount  int64            `json:"page_count"`
	TotalCount int64            `json:"total_count"`
}

type UserWithGroups

type UserWithGroups struct {
	User
	Groups []Group
}

func (UserWithGroups) GetUser

func (u UserWithGroups) GetUser() User

func (UserWithGroups) HasGroup

func (u UserWithGroups) HasGroup(groupUUID string) bool

func (UserWithGroups) ToUserInfo

func (u UserWithGroups) ToUserInfo() UserInfo

type Variable

type Variable map[string]any

func (Variable) Name

func (v Variable) Name() string

func (Variable) Valid

func (v Variable) Valid() bool

func (Variable) Value

func (v Variable) Value() string

Jump to

Keyboard shortcuts

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