Documentation
¶
Index ¶
- type API
- func (p *API) Checksum(path string) (models.ChecksumfileResponse, error)
- func (p *API) CopyFile(sourcePath, destinationPath string, overwrite bool) (models.CopyfileResponse, error)
- func (p *API) CreateFolder(path string) (models.CreatefolderResponse, error)
- func (p *API) DeleteFile(path string) (models.DeletefileResponse, error)
- func (p *API) DeleteFolder(path string) (models.DeletefolderResponse, error)
- func (p *API) DeleteFolderRecursive(path string) (models.DeletefolderRecursiveResponse, error)
- func (p *API) EnsureFolder(path string) error
- func (p *API) GetFileLink(path string) (models.GetfileResponse, error)
- func (p *API) GetFileLinkByID(fileID int) (models.GetfileResponse, error)
- func (p *API) GetUserInfo() (UserinfoResponse, error)
- func (p *API) GetZipLinkByFolderID(folderID int, filename string, forceDownload bool) (models.GetziplinkResponse, error)
- func (p *API) IsConfigured() bool
- func (p *API) ListFolder(path string, opts ListFolderOptions) (models.ListfolderResponse, error)
- func (p *API) LoginWithPassword(username, password string) (UserinfoResponse, []byte, error)
- func (p *API) Query(req *Request) ([]byte, error)
- func (p *API) RenameFile(sourcePath, destinationPath string) (models.RenamefileResponse, error)
- func (p *API) RenameFolder(sourcePath, destinationPath string) (models.RenamefolderResponse, error)
- func (p *API) UploadFile(localPath, remotePath string, renameIfExists bool) (models.UploadfileResponse, error)
- type CloudAPI
- type ListFolderOptions
- type Request
- type UserinfoResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
API is a pCloud client holding session-level configuration.
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) 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
EnsureFolder creates path on pCloud if it does not already exist. It uses /createfolderifnotexists and is idempotent.
func (*API) GetFileLink ¶
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 (*API) IsConfigured ¶
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) 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 ¶
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 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.