drivefs

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package drivefs contains helper functions to interact with Google Drive

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenewRefreshTokenForAccount

func RenewRefreshTokenForAccount(ctx context.Context, cr *chrome.Chrome, oauthCredentials string) (string, error)

RenewRefreshTokenForAccount obtains a new OAuth refresh token for an account logged in on the chrome.Chrome instance. This is used by filemanager.DrivefsNewRefreshTokens test to easily obtain a set of new refresh tokens for the pooled GAIA logins.

func WaitForDriveFs

func WaitForDriveFs(ctx context.Context, username string) (string, error)

WaitForDriveFs checks that the Drivefs mount is ready for IO. The username supplied must come from a user logged in using GAIA login.

Types

type APIClient

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

APIClient contains the stored client and Drive API service.

func CreateAPIClient

func CreateAPIClient(ctx context.Context, cr *chrome.Chrome, oauthCredentials, refreshToken string) (*APIClient, error)

CreateAPIClient is a factory method that authorizes the logged in user. The factory returns a APIClient type that has helper methods to perform Drive API tasks.

func (*APIClient) CreateBlankGoogleDoc

func (d *APIClient) CreateBlankGoogleDoc(ctx context.Context, fileName string, dirPath []string) (*drive.File, error)

CreateBlankGoogleDoc creates a google doc with supplied filename in the directory path. All paths should start with root unless they are team drives, in which case the drive path.

func (*APIClient) RemoveFileByID

func (d *APIClient) RemoveFileByID(ctx context.Context, fileID string) error

RemoveFileByID removes the file by supplied fileID.

type FixtureData

type FixtureData struct {
	// Chrome is a connection to an already-started Chrome instance.
	// It cannot be closed by tests.
	Chrome *chrome.Chrome

	// The path that DriveFS has mounted at.
	MountPath string

	// The API connection to the Test extension, reused by tests.
	TestAPIConn *chrome.TestConn

	// The APIClient singleton.
	APIClient *APIClient
}

FixtureData is the struct available for tests.

Jump to

Keyboard shortcuts

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