Documentation
¶
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) DownloadFile(ctx context.Context, fileID string, maxRetries int) (io.ReadCloser, error)
- func (c *Client) GetFileMetadata(ctx context.Context, fileID string, maxRetries int) (*drive.File, error)
- func (c *Client) GetFilePermissions(ctx context.Context, fileID string, maxRetries int) ([]*drive.Permission, error)
- func (c *Client) GetGroupMembers(ctx context.Context, groupEmail string) ([]string, error)
- func (c *Client) IsFolderAccessible(ctx context.Context, folderID string) bool
- func (c *Client) ListFolderContents(ctx context.Context, folderID string, maxRetries int) ([]*drive.File, error)
- type GoogleClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements GoogleClient using Google Drive and Cloud Identity APIs.
func NewClientFromJSON ¶
NewClientFromJSON creates a new Google API client using raw service account credentials JSON, avoiding the need to write credentials to a temporary file.
func (*Client) Close ¶
func (c *Client) Close()
Close releases resources held by the client, including idle HTTP connections.
func (*Client) DownloadFile ¶
func (c *Client) DownloadFile( ctx context.Context, fileID string, maxRetries int, ) (io.ReadCloser, error)
DownloadFile downloads the content of a file. It handles three cases in order:
- Native Google Workspace files (Docs, Sheets, Slides, Drawings) — exported as PDF via direct Docs editor URLs.
- Uploaded files that Google can open in a Workspace editor (DOCX, XLSX, PPTX, etc.) — also exported as PDF via Docs editor URLs, determined by Drive importFormats.
- All other files — downloaded as raw binary via Drive API.
The caller must close the returned ReadCloser.
func (*Client) GetFileMetadata ¶
func (c *Client) GetFileMetadata( ctx context.Context, fileID string, maxRetries int, ) (*drive.File, error)
GetFileMetadata retrieves metadata for a single file or folder.
func (*Client) GetFilePermissions ¶
func (c *Client) GetFilePermissions( ctx context.Context, fileID string, maxRetries int, ) ([]*drive.Permission, error)
GetFilePermissions retrieves all permissions for a given file ID from the Drive API with retry support.
func (*Client) GetGroupMembers ¶
GetGroupMembers retrieves all transitive members of a Google group by email. It uses Cloud Identity API to expand nested group memberships.
func (*Client) IsFolderAccessible ¶
IsFolderAccessible checks if a folder can be accessed by the service account.
type GoogleClient ¶
type GoogleClient interface {
GetFilePermissions(
ctx context.Context, fileID string, maxRetries int,
) ([]*drive.Permission, error)
GetGroupMembers(
ctx context.Context, groupEmail string,
) ([]string, error)
ListFolderContents(
ctx context.Context, folderID string, maxRetries int,
) ([]*drive.File, error)
GetFileMetadata(
ctx context.Context, fileID string, maxRetries int,
) (*drive.File, error)
IsFolderAccessible(
ctx context.Context, folderID string,
) bool
DownloadFile(
ctx context.Context, fileID string, maxRetries int,
) (io.ReadCloser, error)
Close()
}
GoogleClient defines the interface for Google API operations used by the gdrive package.