drive

package
v0.0.0-...-51f1e59 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Fields string

Fields are the fields that should be returned by the Google Drive API

Functions

This section is empty.

Types

type APIObject

type APIObject struct {
	ObjectID     string
	Name         string
	IsDir        bool
	Size         uint64
	LastModified time.Time
	DownloadURL  string
	Parents      []string
	CanTrash     bool
}

APIObject is a Google Drive file object

type Cache

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

Cache is the cache

func NewCache

func NewCache(cacheFile, configPath string, sqlDebug bool) (*Cache, error)

NewCache creates a new cache instance

func (*Cache) BatchUpdateObjects

func (c *Cache) BatchUpdateObjects(objects []*APIObject) error

func (*Cache) Close

func (c *Cache) Close() error

Close closes all handles

func (*Cache) DeleteObject

func (c *Cache) DeleteObject(id string) error

DeleteObject deletes an object by id

func (*Cache) GetObject

func (c *Cache) GetObject(id string) (object *APIObject, err error)

GetObject gets an object by id

func (*Cache) GetObjectByParentAndName

func (c *Cache) GetObjectByParentAndName(parent, name string) (object *APIObject, err error)

GetObjectByParentAndName finds a child element by name and its parent id

func (*Cache) GetObjectsByParent

func (c *Cache) GetObjectsByParent(parent string) ([]*APIObject, error)

GetObjectsByParent get all objects under parent id

func (*Cache) GetStartPageToken

func (c *Cache) GetStartPageToken() (string, error)

GetStartPageToken gets the start page token

func (*Cache) LoadToken

func (c *Cache) LoadToken() (*oauth2.Token, error)

LoadToken loads a token from cache

func (*Cache) StoreStartPageToken

func (c *Cache) StoreStartPageToken(token string) error

StoreStartPageToken stores the page token for changes

func (*Cache) StoreToken

func (c *Cache) StoreToken(token *oauth2.Token) error

StoreToken stores a token in the cache or updates the existing token element

func (*Cache) UpdateObject

func (c *Cache) UpdateObject(object *APIObject) error

UpdateObject updates an object

type Client

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

Client holds the Google Drive API connection(s)

func NewClient

func NewClient(config *config.Config, cache *Cache, refreshInterval time.Duration, rootNodeID string, driveID string) (*Client, error)

NewClient creates a new Google Drive client

func (*Client) GetNativeClient

func (d *Client) GetNativeClient() *http.Client

GetNativeClient gets a native http client

func (*Client) GetObject

func (d *Client) GetObject(id string) (*APIObject, error)

GetObject gets an object by id

func (*Client) GetObjectByParentAndName

func (d *Client) GetObjectByParentAndName(parent, name string) (*APIObject, error)

GetObjectByParentAndName finds a child element by name and its parent id

func (*Client) GetObjectsByParent

func (d *Client) GetObjectsByParent(parent string) ([]*APIObject, error)

GetObjectsByParent get all objects under parent id

func (*Client) GetRoot

func (d *Client) GetRoot() (*APIObject, error)

GetRoot gets the root node directly from the API

func (*Client) Mkdir

func (d *Client) Mkdir(parent string, Name string) (*APIObject, error)

Mkdir creates a new directory in Google Drive

func (*Client) Remove

func (d *Client) Remove(object *APIObject, parent string) error

Remove removes file from Google Drive

func (*Client) Rename

func (d *Client) Rename(object *APIObject, OldParent string, NewParent string, NewName string) error

Rename renames file in Google Drive

type PageToken

type PageToken struct {
	ID    string
	Token string
}

PageToken is the last change id

Jump to

Keyboard shortcuts

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