google

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT-0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDocsReadOnly = errors.New("docs is configured as readonly; change to readwrite with 'google-workspace config set --docs=readwrite' then re-authenticate")

ErrDocsReadOnly is returned when a write operation is attempted in readonly mode.

View Source
var ErrDriveReadOnly = errors.New("drive is configured as readonly; change to readwrite with 'google-workspace config set --drive=readwrite' then re-authenticate")

ErrDriveReadOnly is returned when a write operation is attempted in readonly mode.

View Source
var ErrReadOnly = errors.New("calendar is configured as readonly; change to readwrite with 'google-workspace config set --calendar=readwrite' then re-authenticate")

ErrReadOnly is returned when a write operation is attempted in readonly mode.

View Source
var ErrSheetsReadOnly = errors.New("sheets is configured as readonly; change to readwrite with 'google-workspace config set --sheets=readwrite' then re-authenticate")

ErrSheetsReadOnly is returned when a write operation is attempted in readonly mode.

Functions

func IsGoogleAppsFile added in v0.4.0

func IsGoogleAppsFile(mimeType string) bool

IsGoogleAppsFile reports whether the MIME type is a Google Workspace type that requires export rather than direct download.

Types

type CalendarClient

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

CalendarClient provides access to the Google Calendar API with configurable read/write mode.

func NewCalendarClient

func NewCalendarClient(ctx context.Context, ts oauth2.TokenSource, mode config.CalendarMode) (*CalendarClient, error)

NewCalendarClient creates a Calendar API client using the provided token source.

func (*CalendarClient) CreateEvent

func (c *CalendarClient) CreateEvent(ctx context.Context, calendarID string, event *calendar.Event) (*calendar.Event, error)

CreateEvent creates a new calendar event. Requires readwrite mode.

func (*CalendarClient) DeleteEvent

func (c *CalendarClient) DeleteEvent(ctx context.Context, calendarID, eventID string) error

DeleteEvent deletes a calendar event. Requires readwrite mode.

func (*CalendarClient) GetEvent

func (c *CalendarClient) GetEvent(ctx context.Context, calendarID, eventID string) (*calendar.Event, error)

GetEvent retrieves a single event by ID.

func (*CalendarClient) ListCalendars

func (c *CalendarClient) ListCalendars(ctx context.Context) ([]*calendar.CalendarListEntry, error)

ListCalendars returns all calendars for the authenticated user.

func (*CalendarClient) ListEvents

func (c *CalendarClient) ListEvents(ctx context.Context, calendarID, timeMin, timeMax string, maxResults int64) ([]*calendar.Event, error)

ListEvents returns events within the specified time range.

func (*CalendarClient) UpdateEvent

func (c *CalendarClient) UpdateEvent(ctx context.Context, calendarID, eventID string, event *calendar.Event) (*calendar.Event, error)

UpdateEvent updates an existing calendar event. Requires readwrite mode.

type ContactsClient

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

ContactsClient provides read-only access to the Google People API. No create, update, or delete operations exist in this type.

func NewContactsClient

func NewContactsClient(ctx context.Context, ts oauth2.TokenSource) (*ContactsClient, error)

NewContactsClient creates a People API client using the provided token source.

func (*ContactsClient) GetContact

func (c *ContactsClient) GetContact(ctx context.Context, resourceName string) (*people.Person, error)

GetContact retrieves a single contact by resource name.

func (*ContactsClient) ListContacts

func (c *ContactsClient) ListContacts(ctx context.Context, maxResults int64) ([]*people.Person, error)

ListContacts returns contacts for the authenticated user.

func (*ContactsClient) SearchContacts

func (c *ContactsClient) SearchContacts(ctx context.Context, query string, maxResults int64) ([]*people.Person, error)

SearchContacts searches for contacts matching the query.

type DocsClient added in v0.5.0

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

DocsClient provides access to the Google Docs API with configurable read/write mode.

func NewDocsClient added in v0.5.0

func NewDocsClient(ctx context.Context, ts oauth2.TokenSource, mode config.ServiceMode) (*DocsClient, error)

NewDocsClient creates a Docs API client using the provided token source.

func (*DocsClient) BatchUpdate added in v0.5.0

func (c *DocsClient) BatchUpdate(ctx context.Context, docID string, requests []*docs.Request) (*docs.BatchUpdateDocumentResponse, error)

BatchUpdate performs a raw batch update. Requires readwrite mode.

func (*DocsClient) GetDocument added in v0.5.0

func (c *DocsClient) GetDocument(ctx context.Context, docID string) (*docs.Document, error)

GetDocument retrieves a document by ID.

func (*DocsClient) InsertText added in v0.5.0

func (c *DocsClient) InsertText(ctx context.Context, docID string, text string, index int64) error

InsertText inserts text at the given index. Use index 1 for the start of the document body. If index is 0, the text is appended to the end of the body. Requires readwrite mode.

