client

package
v0.1.0-beta4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package acd represent an Amazon Cloud Drive client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	TermsOfUse string `json:"termsOfUse"`
	Status     string `json:"status"`
}

AccountInfo represents information about an Amazon Cloud Drive account.

type AccountQuota

type AccountQuota struct {
	Quota          uint64    `json:"quota"`
	LastCalculated time.Time `json:"lastCalculated"`
	Available      uint64    `json:"available"`
}

AccountQuota represents information about the account quotas.

type AccountUsage

type AccountUsage struct {
	LastCalculated time.Time `json:"lastCalculated"`

	Doc struct {
		Billable struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"billable"`
		Total struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"total"`
	} `json:"doc"`

	Other struct {
		Billable struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"billable"`
		Total struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"total"`
	} `json:"other"`

	Photo struct {
		Billable struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"billable"`
		Total struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"total"`
	} `json:"photo"`

	Video struct {
		Billable struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"billable"`
		Total struct {
			Bytes uint64 `json:"bytes"`
			Count uint64 `json:"count"`
		} `json:"total"`
	} `json:"video"`
}

AccountUsage represents information about the account usage.

func (*AccountUsage) Billable

func (au *AccountUsage) Billable() (bytes uint64, count uint64)

func (*AccountUsage) Total

func (au *AccountUsage) Total() (bytes uint64, count uint64)

type Client

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

Client provides a client for Amazon Cloud Drive.

func New

func New(config *Config) (*Client, error)

New returns a new Amazon Cloud Drive "acd" Client

func (*Client) CheckResponse

func (c *Client) CheckResponse(res *http.Response) error

CheckResponse validates the response from the Amazon Cloud Drive API. It does that by looking at the response's status code and it returns an error for any code lower than 200 or greater than 300

func (*Client) Close

func (c *Client) Close() error

Close finalizes the acd.

func (*Client) Do

func (c *Client) Do(r *http.Request) (*http.Response, error)

Do invokes net/http.Client.Do(). Refer to net/http.Client.Do() for documentation.

func (*Client) Download

func (c *Client) Download(path string) (io.ReadCloser, error)

Download returns an io.ReadCloser for path. The caller is responsible for closing the body.

func (*Client) DownloadFolder

func (c *Client) DownloadFolder(localPath, remotePath string, recursive bool) error

DownloadFolder downloads an entire folder to a path, if recursive is true, it will also download all subfolders.

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo() (*AccountInfo, error)

GetAccountInfo returns AccountInfo about the current account.

func (*Client) GetAccountQuota

func (c *Client) GetAccountQuota() (*AccountQuota, error)

GetAccountQuota returns AccountQuota about the current account.

func (*Client) GetAccountUsage

func (c *Client) GetAccountUsage() (*AccountUsage, error)

GetAccountUsage returns AccountUsage about the current account.

func (*Client) GetContentURL

func (c *Client) GetContentURL(path string) string

GetContentURL returns the content url.

func (*Client) GetMetadataURL

func (c *Client) GetMetadataURL(path string) string

GetMetadataURL returns the metadata url.

func (*Client) GetNodeTree

func (c *Client) GetNodeTree() *node.Tree

GetNodeTree returns the nodeTree.

func (*Client) GetTrash

func (c *Client) GetTrash() ([]*node.Node, error)

GetTrash will get all the nodes in the trash

func (*Client) List

func (c *Client) List(path string) (node.Nodes, error)

List returns nodes.Nodes for all of the nodes underneath the path. It's up to the caller to differentiate between a file, a folder or an asset by using (*node.Node).IsFile(), (*node.Node).IsDir() and/or (*node.Node).IsAsset(). A dir has sub-nodes accessible via (*node.Node).Nodes, you do not need to call this this function for every sub-node.

func (*Client) PurgeNodes

func (c *Client) PurgeNodes(nodes []*node.Node) error

PurgeNodes will purge the provided nodes

func (*Client) PurgeTrash

func (c *Client) PurgeTrash() error

PurgeTrash will purge all nodes in the trash

func (*Client) RefreshToken

func (c *Client) RefreshToken() error

func (*Client) Upload

func (c *Client) Upload(filename string, overwrite bool, labels []string, properties node.Property, r io.Reader) (*node.Node, error)

Upload uploads io.Reader to the path defined by the filename. It will create any non-existing folders.

func (*Client) UploadFolder

func (c *Client) UploadFolder(localPath, remotePath string, recursive, overwrite bool, labels []string, properties node.Property) error

UploadFolder uploads an entire folder. If recursive is true, it will recurse through the entire filetree under localPath. If overwrite is false and an existing file with the same md5 was found, an error will be returned.

type Config

type Config struct {
	// AppName is the name of the application to send to Amazon
	AppName string `json:"appName"`

	// AppVersion is the version of the application to send to Amazon
	AppVersion string `json:"appVersion"`

	// CacheFile represents the file used by the client to cache the NodeTree.
	// This file is not assumed to be present and will be created on the first
	// run. It is gob-encoded node.Node.
	CacheFile string `json:"cacheFile"`

	// Headers contains all the additional headers to pass on all requests made.
	Headers map[string]string `json:"headers"`

	// PurgeTrashInterval is how often to purge trash
	PurgeTrashInterval string `json:"purgeTrashInterval"`

	// RefreshToken is an Amazon API Refresh Token
	// https://developer.amazon.com/docs/login-with-amazon/refresh-token.html
	RefreshToken string `json:"refreshToken"`

	// SyncChunkSize is the number of nodes to be returned within each Changes
	// object in the response stream.
	SyncChunkSize int `json:"syncChunkSize"`

	// SyncInterval is how often to sync the Node Tree cache
	SyncInterval string `json:"syncInterval"`

	// Timeout configures the HTTP Client with a timeout after which the client
	// will cancel the request and return. A timeout of 0 means no timeout.
	// See http://godoc.org/net/http#Client for more information.
	Timeout string `json:"timeout"`

	// UserAgent is the value to use for the user agent header on all http requests
	UserAgent string `json:"userAgent"`
	// contains filtered or unexported fields
}

Config represents the clients configuration.

func LoadConfig

func LoadConfig(configFile string) (*Config, error)

Jump to

Keyboard shortcuts

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