gdrive_utils

package module
Version: v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 22 Imported by: 4

README

gdrive-utils

Google Drive API Utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPermission added in v0.0.4

func AddPermission(svc *drive.Service, docId string, email string, role string) (string, error)

func CopyDoc added in v0.0.4

func CopyDoc(svcDrive *drive.Service, svcDocs *docs.Service, templateDocId string, folderId string, docName string, replacements map[string]string) (string, error)

func DefaultClient

func DefaultClient(dir string, scopes ...string) (*http.Client, error)

func FindParentFolderId added in v0.0.4

func FindParentFolderId(svc *drive.Service, configDocId string) (string, error)

func GetFolderId added in v0.0.4

func GetFolderId(svc *drive.Service, configDocId string, p string) (string, error)

func NewClient

func NewClient(dir string, config *oauth2.Config) *http.Client

Retrieves a token, saves the token, then returns the generated client.

func RevokePermission added in v0.0.4

func RevokePermission(svc *drive.Service, docId string, email string) error

Types

type Predicate

type Predicate struct {
	Header string
	By     func(v []interface{}) (int, error)
}

type SheetReader

type SheetReader struct {
	ValueRenderOption    string
	DateTimeRenderOption string
	// contains filtered or unexported fields
}

func NewColumnReader

func NewColumnReader(srv *sheets.Service, spreadsheetId, sheetName, header string) (*SheetReader, error)

func NewLastRowReader

func NewLastRowReader(srv *sheets.Service, spreadsheetId, sheetName string) (*SheetReader, error)

func NewReader

func NewReader(srv *sheets.Service, spreadsheetId, sheetName string, rowStart int) (*SheetReader, error)

func NewRowReader

func NewRowReader(srv *sheets.Service, spreadsheetId, sheetName string, predicate *Predicate) (*SheetReader, error)

func (*SheetReader) Read

func (r *SheetReader) Read() (record []string, err error)

Read reads one record (a slice of fields) from r. If the record has an unexpected number of fields, Read returns the record along with the error ErrFieldCount. Except for that case, Read always returns either a non-nil record or a non-nil error, but not both. If there is no data left to be read, Read returns nil, io.EOF. If ReuseRecord is true, the returned slice may be shared between multiple calls to Read.

func (*SheetReader) ReadAll

func (r *SheetReader) ReadAll() (records [][]string, err error)

ReadAll reads all the remaining records from r. Each record is a slice of fields. A successful call returns err == nil, not err == io.EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.

type SheetWriter

type SheetWriter struct {
	ValueRenderOption    string
	DateTimeRenderOption string
	// contains filtered or unexported fields
}

func NewRowWriter

func NewRowWriter(srv *sheets.Service, spreadsheetId, sheetName string, predicate *Predicate) *SheetWriter

func NewWriter

func NewWriter(srv *sheets.Service, spreadsheetId, sheetName string) *SheetWriter

func (*SheetWriter) Error

func (w *SheetWriter) Error() error

func (*SheetWriter) Flush

func (w *SheetWriter) Flush()

func (*SheetWriter) Write

func (w *SheetWriter) Write(row []string) error

type Spreadsheet

type Spreadsheet struct {
	SpreadSheetId string
	// contains filtered or unexported fields
}

func NewSpreadsheet

func NewSpreadsheet(srv *sheets.Service, spreadsheetId string) (*Spreadsheet, error)

func (*Spreadsheet) AppendRowData

func (si *Spreadsheet) AppendRowData(sheetId int64, data []string, formatCell bool) error

ref: https://developers.google.com/sheets/api/guides/batchupdate

func (*Spreadsheet) EnsureSheet

func (si *Spreadsheet) EnsureSheet(name string, headers []string) (int64, error)

func (*Spreadsheet) FindEmptyCell

func (si *Spreadsheet) FindEmptyCell(sheetName string) (string, error)

Jump to

Keyboard shortcuts

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