rest

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const LetterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
View Source
const NoKeyringMsg = "" /* 132-byte string literal not displayed */

NoKeyringMsg warns end user when no keyring is found

Variables

View Source
var (
	// DefaultConfig  stores the current active config.
	DefaultConfig    *CecConfig
	DefaultContext   context.Context
	DefaultTransport openapiruntime.ClientTransport
)
View Source
var (
	DryRun    bool
	QueueSize = 3
)

Functions

func ApplyUpdate

func ApplyUpdate(ctx context.Context, p *UpdatePackage, dryRun bool, pgChan chan float64, doneChan chan bool, errorChan chan error)

func AuthenticatedGet added in v2.1.0

func AuthenticatedGet(uri string) (*http.Response, error)

AuthenticatedGet performs an authenticated GET request for the passed URI (that must start with a '/').

func AuthenticatedRequest added in v2.1.0

func AuthenticatedRequest(req *http.Request, sdkConfig *cells_sdk.SdkConfig) (*http.Response, error)

AuthenticatedRequest performs the passed request after adding an authorization Header.

func BuildParams

func BuildParams(source []string, targetFolder string, targetParent bool) string

func CheckKeyring added in v2.1.0

func CheckKeyring() error

CheckKeyring simply tries a write followed by a read in the local keyring and returns nothing if it works or an error otherwise.

func CleanURL added in v2.1.0

func CleanURL(input string) (string, error)

func ClearKeyring

func ClearKeyring(c *CecConfig) error

ClearKeyring removes sensitive info from the local keychain, if they are present.

func ConfigFromKeyring

func ConfigFromKeyring(conf *CecConfig) error

ConfigFromKeyring tries to find sensitive info inside local keychain and feed the conf.

func ConfigToKeyring

func ConfigToKeyring(conf *CecConfig) error

ConfigToKeyring stores sensitive information in local keyring if any and removes it from current SDK config.

func CopyJob

func CopyJob(jsonParams string) (string, error)

func CopyParams

func CopyParams(source []string, targetFolder string) string
func CreateSimpleFolderLink(targetNodeUuid, label string) (*models.RestShareLink, error)

func DefaultConfigDirPath added in v2.1.0

func DefaultConfigDirPath() string

func DefaultConfigFilePath

func DefaultConfigFilePath() string

func DeleteNode

func DeleteNode(paths []string) (jobUUIDs []string, e error)

func GetApiClient

func GetApiClient(anonymous ...bool) (context.Context, *client.PydioCellsRestAPI, error)

GetApiClient connects to the Pydio Cells server defined by this config, by sending an authentication request to the OIDC service to get a valid JWT (or taking the JWT from cache). It also returns a context to be used in subsequent requests.

func GetBulkMetaNode

func GetBulkMetaNode(path string) ([]*models.TreeNode, error)

func GetConfigFilePath

func GetConfigFilePath() string

func GetFile

func GetFile(pathToFile string) (io.Reader, int, error)

func GetS3Client

func GetS3Client() (*s3.S3, string, error)

func GetTaskStatusForJob

func GetTaskStatusForJob(jobID string) (status models.JobsTaskStatus, msg string, pg float32, e error)

GetTaskStatusForJob retrieves the task status, progress and message.

func IsForbiddenError added in v2.1.0

func IsForbiddenError(err error) bool

func ListNodesPath

func ListNodesPath(path string) ([]string, error)

func MonitorJob

func MonitorJob(JobID string) (err error)

MonitorJob monitors a job status every second.

func MoveJob

func MoveJob(jsonParams string) (string, error)

func MoveParams

func MoveParams(source []string, targetFolder string) string

func OAuthExchangeCode

func OAuthExchangeCode(c *cells_sdk.SdkConfig, code, callbackUrl string) error

OAuthExchangeCode gets an OAuth code and retrieves an AccessToken/RefreshToken pair. It updates the passed Conf

func OAuthPrepareUrl

func OAuthPrepareUrl(serverUrl, state string, browser bool) (redirectUrl string, callbackUrl string, e error)

OAuthPrepareUrl makes a URL that can be opened in browser or copy/pasted by user

func PutFile

