pcloud

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	BaseURL   string
	AuthToken string
}

API is a pCloud client holding session-level configuration.

func NewAPI

func NewAPI() *API

NewAPI returns a new API client.

func (*API) Checksum

func (p *API) Checksum(path string) (models.ChecksumfileResponse, error)

Checksum fetches MD5 and SHA1 checksums for a remote file path.

func (*API) CopyFile

func (p *API) CopyFile(sourcePath, destinationPath string, overwrite bool) (models.CopyfileResponse, error)

func (*API) CreateFolder

func (p *API) CreateFolder(path string) (models.CreatefolderResponse, error)

func (*API) DeleteFile

func (p *API) DeleteFile(path string) (models.DeletefileResponse, error)

func (*API) DeleteFolder

func (p *API) DeleteFolder(path string) (models.DeletefolderResponse, error)

func (*API) DeleteFolderRecursive

func (p *API) DeleteFolderRecursive(path string) (models.DeletefolderRecursiveResponse, error)

func (*API) EnsureFolder added in v1.2.0

func (p *API) EnsureFolder(path string) error

EnsureFolder creates path on pCloud if it does not already exist. It uses /createfolderifnotexists and is idempotent.

func (p *API) GetFileLink(path string) (models.GetfileResponse, error)

func (*API) GetFileLinkByID

func (p *API) GetFileLinkByID(fileID int) (models.GetfileResponse, error)

GetFileLinkByID returns a download link for the file identified by its numeric file ID.

func (*API) GetUserInfo

func (p *API) GetUserInfo() (UserinfoResponse, error)

GetUserInfo fetches account information for the authenticated user.

func (*API) GetZipLinkByFolderID

func (p *API) GetZipLinkByFolderID(folderID int, filename string, forceDownload bool) (models.GetziplinkResponse, error)

func (*API) IsConfigured

func (p *API) IsConfigured() bool

IsConfigured reports whether the client has both a base URL and an auth token.

func (*API) ListFolder

func (p *API) ListFolder(path string, opts ListFolderOptions) (models.ListfolderResponse, error)

func (*API) LoginWithPassword

func (p *API) LoginWithPassword(username, password string) (UserinfoResponse, []byte, error)

LoginWithPassword authenticates with username+password and returns the parsed response, the raw JSON bytes (useful for debugging), and any error. A bare API client (no Bearer token) is used deliberately: if an OAuth Authorization header is present, pCloud validates the existing session instead of issuing a new auth session token, leaving the `auth` field empty.

func (*API) Query

func (p *API) Query(req *Request) ([]byte, error)

Query executes req against the API and returns the raw JSON response body.

func (*API) RenameFile

func (p *API) RenameFile(sourcePath, destinationPath string) (models.RenamefileResponse, error)

func (*API) RenameFolder

func (p *API) RenameFolder(sourcePath, destinationPath string) (models.RenamefolderResponse, error)

func (*API) UploadFile

func (p *API) UploadFile(localPath, remotePath string, renameIfExists bool) (models.UploadfileResponse, error)

type CloudAPI added in v1.4.0

type CloudAPI interface {
	ListFolder(path string, opts ListFolderOptions) (models.ListfolderResponse, error)
	DeleteFile(path string) (models.DeletefileResponse, error)
	DeleteFolderRecursive(path string) (models.DeletefolderRecursiveResponse, error)
	RenameFile(sourcePath, destinationPath string) (models.RenamefileResponse, error)
	RenameFolder(sourcePath, destinationPath string) (models.RenamefolderResponse, error)
	GetFileLink(path string) (models.GetfileResponse, error)
	GetZipLinkByFolderID(folderID int, filename string, forceDownload bool) (models.GetziplinkResponse, error)
}

CloudAPI is the subset of pCloud API operations required by the TUI layer. *API satisfies this interface; tests can supply a StubAPI instead.

type ListFolderOptions

type ListFolderOptions struct {
	// Recursive returns the full directory tree when true (recursive=1).
	Recursive bool
	// ShowDeleted includes deleted files and folders that can be undeleted.
	ShowDeleted bool
	// NoFiles returns only the folder (sub)structure, omitting files.
	NoFiles bool
	// NoShares returns only the user's own folders and files, hiding shared items.
	NoShares bool
}

ListFolderOptions controls optional parameters for the listfolder API call.

type Request

type Request struct {
	Endpoint   string
	Parameters url.Values
	Body       io.Reader
	Headers    map[string]string
}

Request holds the per-call data passed to Query.

type UserinfoResponse

type UserinfoResponse struct {
	UserID          int    `json:"userid"`
	Email           string `json:"email"`
	Auth            string `json:"auth"`
	Quota           int64  `json:"quota"`
	UsedQuota       int64  `json:"usedquota"`
	Plan            int    `json:"plan"`
	Premium         bool   `json:"premium"`
	PremiumLifetime bool   `json:"premiumlifetime"`
	PremiumExpires  string `json:"premiumexpires"`
	Currency        string `json:"currency"`
}

UserinfoResponse holds the fields returned by /userinfo when called with getauth=1.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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