Documentation
¶
Overview ¶
Package node represents the Amazon Cloud Drive nodes documented at https://developer.amazon.com/public/apis/experience/cloud-drive/content/nodes It also provides the Tree struct which allows you to refer to the entire filesystem as a file tree as defined by the Amazon documentation.
Index ¶
- Variables
- type ContentProperties
- type Node
- func (n *Node) AddChild(child *Node)
- func (n *Node) Available() bool
- func (n *Node) CreateFolder(name string) (*Node, error)
- func (n *Node) Download() (io.ReadCloser, error)
- func (n *Node) IsAsset() bool
- func (n *Node) IsDir() bool
- func (n *Node) IsFile() bool
- func (n *Node) ModTime() time.Time
- func (n *Node) Overwrite(r io.Reader) error
- func (n *Node) Remove() error
- func (n *Node) RemoveChild(child *Node)
- func (n *Node) Size() int64
- func (n *Node) Upload(name string, r io.Reader) (*Node, error)
- type Nodes
- type Tree
Constants ¶
This section is empty.
Variables ¶
var ( // Mocked is a valid tree (mock). The IDs are the fully-qualified path of // the file or folder to make testing easier. // / // |-- README.md // |-- pictures // |-- | // | -- logo.png Mocked = &Tree{ Node: rootNode, nodeMap: map[string]*Node{ "/": rootNode, "/README.md": rootNode.Nodes[0], "/pictures": rootNode.Nodes[1], "/pictures/logo.png": rootNode.Nodes[1].Nodes[0], }, } )
Functions ¶
This section is empty.
Types ¶
type ContentProperties ¶
type ContentProperties struct {
Version uint64 `json:"version,omitempty"`
Extension string `json:"extension,omitempty"`
Size uint64 `json:"size,omitempty"`
MD5 string `json:"md5,omitempty"`
ContentType string `json:"contentType,omitempty"`
ContentDate time.Time `json:"contentDate,omitempty"`
}
ContentProperties hold the properties of the node.
type Node ¶
type Node struct {
// Coming from Amazon
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Kind string `json:"kind,omitempty"`
Parents []string `json:"Parents,omitempty"`
Status string `json:"status,omitempty"`
Labels []string `json:"labels,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
CreationDate time.Time `json:"creationDate,omitempty"`
ModifiedDate time.Time `json:"modifiedDate,omitempty"`
Version uint64 `json:"version,omitempty"`
TempLink string `json:"tempLink,omitempty"`
ContentProperties ContentProperties `json:"contentProperties,omitempty"`
// Internal
Nodes Nodes `json:"nodes,omitempty"`
Root bool `json:"root,omitempty"`
// 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 (*Node) CreateFolder ¶
CreateFolder creates the named folder under the node
func (*Node) Download ¶
func (n *Node) Download() (io.ReadCloser, error)
Download downloads the node and returns the body as io.ReadCloser or an error. The caller is responsible for closing the reader.
func (*Node) Remove ¶
Remove deletes a node from the server. This function does not update the NodeTree, the caller should do so!
func (*Node) RemoveChild ¶
RemoveChild remove a new child for the node
type Tree ¶
type Tree struct {
*Node
// Internal
LastUpdated time.Time
Checkpoint string
// contains filtered or unexported fields
}
Tree represents a node tree.
func (*Tree) FindNode ¶
FindNode finds a node for a particular path. TODO(kalbasit): This does not perform well, this should be cached in a map path->node and calculated on load (fresh, cache, refresh).
func (*Tree) MkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents, and returns the directory node and nil, or else returns an error. If path is already a directory, MkdirAll does nothing and returns the directory node and nil.
func (*Tree) RemoveNode ¶
RemoveNode removes this node from the server and from the NodeTree.