gsmdrive

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: GPL-3.0 Imports: 16 Imported by: 1

Documentation

Overview

Package gsmdrive implements the Drive API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(fileID, includePermissionsForView, ocrLanguage, fields string, file *drive.File, ignoreDefaultVisibility, keepRevisionForever bool) (*drive.File, error)

CopyFile creates a copy of a file and applies any requested updates with patch semantics. Folders cannot be copied.

func CopyFoldersAndReturnFilesWithNewParents added in v0.2.3

func CopyFoldersAndReturnFilesWithNewParents(folderID, destination string, results chan *drive.File, excludeFolders []string, threads int) (<-chan *drive.File, error)

CopyFoldersAndReturnFilesWithNewParents creates copy of each folder in the supplied channel, adds the new ID to the parents propertie of the files in the source folder and returns the files in a channel.

func CreateComment

func CreateComment(fileID, fields string, comment *drive.Comment) (*drive.Comment, error)

CreateComment creates a new comment on a file.

func CreateDrive

func CreateDrive(d *drive.Drive, fields string, returnWhenReady bool) (*drive.Drive, error)

CreateDrive creates a new shared drive.

func CreateFile

func CreateFile(file *drive.File, content *os.File, ignoreDefaultVisibility, keepRevisionForever, useContentAsIndexableText bool, includePermissionsForView, ocrLanguage, sourceMimeType, fields string) (*drive.File, error)

CreateFile creates a new file.

func CreatePermission

func CreatePermission(fileID, emailMessage, fields string, useDomainAdminAccess, sendNotificationEmail, transferOwnership, moveToNewOwnersRoot bool, permission *drive.Permission) (*drive.Permission, error)

CreatePermission creates a permission for a file or shared drive.

func CreateReply

func CreateReply(fileID, commentID, fields string, reply *drive.Reply) (*drive.Reply, error)

CreateReply creates a new reply to a comment.

func DeleteComment

func DeleteComment(fileID, commentID string) (bool, error)

DeleteComment deletes a comment.

func DeleteDrive

func DeleteDrive(driveID string, useDomainAdminAccess bool) (bool, error)

DeleteDrive permanently deletes a shared drive for which the user is an organizer. The shared drive cannot contain any untrashed items.

func DeleteFile

func DeleteFile(fileID string) (bool, error)

DeleteFile permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a shared drive the user must be an organizer on the parent. If the target is a folder, all descendants owned by the user are also deleted.

func DeletePermission

func DeletePermission(fileID, permissionID string, useDomainAdminAccess bool) (bool, error)

DeletePermission deletes a permission.

func DeleteReply

func DeleteReply(fileID, commentID, replyID string) (bool, error)

DeleteReply deletes a reply.

func DeleteRevision

func DeleteRevision(fileID, revisionID string) (bool, error)

DeleteRevision permanently deletes a file version. You can only delete revisions for files with binary content in Google Drive, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted.

func DownloadFile

func DownloadFile(fileID, localFilePath string, acknowledgeAbuse bool) (string, error)

DownloadFile downloads a file from drive

func DownloadRevision

func DownloadRevision(fileID, revisionID string, acknowledgeAbuse bool) (string, error)

DownloadRevision downloads a file revision from drive

func EmptyTrash

func EmptyTrash() (bool, error)

EmptyTrash permanently deletes all of the user's trashed files.

func ExportFile

func ExportFile(fileID, mimeType, localFilePath string) (string, error)

ExportFile exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB.

func GenerateFileIDs

func GenerateFileIDs(count int64, space string) ([]string, error)

GenerateFileIDs generates a set of file IDs which can be provided in create or copy requests.

func GetAbout

func GetAbout(fields string) (*drive.About, error)

GetAbout gets information about the user, the user's Drive, and system capabilities.

func GetComment

func GetComment(fileID, commentID, fields string, includeDeleted bool) (*drive.Comment, error)

GetComment gets a comment by ID.

func GetDrive

func GetDrive(driveID, fields string, useDomainAdminAccess bool) (*drive.Drive, error)

GetDrive gets a shared drive's metadata by ID.

func GetFile

func GetFile(fileID, fields, includePermissionsForView string) (*drive.File, error)

GetFile gets a file's metadata or content by ID.

func GetFolder added in v0.2.3

func GetFolder(folderID string) (*drive.File, error)

GetFolder returns the file if it can be found AND is a folder, otherwise, it returns an error

func GetPermission

func GetPermission(fileID, permissionID, fields string, useDomainAdminAccess bool) (*drive.Permission, error)

GetPermission gets a permission by ID.

func GetPermissionID added in v0.2.3

func GetPermissionID(flags map[string]*gsmhelpers.Value) (string, error)

GetPermissionID returns the permissionId from a flag set if either the permissionId itself, or the emailAddress is set. Otherwise, it will return an error.

func GetReply

func GetReply(fileID, commentID, replyID, fields string, includeDeleted bool) (*drive.Reply, error)

