agent

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package agent contains all functionalities related to Phobos agents, which are responsible for claiming and running jobs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequireViewerAccessToAgentResource added in v0.1.1

func RequireViewerAccessToAgentResource(ctx context.Context, agent *models.Agent) error

RequireViewerAccessToAgentResource checks if the caller has viewer access to an agent's resource like jobs, sessions, error logs, etc.

Types

type AssignServiceAccountToAgentInput

type AssignServiceAccountToAgentInput struct {
	ID               string
	ServiceAccountID string
}

AssignServiceAccountToAgentInput is the input for assigning a service account to an agent

type CreateAgentInput

type CreateAgentInput struct {
	OrganizationID  *string
	Type            models.AgentType
	Name            string
	Description     string
	Tags            []string
	Disabled        bool
	RunUntaggedJobs bool
}

CreateAgentInput is the input for creating a new agent

type CreateAgentSessionInput

type CreateAgentSessionInput struct {
	AgentID  string
	Internal bool
}

CreateAgentSessionInput is the input for creating a new agent session

type DeleteAgentInput

type DeleteAgentInput struct {
	MetadataVersion *int
	ID              string
}

DeleteAgentInput is the input for deleting an existing agent

type GetAgentSessionsInput

type GetAgentSessionsInput struct {
	// Sort specifies the field to sort on and direction
	Sort *db.AgentSessionSortableField
	// PaginationOptions supports cursor based pagination
	PaginationOptions *pagination.Options
	// AgentID is the agent to return sessions for
	AgentID string
}

GetAgentSessionsInput is the input for querying a list of agent sessions

type GetAgentsInput

type GetAgentsInput struct {
	// Sort specifies the field to sort on and direction
	Sort *db.AgentSortableField
	// PaginationOptions supports cursor based pagination
	PaginationOptions *pagination.Options
	// OrganizationID is the organization to return agents for
	OrganizationID *string
	// AgentType is the type of agent to return
	AgentType *models.AgentType
}

GetAgentsInput is the input for querying a list of agents

type Service

type Service interface {
	GetAgentByID(ctx context.Context, id string) (*models.Agent, error)
	GetAgentByPRN(ctx context.Context, prn string) (*models.Agent, error)
	GetAgentsByIDs(ctx context.Context, idList []string) ([]models.Agent, error)
	GetAgents(ctx context.Context, input *GetAgentsInput) (*db.AgentsResult, error)
	CreateAgent(ctx context.Context, input *CreateAgentInput) (*models.Agent, error)
	UpdateAgent(ctx context.Context, input *UpdateAgentInput) (*models.Agent, error)
	DeleteAgent(ctx context.Context, input *DeleteAgentInput) error
	AssignServiceAccountToAgent(ctx context.Context, input *AssignServiceAccountToAgentInput) error
	UnassignServiceAccountFromAgent(ctx context.Context, input *UnassignServiceAccountFromAgentInput) error
	CreateAgentSession(ctx context.Context, input *CreateAgentSessionInput) (*models.AgentSession, error)
	GetAgentSessions(ctx context.Context, input *GetAgentSessionsInput) (*db.AgentSessionsResult, error)
	GetAgentSessionByID(ctx context.Context, id string) (*models.AgentSession, error)
	GetAgentSessionByPRN(ctx context.Context, prn string) (*models.AgentSession, error)
	AcceptAgentSessionHeartbeat(ctx context.Context, sessionID string) error
	CreateAgentSessionError(ctx context.Context, agentSessionID string, message string) error
	ReadAgentSessionErrorLog(ctx context.Context, agentSessionID string, startOffset int, limit int) ([]byte, error)
	SubscribeToAgentSessionErrorLog(ctx context.Context, options *SubscribeToAgentSessionErrorLogInput) (<-chan *logstream.LogEvent, error)
	GetLogStreamsByAgentSessionIDs(ctx context.Context, idList []string) ([]models.LogStream, error)
	SubscribeToAgentSessions(ctx context.Context, options *SubscribeToAgentSessionsInput) (<-chan *SessionEvent, error)
}

Service implements all agent related functionality

func NewService

func NewService(
	logger logger.Logger,
	dbClient *db.Client,
	limitChecker limits.LimitChecker,
	logStreamManager logstream.Manager,
	eventManager *events.EventManager,
	activityService activityevent.Service,
) Service

NewService creates an instance of Service

type SessionEvent

type SessionEvent struct {
	AgentSession *models.AgentSession
	Action       string
}

SessionEvent is an agent session event

type SubscribeToAgentSessionErrorLogInput

type SubscribeToAgentSessionErrorLogInput struct {
	LastSeenLogSize *int
	AgentSessionID  string
}

SubscribeToAgentSessionErrorLogInput includes options for setting up a log event subscription

type SubscribeToAgentSessionsInput

type SubscribeToAgentSessionsInput struct {
	OrganizationID *string
	AgentID        *string
	AgentType      *models.AgentType
}

SubscribeToAgentSessionsInput is the input for subscribing to agent sessions

type UnassignServiceAccountFromAgentInput

type UnassignServiceAccountFromAgentInput struct {
	ID               string
	ServiceAccountID string
}

UnassignServiceAccountFromAgentInput is the input for un-assigning a service account from an agent

type UpdateAgentInput

type UpdateAgentInput struct {
	Disabled        *bool
	Description     *string
	MetadataVersion *int
	RunUntaggedJobs *bool
	ID              string
	Tags            []string
}

UpdateAgentInput is the input for updating an existing agent

Jump to

Keyboard shortcuts

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