func (*DocsClient) ReplaceAllText added in v0.5.0

func (c *DocsClient) ReplaceAllText(ctx context.Context, docID, find, replace string) (*docs.BatchUpdateDocumentResponse, error)

ReplaceAllText replaces all occurrences of find with replace in the document. Requires readwrite mode.

type DriveClient added in v0.4.0

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

DriveClient provides access to the Google Drive API with configurable read/write mode. File write operations do not exist in this type; write access is limited to comments.

func NewDriveClient added in v0.4.0

func NewDriveClient(ctx context.Context, ts oauth2.TokenSource, mode config.ServiceMode) (*DriveClient, error)

NewDriveClient creates a Drive API client using the provided token source.

func (*DriveClient) CreateComment added in v0.5.0

func (c *DriveClient) CreateComment(ctx context.Context, fileID, content string) (*drive.Comment, error)

CreateComment adds a comment to a file. Requires readwrite mode.

func (*DriveClient) DownloadFile added in v0.4.0

func (c *DriveClient) DownloadFile(ctx context.Context, fileID string) (io.ReadCloser, error)

DownloadFile retrieves the content of a file. For Google Workspace files (Docs, Sheets, Slides) it exports to a text format automatically. For all other files it downloads the raw bytes. The caller must close the returned ReadCloser.

func (*DriveClient) GetFile added in v0.4.0

func (c *DriveClient) GetFile(ctx context.Context, fileID string) (*drive.File, error)

GetFile retrieves metadata for a single file.

func (*DriveClient) ListComments added in v0.5.0

func (c *DriveClient) ListComments(ctx context.Context, fileID string, maxResults int64) ([]*drive.Comment, error)

ListComments returns comments on a file. Works in both readonly and readwrite modes.

func (*DriveClient) ListFiles added in v0.4.0

func (c *DriveClient) ListFiles(ctx context.Context, query string, pageSize int64) ([]*drive.File, error)

ListFiles returns files visible to the authenticated user.

func (*DriveClient) ReplyToComment added in v0.5.0

func (c *DriveClient) ReplyToComment(ctx context.Context, fileID, commentID, content string) (*drive.Reply, error)

ReplyToComment replies to an existing comment. Requires readwrite mode.

type GmailClient

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

GmailClient provides read-only access to the Gmail API. No send, modify, or delete operations exist in this type.

func NewGmailClient

func NewGmailClient(ctx context.Context, ts oauth2.TokenSource) (*GmailClient, error)

NewGmailClient creates a Gmail API client using the provided token source.

func (*GmailClient) GetMessage

func (c *GmailClient) GetMessage(ctx context.Context, id string, format string) (*gmail.Message, error)

GetMessage retrieves a single message by ID.

func (*GmailClient) GetThread

func (c *GmailClient) GetThread(ctx context.Context, id string) (*gmail.Thread, error)

GetThread retrieves a thread by ID.

func (*GmailClient) ListLabels

func (c *GmailClient) ListLabels(ctx context.Context) ([]*gmail.Label, error)

ListLabels returns all labels for the authenticated user.

func (*GmailClient) SearchMessages

func (c *GmailClient) SearchMessages(ctx context.Context, query string, maxResults int64) ([]*gmail.Message, error)

SearchMessages searches for messages matching the query.

func (*GmailClient) SearchThreads

func (c *GmailClient) SearchThreads(ctx context.Context, query string, maxResults int64) ([]*gmail.Thread, error)

SearchThreads searches for threads matching the query.

type SheetsClient added in v0.5.0

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

SheetsClient provides access to the Google Sheets API with configurable read/write mode.

func NewSheetsClient added in v0.5.0

func NewSheetsClient(ctx context.Context, ts oauth2.TokenSource, mode config.ServiceMode) (*SheetsClient, error)

NewSheetsClient creates a Sheets API client using the provided token source.

func (*SheetsClient) GetSpreadsheet added in v0.5.0

func (c *SheetsClient) GetSpreadsheet(ctx context.Context, spreadsheetID string) (*sheets.Spreadsheet, error)

GetSpreadsheet retrieves spreadsheet metadata including sheet names.

func (*SheetsClient) ReadRange added in v0.5.0

func (c *SheetsClient) ReadRange(ctx context.Context, spreadsheetID, rangeA1 string) (*sheets.ValueRange, error)

ReadRange reads cell values from the specified A1-notation range.

func (*SheetsClient) WriteRange added in v0.5.0

func (c *SheetsClient) WriteRange(ctx context.Context, spreadsheetID, rangeA1 string, values [][]interface{}, raw bool) error

WriteRange writes cell values to the specified A1-notation range. When raw is true, values are stored as-is without formula evaluation. When raw is false, values are interpreted as if typed by a user (formulas are evaluated). Requires readwrite mode.

Jump to

Keyboard shortcuts

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