Documentation ¶
Overview ¶
Package googleworkspace contains logic for working with Google Workspace.
Index ¶
- func GetLinkURLs(b *docs.Body) []string
- func GetTables(b *docs.Body) []*docs.Table
- func VisitAllTableParagraphs(t *docs.Table, fn func(p *docs.Paragraph))
- type Config
- type Service
- func (s *Service) CopyFile(fileID, name, destFolder string) (*drive.File, error)
- func (s *Service) CreateFolder(folderName, destFolder string) (*drive.File, error)
- func (s *Service) CreateShortcut(targetFileID, destFolder string) (*drive.File, error)
- func (s *Service) DeleteFile(fileID string) error
- func (s *Service) DeletePermission(fileID, permissionID string) error
- func (s *Service) GetDoc(id string) (*docs.Document, error)
- func (s *Service) GetDocs(folderID string) ([]*drive.File, error)
- func (s *Service) GetFile(fileID string) (*drive.File, error)
- func (s *Service) GetFiles(folderID, mimeType string) ([]*drive.File, error)
- func (s *Service) GetFolders(folderID string) ([]*drive.File, error)
- func (s *Service) GetFoldersRecursive(folderID string) ([]*drive.File, error)
- func (s *Service) GetLatestRevision(fileID string) (*drive.Revision, error)
- func (s *Service) GetSubfolder(folderID, subfolderName string) (*drive.File, error)
- func (s *Service) GetUpdatedDocs(folderID, timestamp string) ([]*drive.File, error)
- func (s *Service) GetUpdatedDocsBetween(folderID, afterTime, beforeTime string) ([]*drive.File, error)
- func (s *Service) GetUpdatedFiles(folderID, mimeType, timestamp string) ([]*drive.File, error)
- func (s *Service) GetUser(userKey string) (*admin.User, error)
- func (s *Service) KeepRevisionForever(fileID, revisionID string) (*drive.Revision, error)
- func (s *Service) ListFiles(folderID, query string) ([]*drive.File, error)
- func (s *Service) ListPermissions(fileID string) ([]*drive.Permission, error)
- func (s *Service) ListRevisions(fileID string) ([]*drive.Revision, error)
- func (s *Service) MoveFile(fileID, destFolder string) (*drive.File, error)
- func (s *Service) RenameFile(fileID, newName string) error
- func (s *Service) ReplaceText(id string, r map[string]string) error
- func (s *Service) SearchPeople(query, readMask string) ([]*people.Person, error)
- func (s *Service) SendEmail(to []string, from, subject, body string) (*gmail.Message, error)
- func (s *Service) ShareFile(fileID, email, role string) error
- func (s *Service) ValidateAccessToken(accessToken string) (*oauth2.Tokeninfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLinkURLs ¶
func GetLinkURLs(b *docs.Body) []string
GetLinkURLs returns all link URLs in a Google Doc Body.
func GetTables ¶
func GetTables(b *docs.Body) []*docs.Table
GetTables returns all tables in a Google Doc Body.
func VisitAllTableParagraphs ¶
func VisitAllTableParagraphs(t *docs.Table, fn func(p *docs.Paragraph))
VisitAllTableParagraphs visits all paragraphs in a Google Doc table, calling fn for each.
Types ¶
type Config ¶
type Config struct { ClientEmail string `hcl:"client_email,optional"` PrivateKey string `hcl:"private_key,optional"` Subject string `hcl:"subject,optional"` TokenURL string `hcl:"token_url,optional"` }
Config is the configuration for interacting with Google Workspace using a service account.
type Service ¶
type Service struct { Admin *admin.Service Docs *docs.Service Drive *drive.Service Gmail *gmail.Service OAuth2 *oauth2api.Service People *people.PeopleService }
Service provides access to the Google Workspace API.
func New ¶
func New() *Service
New reads Google API credentials and returns a service with the required access for Hermes.
func NewFromConfig ¶
New returns a service with the required Google Workspace access for Hermes.
func (*Service) CreateFolder ¶
CreateFolder creates a Google Drive folder.
func (*Service) CreateShortcut ¶
CreateShortcut creates a Google Drive shortcut.
func (*Service) DeleteFile ¶
DeleteFile deletes a Google Drive file
func (*Service) DeletePermission ¶
DeletePermission deletes a permission for a Google Drive file.
func (*Service) GetFolders ¶
GetDocs returns all folders in a Google Drive folder.
func (*Service) GetFoldersRecursive ¶
GetDocs returns all folders and recursively all subfolders in a Google Drive folder.
func (*Service) GetLatestRevision ¶
GetLatestRevision returns the latest revision for a Google Drive file.
func (*Service) GetSubfolder ¶
GetSubfolder returns the subfolder file if the specified folder contains a subfolder with the specified name, and nil if not found.
func (*Service) GetUpdatedDocs ¶
GetUpdatedDocs returns all docs in a Google Drive folder that have been modified after a provided timestamp.
func (*Service) GetUpdatedDocsBetween ¶
func (s *Service) GetUpdatedDocsBetween( folderID, afterTime, beforeTime string) ([]*drive.File, error)
GetUpdatedDocsBetween returns all docs in a Google Drive folder that have been modified after a provided timestamp string (in RFC 3339 date-time) "afterTime" and before (or equal to) the timestamp string "beforeTime".
func (*Service) GetUpdatedFiles ¶
GetUpdatedFiles returns all files in a Google Drive folder that have been modified after a provided timestamp.
func (*Service) KeepRevisionForever ¶
KeepRevisionForever keeps a Google Drive file revision forever.
func (*Service) ListFiles ¶
ListFiles lists files in a Google Drive folder using the provided query.
func (*Service) ListPermissions ¶
ListPermissions lists permissions for a Google Drive file.
func (*Service) ListRevisions ¶
ListRevisions lists revisions for a Google Drive file.
func (*Service) RenameFile ¶
RenameFile renames a Google Drive file.
func (*Service) ReplaceText ¶
ReplaceText replaces text in a Google Doc. Provide a map of replacement tags (denoted as "{{tag}}" in the doc) to replacement text as the second parameter.
func (*Service) SearchPeople ¶
SearchPeople searches the Google People API.
func (*Service) ValidateAccessToken ¶
ValidateAccessToken validates a Google access token and returns the token info.