GetReply gets a reply by ID.

func GetRevision

func GetRevision(fileID, revisionID, fields string) (*drive.Revision, error)

GetRevision gets a revision's metadata or content by ID.

func GetStartPageToken

func GetStartPageToken(driveID, fields string) (*drive.StartPageToken, error)

GetStartPageToken gets the starting pageToken for listing future changes.

func HideDrive

func HideDrive(driveID, fields string) (*drive.Drive, error)

HideDrive hides a shared drive from the default view.

func ListChanges

func ListChanges(pageToken, driveID, spaces, fields, includePermissionsForView string, includeCorpusRemovals, includeItemsFromAllDrives, includeRemoved, restrictToMyDrive bool) ([]*drive.Change, string, error)

ListChanges lists the changes for a user or shared drive.

func ListComments

func ListComments(fileID, startModifiedTime, fields string, includeDeleted bool, cap int) (<-chan *drive.Comment, <-chan error)

ListComments lists a file's comments.

func ListDrives

func ListDrives(filter, fields string, useDomainAdminAccess bool, cap int) (<-chan *drive.Drive, <-chan error)

ListDrives lists the user's shared drives. This method accepts the q parameter, which is a search query combining one or more search terms. For more information, see https://developers.google.com/drive/api/v3/search-shareddrives.

func ListFiles

func ListFiles(q, driveID, corpora, includePermissionsForView, orderBy, spaces, fields string, includeItemsFromAllDrives bool, cap int) (<-chan *drive.File, <-chan error)

ListFiles lists or searches files. This method accepts the q parameter, which is a search query combining one or more search terms. For more information, see https://developers.google.com/drive/api/v3/search-files.

func ListFilesRecursive

func ListFilesRecursive(id, fields string, excludeFolders []string, includeRoot bool, threads int) <-chan *drive.File

ListFilesRecursive lists all files and foldes in a parent folder recursively

func ListLabels added in v0.8.0

func ListLabels(fileID, fields string, cap int) (<-chan *drive.Label, <-chan error)

ListLabels lists the labels on a file.

func ListPermissions

func ListPermissions(fileID, includePermissionsForView, fields string, useDomainAdminAccess bool, cap int) (<-chan *drive.Permission, <-chan error)

ListPermissions lists a file's or shared drive's permissions.

func ListReplies

func ListReplies(fileID, commentID, fields string, includeDeleted bool, cap int) (<-chan *drive.Reply, <-chan error)

ListReplies Lists a comment's replies.

func ListRevisions

func ListRevisions(fileID, fields string, cap int) (<-chan *drive.Revision, <-chan error)

ListRevisions lists a file's revisions.

func ModifyLabels added in v0.8.0

func ModifyLabels(fileID, fields string, modifyLabelsRequest *drive.ModifyLabelsRequest) ([]*drive.Label, error)

ModifyLabels modifies the set of labels on a file.

func SetClient

func SetClient(c *http.Client)

SetClient is used to inject a *http.Client into the package

func UnhideDrive

func UnhideDrive(driveID, fields string) (*drive.Drive, error)

UnhideDrive restores a shared drive to the default view.

func UpdateComment

func UpdateComment(fileID, commentID, fields string, comment *drive.Comment) (*drive.Comment, error)

UpdateComment updates a comment with patch semantics.

func UpdateDrive

func UpdateDrive(driveID, fields string, useDomainAdminAccess bool, d *drive.Drive) (*drive.Drive, error)

UpdateDrive updates the metadate for a shared drive.

func UpdateFile

func UpdateFile(fileID, addParents, removeParents, includePermissionsForView, ocrLanguage, fields string, file *drive.File, content *os.File, keepRevisionForever, useContentAsIndexableText bool) (*drive.File, error)

UpdateFile updates a file's metadata and/or content. This method supports patch semantics.

func UpdatePermission

func UpdatePermission(fileID, permissionID, fields string, useDomainAdminAccess, removeExpiration bool, permission *drive.Permission) (*drive.Permission, error)

UpdatePermission updates a permission with patch semantics.

func UpdateReply

func UpdateReply(fileID, commentID, replyID, fields string, reply *drive.Reply) (*drive.Reply, error)

UpdateReply updates a reply with patch semantics.

func UpdateRevision

func UpdateRevision(fileID, revisionID, fields string, revision *drive.Revision) (*drive.Revision, error)

UpdateRevision updates a revision with patch semantics.

Types

type FolderSize added in v0.2.4

type FolderSize struct {
	Files   int64 `json:"files,omitempty"`
	Folders int64 `json:"folders,omitempty"`
	Size    int64 `json:"size,omitempty"`
}

FolderSize represents the size of a Drive folder or Shared Drive

func CountFilesAndFolders added in v0.2.4

func CountFilesAndFolders(filesCh <-chan *drive.File) (folderSize *FolderSize)

CountFilesAndFolders returns the number of files in a channel and their size

Jump to

Keyboard shortcuts

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