func PutFile(pathToFile string, content io.ReadSeeker, checkExists bool, errChan ...chan error) (*s3.PutObjectOutput, error)

func RandString added in v2.2.0

func RandString(n int) string

func RefreshAndStoreIfRequired

func RefreshAndStoreIfRequired(c *CecConfig) bool

func RefreshIfRequired

func RefreshIfRequired(conf *CecConfig) (bool, error)

RefreshIfRequired refreshes the token inside the given conf if required.

func RenameParams

func RenameParams(source []string, targetFolder string) string

func RetrieveCurrentSessionLogin added in v2.1.0

func RetrieveCurrentSessionLogin() (string, error)

RetrieveCurrentSessionLogin requests the registry of the current configured server & login and parse the result to get current user login. Typically useful when using PAT auth.

func RetrieveRemoteServerVersion added in v2.2.0

func RetrieveRemoteServerVersion() (*common.ServerVersion, error)

RetrieveRemoteServerVersion gets the version info from the distant server. User must be authenticated (and admin ?).

func RetryCallback

func RetryCallback(callback func() error, number int, interval time.Duration) error

RetryCallback implements boiler plate code to easily call the same function until it suceeds or a time-out is reached.

func RunJob

func RunJob(jobName string, jsonParams string) (string, error)

RunJob runs a job.

func SetConfigFilePath

func SetConfigFilePath(confPath string)
func StandardizeLink(old string) string

func StatNode

func StatNode(pathToFile string) (*models.TreeNode, bool)

func TreeCreateNodes

func TreeCreateNodes(nodes []*models.TreeNode) error

func Unique added in v2.2.0

func Unique(length int) string

func UpdateConfig added in v2.2.0

func UpdateConfig(newConf *CecConfig) error

func ValidURL added in v2.2.0

func ValidURL(input string) error

Types

type BarsPool

type BarsPool struct {
	*uiprogress.Progress
	// contains filtered or unexported fields
}

func NewBarsPool

func NewBarsPool(showGlobal bool, totalNodes int, refreshInterval time.Duration) *BarsPool

func (*BarsPool) Done

func (b *BarsPool) Done()

func (*BarsPool) Get

func (b *BarsPool) Get(i int, total int, name string) *uiprogress.Bar

type CecConfig added in v2.1.0

type CecConfig struct {
	cells_sdk.SdkConfig
	Label            string `json:"label"`
	SkipKeyring      bool   `json:"skipKeyring"`
	AuthType         string `json:"authType"`
	CreatedAtVersion string `json:"createdAtVersion"`
}

CecConfig extends the default SdkConfig with custom parameters.

type ConfigList added in v2.2.0

type ConfigList struct {
	ActiveConfigID string
	Configs        map[string]*CecConfig
}

func GetConfigList added in v2.2.0

func GetConfigList() (*ConfigList, error)

GetConfigList retrieves the current configurations stored in the config.json file.

func (*ConfigList) GetActiveConfig added in v2.2.0

func (list *ConfigList) GetActiveConfig() (*CecConfig, error)

func (*ConfigList) Remove added in v2.2.0

func (list *ConfigList) Remove(id string) error

Remove removes a config from the list of available configurations by its ID.

func (*ConfigList) SaveConfigFile added in v2.2.0

func (list *ConfigList) SaveConfigFile() error

SaveConfigFile saves inside the config file.

func (*ConfigList) SetActiveConfig added in v2.2.0

func (list *ConfigList) SetActiveConfig(id string) error

type CrawlNode

type CrawlNode struct {
	IsLocal bool

	IsDir       bool
	FullPath    string
	RelPath     string
	MTime       time.Time
	Size        int64
	NewFileName string

	os.FileInfo
	models.TreeNode
}

CrawlNode enables processing the scp command step by step.

func NewCrawler

func NewCrawler(target string, isSrcLocal bool) (*CrawlNode, error)

func NewLocalNode

func NewLocalNode(fullPath string, i os.FileInfo) *CrawlNode

NewLocalNode creates the base node for crawling in case of an upload.

func NewRemoteNode

func NewRemoteNode(t *models.TreeNode) *CrawlNode

