Documentation
¶
Index ¶
- Constants
- Variables
- func CheckResponse(r *http.Response) error
- func EscapeForFilter(s string) string
- type AccountEndpoints
- type AccountInfo
- type AccountQuota
- type AccountService
- func (s *AccountService) GetEndpoints() (*AccountEndpoints, *http.Response, error)
- func (s *AccountService) GetInfo() (*AccountInfo, *http.Response, error)
- func (s *AccountService) GetQuota() (*AccountQuota, *http.Response, error)
- func (s *AccountService) GetUsage() (*AccountUsage, *http.Response, error)
- type AccountUsage
- type CategoryUsage
- type ChangeSet
- type ChangesOptions
- type ChangesService
- func (s *ChangesService) GetChanges(opts *ChangesOptions) ([]*ChangeSet, *http.Response, error)
- func (s *ChangesService) GetChangesChan(opts *ChangesOptions, ch chan<- *ChangeSet) (*http.Response, error)
- func (s *ChangesService) GetChangesFunc(opts *ChangesOptions, f func(*ChangeSet, error) error) (*http.Response, error)
- type Client
- type File
- func (f *File) Download(path string) (*http.Response, error)
- func (f *File) Open() (in io.ReadCloser, resp *http.Response, err error)
- func (f *File) OpenHeaders(headers map[string]string) (in io.ReadCloser, resp *http.Response, err error)
- func (f *File) OpenTempURL(client *http.Client) (in io.ReadCloser, resp *http.Response, err error)
- func (f *File) OpenTempURLHeaders(client *http.Client, headers map[string]string) (in io.ReadCloser, resp *http.Response, err error)
- func (f *File) Overwrite(in io.Reader) (*File, *http.Response, error)
- func (f *File) OverwriteSized(in io.Reader, _ int64) (*File, *http.Response, error)deprecated
- type Folder
- func (f *Folder) CreateFolder(name string) (*Folder, *http.Response, error)
- func (f *Folder) GetAllChildren(opts *NodeListOptions) ([]*Node, *http.Response, error)
- func (f *Folder) GetChildren(opts *NodeListOptions) ([]*Node, *http.Response, error)
- func (f *Folder) GetFile(name string) (*File, *http.Response, error)
- func (f *Folder) GetFolder(name string) (*Folder, *http.Response, error)
- func (f *Folder) GetNode(name string) (*Node, *http.Response, error)
- func (f *Folder) Put(in io.Reader, name string) (*File, *http.Response, error)
- func (f *Folder) PutSized(in io.Reader, _ int64, name string) (*File, *http.Response, error)deprecated
- func (f *Folder) Upload(path, name string) (*File, *http.Response, error)
- func (f *Folder) WalkNodes(names ...string) (*Node, []*http.Response, error)
- type Node
- func (n *Node) AddParent(newParentID string) (*http.Response, error)
- func (n *Node) GetMetadata() (string, error)
- func (n *Node) GetTempURL() (*http.Response, error)
- func (n *Node) IsFile() bool
- func (n *Node) IsFolder() bool
- func (n *Node) RemoveParent(parentID string) (*http.Response, error)
- func (n *Node) Rename(newName string) (*Node, *http.Response, error)
- func (n *Node) ReplaceParent(oldParentID string, newParentID string) (*http.Response, error)
- func (n *Node) Restore() (*Node, *http.Response, error)
- func (n *Node) Trash() (*http.Response, error)
- func (n *Node) Typed() interface{}
- type NodeListOptions
- type NodesService
- type UsageNumbers
Constants ¶
const (
// LibraryVersion is the current version of this library
LibraryVersion = "0.1.0"
)
Variables ¶
var ( // ErrorNodeNotFound is returned from GetFile, GetFolder, GetNode ErrorNodeNotFound = errors.New("Node not found") )
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range.
func EscapeForFilter ¶
EscapeForFilter escapes an abitrary string for use as a filter query parameter.
Special characters that are part of the query syntax will be escaped. The list of special characters are:
+ - & | ! ( ) { } [ ] ^ ' " ~ * ? : \
Additionally, space will be escaped. Characters are escaped by using \ before the character.
Types ¶
type AccountEndpoints ¶
type AccountEndpoints struct { CustomerExists bool `json:"customerExists"` ContentURL string `json:"contentUrl"` MetadataURL string `json:"metadataUrl"` }
AccountEndpoints represents information about the current customer's endpoints
type AccountInfo ¶
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 AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService provides access to the account related functions in the Amazon Cloud Drive API.
See: https://developer.amazon.com/public/apis/experience/cloud-drive/content/account
func (*AccountService) GetEndpoints ¶
func (s *AccountService) GetEndpoints() (*AccountEndpoints, *http.Response, error)
GetEndpoints retrives the current endpoints for this customer
It also updates the endpoints in the client
func (*AccountService) GetInfo ¶
func (s *AccountService) GetInfo() (*AccountInfo, *http.Response, error)
GetInfo provides information about the current user account like the status and the accepted “Terms Of Use”.
func (*AccountService) GetQuota ¶
func (s *AccountService) GetQuota() (*AccountQuota, *http.Response, error)
GetQuota gets account quota and storage availability information.
func (*AccountService) GetUsage ¶
func (s *AccountService) GetUsage() (*AccountUsage, *http.Response, error)
GetUsage gets Account Usage information broken down by content category.
type AccountUsage ¶
type AccountUsage struct { LastCalculated *time.Time `json:"lastCalculated"` Other *CategoryUsage `json:"other"` Doc *CategoryUsage `json:"doc"` Photo *CategoryUsage `json:"photo"` Video *CategoryUsage `json:"video"` }
AccountUsage represents information about the account usage.
type CategoryUsage ¶
type CategoryUsage struct { Total *UsageNumbers `json:"total"` Billable *UsageNumbers `json:"billable"` }
CategoryUsage defines Total and Billable UsageNumbers
type ChangeSet ¶
type ChangeSet struct { Checkpoint string `json:"checkpoint"` Nodes []*Node `json:"nodes"` Reset bool `json:"reset"` StatusCode int `json:"statusCode"` End bool `json:"end"` }
A ChangeSet is collection of node changes as received from the Changes API
type ChangesOptions ¶
type ChangesOptions struct { Checkpoint string `json:"checkpoint,omitempty"` ChunkSize int `json:"chunkSize,omitempty"` MaxNodes int `json:"maxNodes,omitempty"` IncludePurged bool `json:"includePurged,omitempty,string"` }
ChangesOptions contains all possible arguments for the Changes API
type ChangesService ¶
type ChangesService struct {
// contains filtered or unexported fields
}
ChangesService provides access to incemental changes in the Amazon Cloud Drive API.
See: https://developer.amazon.com/public/apis/experience/cloud-drive/content/changes
func (*ChangesService) GetChanges ¶
func (s *ChangesService) GetChanges(opts *ChangesOptions) ([]*ChangeSet, *http.Response, error)
GetChanges returns all the changes since opts.Checkpoint
func (*ChangesService) GetChangesChan ¶
func (s *ChangesService) GetChangesChan(opts *ChangesOptions, ch chan<- *ChangeSet) (*http.Response, error)
GetChangesChan gets all the changes since opts.Checkpoint sending each ChangeSet to the channel. The provided channel is closed before returning
func (*ChangesService) GetChangesFunc ¶
func (s *ChangesService) GetChangesFunc(opts *ChangesOptions, f func(*ChangeSet, error) error) (*http.Response, error)
GetChangesFunc gets all the changes since opts.Checkpoint and calls f with the ChangeSet or the error received. If f returns a non nil value, GetChangesFunc exits and returns the given error.
type Client ¶
type Client struct { // Metadata URL for API requests. Defaults to the public Amazon Cloud Drive API. // MetadataURL should always be specified with a trailing slash. MetadataURL *url.URL // Content URL for API requests. Defaults to the public Amazon Cloud Drive API. // ContentURL should always be specified with a trailing slash. ContentURL *url.URL // User agent used when communicating with the API. UserAgent string // Services used for talking to different parts of the API. Account *AccountService Nodes *NodesService Changes *ChangesService // contains filtered or unexported fields }
A Client manages communication with the Amazon Cloud Drive API.
func NewClient ¶
NewClient returns a new Amazon Cloud Drive API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If v is nil then the resp.Body won't be closed - this is your responsibility.
func (*Client) NewContentRequest ¶
NewContentRequest creates an API request for content. A relative URL can be provided in urlStr, in which case it is resolved relative to the ContentURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) NewMetadataRequest ¶
NewMetadataRequest creates an API request for metadata. A relative URL can be provided in urlStr, in which case it is resolved relative to the MetadataURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type File ¶
type File struct {
*Node
}
File represents a file on the Amazon Cloud Drive.
func (*File) Download ¶
Download fetches the content of file f and stores it into the file pointed to by path. Errors if the file at path already exists. Does not create the intermediate directories in path.
func (*File) OpenHeaders ¶
func (f *File) OpenHeaders(headers map[string]string) (in io.ReadCloser, resp *http.Response, err error)
OpenHeaders opens the content of the file f for read
Extra headers for the GET can be passed in in headers ¶
You must call in.Close() when finished
func (*File) OpenTempURL ¶
OpenTempURL opens the content of the file f for read from the TempURL
Pass in an http Client (without authorization) for the download.
You must call in.Close() when finished
func (*File) OpenTempURLHeaders ¶
func (f *File) OpenTempURLHeaders(client *http.Client, headers map[string]string) (in io.ReadCloser, resp *http.Response, err error)
OpenTempURLHeaders opens the content of the file f for read from the TempURL
Pass in an http Client (without authorization) for the download.
You must call in.Close() when finished
type Folder ¶
type Folder struct {
*Node
}
Folder represents a folder on the Amazon Cloud Drive.
func FolderFromId ¶
func FolderFromId(ID string, service *NodesService) *Folder
FolderFromId constructs a skeleton Folder from an Id and a NodeService
func (*Folder) CreateFolder ¶
CreateFolder makes a new folder with the given name.
The new Folder is returned
func (*Folder) GetAllChildren ¶
GetAllChildren gets the list of all children.
func (*Folder) GetChildren ¶
GetChildren gets a list of children, up until the limit (either default or the one set in opts).
func (*Folder) GetFile ¶
GetFile gets the file by name. It is an error if not exactly one file is found.
If it isn't found then it returns the error ErrorNodeNotFound
func (*Folder) GetFolder ¶
GetFolder gets the subfolder by name. It is an error if not exactly one subfolder is found.
If it isn't found then it returns the error ErrorNodeNotFound
func (*Folder) GetNode ¶
GetNode gets the node by name. It is an error if not exactly one node is found.
If it isn't found then it returns the error ErrorNodeNotFound
func (*Folder) Put ¶
Put stores the data read from in at path as name on the Amazon Cloud Drive. Errors if the file already exists on the drive.
func (*Folder) PutSized
deprecated
type Node ¶
type Node struct { Id *string `json:"id"` Name *string `json:"name"` Kind *string `json:"kind"` ModifiedDate *string `json:"modifiedDate"` Parents []string `json:"parents"` Status *string `json:"status"` ContentProperties *struct { Size *uint64 `json:"size"` Md5 *string `json:"md5"` ContentType *string `json:"contentType"` } `json:"contentProperties"` TempURL string `json:"tempLink"` // contains filtered or unexported fields }
Node represents a digital asset on the Amazon Cloud Drive, including files and folders, in a parent-child relationship. A node contains only metadata (e.g. folder) or it contains metadata and content (e.g. file).
func NodeFromId ¶
func NodeFromId(ID string, service *NodesService) *Node
NodeFromId constructs a skeleton Node from an Id and a NodeService
func (*Node) AddParent ¶
AddParent adds an additional parent to Node n. Can return a 409 Conflict if there's already a file or folder below the new parent with the same name as Node n.
func (*Node) GetMetadata ¶
GetMetadata return a pretty-printed JSON string of the node's metadata
func (*Node) GetTempURL ¶
GetTempURL sets the TempURL for the node passed in if it isn't already set
func (*Node) RemoveParent ¶
RemoveParent removes a parent from Node n. If all parents are removed, the file is instead attached to the absolute root folder of AmazonDrive.
func (*Node) ReplaceParent ¶
ReplaceParent puts Node n below a new parent while removing the old one at the same time. This is equivalent to calling AddParent and RemoveParent sequentially, but only needs one REST call. Can return a 409 Conflict if there's already a file or folder in the new location with the same name as Node n.
func (*Node) Restore ¶
Restore moves a previously trashed Node n back into all its connected parents
type NodeListOptions ¶
type NodeListOptions struct { Limit uint `url:"limit,omitempty"` Filters string `url:"filters,omitempty"` Sort string `url:"sort,omitempty"` // Token where to start for next page (internal) StartToken string `url:"startToken,omitempty"` // contains filtered or unexported fields }
NodeListOptions holds the options when getting a list of nodes, such as the filter, sorting and pagination.
type NodesService ¶
type NodesService struct {
// contains filtered or unexported fields
}
NodesService provides access to the nodes in the Amazon Cloud Drive API.
See: https://developer.amazon.com/public/apis/experience/cloud-drive/content/nodes
func (*NodesService) GetAllNodes ¶
func (s *NodesService) GetAllNodes(opts *NodeListOptions) ([]*Node, *http.Response, error)
GetAllNodes gets the list of all nodes.
func (*NodesService) GetNodes ¶
func (s *NodesService) GetNodes(opts *NodeListOptions) ([]*Node, *http.Response, error)
GetNodes gets a list of nodes, up until the limit (either default or the one set in opts).
type UsageNumbers ¶
UsageNumbers defines Bytes and Count for a metered count