Documentation
¶
Overview ¶
Package gmailapi is the Gmail REST API v1 protocol backend (ADR 0037): a backend.Receiver and backend.Sender over https://gmail.googleapis.com.
Index ¶
- Constants
- Variables
- type Config
- type Receiver
- func (r *Receiver) Apply(ctx context.Context, op backend.Op) (backend.Result, error)
- func (r *Receiver) Check(ctx context.Context) (backend.CheckResult, error)
- func (r *Receiver) Close() error
- func (r *Receiver) Describe(ctx context.Context) (backend.Description, error)
- func (r *Receiver) Fetch(ctx context.Context, req backend.ContentRequest) (io.ReadCloser, error)
- func (r *Receiver) Find(ctx context.Context, folder backend.FolderRef, messageID string, size int64) ([]backend.MessageRef, error)
- func (r *Receiver) Headers(ctx context.Context, folder backend.FolderRef, refs []backend.MessageRef, ...) (map[backend.MessageRef][]byte, error)
- func (r *Receiver) Sync(ctx context.Context, req backend.SyncRequest, commit func(backend.Page) error) (bool, error)
- func (r *Receiver) Watch(context.Context, func([]backend.FolderRef)) error
- type Sender
Constants ¶
const ( ReasonAPIDisabled = "gmailapi.api_disabled" ReasonNoCopy = "gmailapi.no_copy" ReasonNoAnswered = "gmailapi.no_answered" ReasonNoDraft = "gmailapi.no_draft" ReasonNoKeywords = "gmailapi.no_keywords" ReasonNoPush = "gmailapi.no_push" ReasonFoldersPending = "gmailapi.folders_pending" ReasonSystemLabelsFixed = "gmailapi.system_labels_fixed" )
Reason keys, translated by the UI and Wit.
const AllMailRef backend.FolderRef = "[Gmail]/All Mail"
AllMailRef is the synthetic All Mail folder: Gmail's labels.list has no All Mail entry, while messages.list (without spam/trash) is All Mail. Keeping it as RoleAll aligns archiving, sidebar 归档 and multi-location behavior with Gmail IMAP (backend/imapbackend).
const DefaultBaseURL = "https://gmail.googleapis.com"
DefaultBaseURL is Google's Gmail REST API host.
Variables ¶
var ErrAPIDisabled = errors.New(ReasonAPIDisabled)
ErrAPIDisabled means the OAuth client's Google Cloud project has not enabled gmail.googleapis.com (HTTP 403 accessNotConfigured). Its message is ReasonAPIDisabled.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// BaseURL is the API origin, "" for DefaultBaseURL; tests point it at httptest.
BaseURL string
Credentials backend.CredentialsFunc
// Wait waits d out, or until ctx is done, when the server asks to back off.
// Nil waits in real time; tests pass a fake.
Wait func(ctx context.Context, d time.Duration) error
}
Config is how to reach a Gmail account over the REST API.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver is a Gmail account's receiving backend over the Gmail REST API v1.
func (*Receiver) Describe ¶
Describe implements backend.Receiver. Its first call signs in so refused credentials return ErrAuthFailed and a disabled API returns ErrAPIDisabled.
func (*Receiver) Fetch ¶
func (r *Receiver) Fetch(ctx context.Context, req backend.ContentRequest) (io.ReadCloser, error)
Fetch implements backend.Receiver.
func (*Receiver) Find ¶
func (r *Receiver) Find(ctx context.Context, folder backend.FolderRef, messageID string, size int64) ([]backend.MessageRef, error)
Find implements backend.Receiver.
func (*Receiver) Headers ¶
func (r *Receiver) Headers(ctx context.Context, folder backend.FolderRef, refs []backend.MessageRef, fields []string) (map[backend.MessageRef][]byte, error)
Headers implements backend.Receiver.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender submits mail through Gmail REST API users.messages.send. Gmail automatically stores the sent copy with the SENT label (SavesSent == true).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gmailapitest is an in-process fake Gmail REST API v1 server for backend contract tests and coretest end-to-end tests, with zero external network dependency.
|
Package gmailapitest is an in-process fake Gmail REST API v1 server for backend contract tests and coretest end-to-end tests, with zero external network dependency. |