NewRemoteNode creates the base node for crawling in case of a download.

func NewTarget

func NewTarget(target string, source *CrawlNode, rename bool) *CrawlNode

func (*CrawlNode) Base

func (c *CrawlNode) Base() string

func (*CrawlNode) CopyAll

func (c *CrawlNode) CopyAll(dd []*CrawlNode, pool *BarsPool) (errs []error)

CopyAll parallely performs the real upload/download of files that have been prepared during the Walk step.

func (*CrawlNode) Dir

func (c *CrawlNode) Dir() string

func (*CrawlNode) Join

func (c *CrawlNode) Join(p ...string) string

func (*CrawlNode) MkdirAll

func (c *CrawlNode) MkdirAll(dd []*CrawlNode, pool *BarsPool) error

MkdirAll prepares a recursive scp by first creating all necessary folders under the target root folder.

func (*CrawlNode) Walk

func (c *CrawlNode) Walk(current ...string) (children []*CrawlNode, e error)

Walk prepares the list of single upload/download nodes that we process in a second time.

type PgReader

type PgReader struct {
	io.Reader
	io.Seeker
	// contains filtered or unexported fields
}

func (*PgReader) CreateErrorChan

func (r *PgReader) CreateErrorChan() (chan error, chan struct{})

func (*PgReader) Read

func (r *PgReader) Read(p []byte) (n int, err error)

func (*PgReader) Seek

func (r *PgReader) Seek(offset int64, whence int) (int64, error)

type UpdatePackage

type UpdatePackage struct {
	// Name of the application
	PackageName string `json:"PackageName,omitempty"`
	// Version of this new binary
	Version string `json:"Version,omitempty"`
	// Release date of the binary
	ReleaseDate int32 `json:"ReleaseDate,omitempty"`
	// Short human-readable description
	Label string `json:"Label,omitempty"`
	// Long human-readable description (markdown)
	Description string `json:"Description,omitempty"`
	// List or public URL of change logs
	ChangeLog string `json:"ChangeLog,omitempty"`
	// License of this package
	License string `json:"License,omitempty"`
	// Https URL where to download the binary
	BinaryURL string `json:"BinaryURL,omitempty"`
	// Checksum of the binary to verify its integrity
	BinaryChecksum string `json:"BinaryChecksum,omitempty"`
	// Signature of the binary
	BinarySignature string `json:"BinarySignature,omitempty"`
	// Hash type used for the signature
	BinaryHashType string `json:"BinaryHashType,omitempty"`
	// Size of the binary to download
	// BinarySize int64 `json:"BinarySize,omitempty"`
	BinarySize string `json:"BinarySize,omitempty"`
	// GOOS value used at build time
	BinaryOS string `json:"BinaryOS,omitempty"`
	// GOARCH value used at build time
	BinaryArch string `json:"BinaryArch,omitempty"`
	// Not used : if binary is a patch
	IsPatch bool `json:"IsPatch,omitempty"`
	// Not used : if a patch, how to patch (bsdiff support)
	PatchAlgorithm string `json:"PatchAlgorithm,omitempty"`
}

func LoadUpdates

func LoadUpdates(ctx context.Context, channel string) ([]*UpdatePackage, error)

type UpdateRequest

type UpdateRequest struct {
	// Channel name
	Channel string `json:"Channel,omitempty"`
	// Name of the currently running application
	PackageName string `json:"PackageName,omitempty"`
	// Current version of the application
	CurrentVersion string `json:"CurrentVersion,omitempty"`
	// Current GOOS
	GOOS string `json:"GOOS,omitempty"`
	// Current GOARCH
	GOARCH string `json:"GOARCH,omitempty"`
	// Not Used : specific service to get updates for
	ServiceName string `json:"ServiceName,omitempty"`
	// For enterprise version, info about the current license
	LicenseInfo map[string]string `json:"LicenseInfo,omitempty"`
}

type UpdateResponse

type UpdateResponse struct {
	Channel string `json:"Channel,omitempty"`
	// List of available binaries
	AvailableBinaries []*UpdatePackage `json:"AvailableBinaries,omitempty"`
}

Jump to

Keyboard shortcuts

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