models

package
v0.7.1-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 18 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 = time.RFC3339

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), getNodesByTags 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

func ParseActionTargets added in v0.5.0

func ParseActionTargets(on []string) (nodeNames []string, tags []string)

ParseActionTargets parses the On array and separates node names from tag references. Tag references are prefixed with "tag:" (e.g., "tag:web"). Returns two slices: node names and tags (without the "tag:" prefix).

func ValidNotificationReceiver added in v0.2.0

func ValidNotificationReceiver(fl validator.FieldLevel) bool

ValidNotificationReceiver validates notification receiver format Receivers must be either a valid email address or group reference "group:name"

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 flow"`
	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"
	ExecutionStatusPendingApproval ExecutionStatus = "pending_approval"
	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
	StartedAt       time.Time
	CompletedAt     time.Time
	ScheduledAt     time.Time
	ActionRetries   map[string]int
}

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"`
	Notify    []Notify   `yaml:"notify" huml:"notify" json:"notify" 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"`
	MaxFileSize int64     `yaml:"max_file_size" huml:"max_file_size" json:"max_file_size"`
}

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"`
	UserSchedulable bool   `yaml:"user_schedulable" huml:"user_schedulable"`
}

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 NamespaceSecret

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

func RepoNamespaceSecretByUUIDToNamespaceSecret

func RepoNamespaceSecretByUUIDToNamespaceSecret(repoSecret repo.GetNamespaceSecretByUUIDRow) NamespaceSecret

func RepoNamespaceSecretListToNamespaceSecret

func RepoNamespaceSecretListToNamespaceSecret(repoSecrets []repo.ListNamespaceSecretsRow) []NamespaceSecret

func RepoNamespaceSecretToNamespaceSecret

func RepoNamespaceSecretToNamespaceSecret(repoSecret repo.NamespaceSecret) NamespaceSecret

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 Notify added in v0.2.0

type Notify struct {
	Channel   string        `yaml:"channel" huml:"channel" json:"channel" validate:"required,oneof=email"`
	Receivers []string      `yaml:"receivers" huml:"receivers" json:"receivers" validate:"required,min=1,dive,notification_receiver"`
	Events    []NotifyEvent `yaml:"events" huml:"events" json:"events" validate:"required,dive,min=1,oneof=on_success on_failure on_waiting on_cancelled"`
}

type NotifyEvent added in v0.2.0

type NotifyEvent string
const (
	NotifyEventOnSuccess   NotifyEvent = "on_success"
	NotifyEventOnFailure   NotifyEvent = "on_failure"
	NotifyEventOnWaiting   NotifyEvent = "on_waiting"
	NotifyEventOnCancelled NotifyEvent = "on_cancelled"
)

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"
	ResourceNamespaceSecret Resource = "namespace_secret"
	ResourceNode            Resource = "node"
	ResourceCredential      Resource = "credential"
	ResourceMember          Resource = "member"
	ResourceExecution       Resource = "execution"
	ResourceApproval        Resource = "approval"
	ResourceNamespace       Resource = "namespace"
)

type Schedule

type Schedule struct {
	UUID          string                 `json:"uuid"`
	FlowSlug      string                 `json:"flow_slug"`
	FlowName      string                 `json:"flow_name"`
	Cron          string                 `json:"cron"`
	Timezone      string                 `json:"timezone"`
	Inputs        map[string]interface{} `json:"inputs"`
	CreatedByID   string                 `json:"created_by_id"`
	CreatedByName string                 `json:"created_by_name"`
	IsActive      bool                   `json:"is_active"`
	IsUserCreated bool                   `json:"is_user_created"`
	CreatedAt     time.Time              `json:"created_at"`
	UpdatedAt     time.Time              `json:"updated_at"`
}

type ScheduledExecution added in v0.4.0

type ScheduledExecution struct {
	ExecID      string
	ScheduledAt time.Time
}

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