agents

package
v0.1.0-beta-3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID         uint       `storm:"id,increment" json:"id"`
	UserID     uint       `json:"userID"`
	Host       string     `json:"host"`
	Port       string     `json:"port"`
	Secret     string     `json:"secret,omitempty"`
	RemoteUser RemoteUser `json:"remote_user"`
}

Agent describes an agent.

func (*Agent) Clean

func (a *Agent) Clean(fields ...string) error

Clean cleans up an agent and verifies if all its fields are alright to be saved.

type AgentBackend

type AgentBackend interface {
	ExchangeKeys(host string, port string, secret string) error
}

type AgentClient

type AgentClient struct {
	Agent *Agent
}

func (*AgentClient) CancelTransfer

func (c *AgentClient) CancelTransfer(
	transferID, token string,
) (status int, err error)

func (*AgentClient) ExchangeKeys

func (c *AgentClient) ExchangeKeys(userID uint, host, port, secret, token string) (status int, err error)

func (*AgentClient) GetRemoteUser

func (c *AgentClient) GetRemoteUser(userID uint, user *RemoteUser, token string) (status int, err error)

func (*AgentClient) GetResource

func (c *AgentClient) GetResource(agent *Agent, url, token string) (response *GetResourceResponse, status int, err error)

func (*AgentClient) GetTokenUser

func (c *AgentClient) GetTokenUser(userID uint, user *TokenUser, accessToken, token string) (status int, err error)

func (*AgentClient) GetVersion

func (c *AgentClient) GetVersion(token string) GetVersionResponse

func (*AgentClient) RemoteCopy

func (c *AgentClient) RemoteCopy(
	archiveName,
	srcRoot,
	token string,
	items []ResourceItem,
	compress bool,
) (response *BeforeCopyResponse, status int, err error)

type BeforeCopyResponse

type BeforeCopyResponse struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

type CancelTransferRequest

type CancelTransferRequest struct {
	TransferID string `json:"transfer_id"`
}

type ExchangeKeysResponse

type ExchangeKeysResponse struct {
	Success bool   `json:"success"`
	Error   string `json:"error"`
}

type GenerateAccessTokenResponse

type GenerateAccessTokenResponse struct {
	Code       uint   `json:"code"`
	Token      string `json:"token"`
	ValidUntil int64  `json:"valid_until"`
	Error      string `json:"error"`
}

func GetTemporaryAccessToken

func GetTemporaryAccessToken(token string, userID uint) (response *GenerateAccessTokenResponse, status int, err error)

type GetRemoteUserResponse

type GetRemoteUserResponse struct {
	Code  int32  `json:"code"`
	ID    uint   `json:"id"`
	Token string `json:"token"`
	Root  string `json:"root"`
	Error string `json:"error,omitempty"`
}

type GetResourceResponse

type GetResourceResponse struct {
	Resource string `json:"resource"`
	Error    string `json:"error"`
}

type GetTokenUserResponse

type GetTokenUserResponse struct {
	Code  int32  `json:"code"`
	ID    uint   `json:"id"`
	Name  string `json:"name"`
	Root  string `json:"root"`
	Error string `json:"error,omitempty"`
}

type GetVersionResponse

type GetVersionResponse struct {
	Latency string `json:"latency"`
	Version string `json:"version"`
	Error   string `json:"error"`
}

type RemoteResourceAgentRequest

type RemoteResourceAgentRequest struct {
	Items           []ResourceItem `json:"items"`
	Compress        bool           `json:"compress"`
	SourceRoot      string         `json:"source_root"`
	DestinationRoot string         `json:"destination_root"`
}

type RemoteUser

type RemoteUser struct {
	ID       uint   `storm:"index" json:"id"`
	Name     string `json:"name"`
	Password string `json:"password,omitempty"`
	Root     string `json:"root"`
	Token    string `json:"token"`
}

type ResourceItem

type ResourceItem struct {
	Source      string `json:"source"`
	Destination string `json:"destination"`
	Overwrite   bool   `json:"overwrite"`
	Keep        bool   `json:"keep"`
}

type Storage

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

Storage is an agents storage.

func NewStorage

func NewStorage(back StorageBackend) *Storage

NewStorage creates a users storage from a backend.

func (*Storage) Delete

func (s *Storage) Delete(id interface{}) error

Delete allows you to delete an agent by its name or username. The provided id must be a string for username lookup or a uint for id lookup. If id is neither, a ErrInvalidDataType will be returned.

func (*Storage) FindByUserID

func (s *Storage) FindByUserID(id uint) ([]*Agent, error)

FindByUserID wraps a StorageBackend.FindByUserID.

func (*Storage) Get

func (s *Storage) Get(id interface{}) (agent *Agent, err error)

func (*Storage) Gets

func (s *Storage) Gets() ([]*Agent, error)

Gets gets a list of all users.

func (*Storage) LastUpdate

func (s *Storage) LastUpdate(id uint) int64

LastUpdate gets the timestamp for the last update of an user.

func (*Storage) Save

func (s *Storage) Save(agent *Agent) error

Save saves the agent in a storage.

type StorageBackend

type StorageBackend interface {
	Gets() ([]*Agent, error)
	GetBy(interface{}) (*Agent, error)
	FindByUserID(id uint) ([]*Agent, error)
	Save(a *Agent) error
	Update(a *Agent, fields ...string) error
	DeleteByID(uint) error
}

StorageBackend is the interface to implement for remote agents storage.

type Store

type Store interface {
	Get(id interface{}) (agent *Agent, err error)
	Gets() ([]*Agent, error)
	Save(agent *Agent) error
	Delete(id interface{}) error
	LastUpdate(id uint) int64
}

type TokenUser

type TokenUser struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
	Root string `json:"root"`
}

type ViewMode

type ViewMode string

ViewMode describes a view mode.

Jump to

Keyboard shortcuts

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