Labels: list, get, create, update, delete, find by name, and
ensure-label. System labels (INBOX, UNREAD, STARRED,
IMPORTANT, SPAM, TRASH, SENT, DRAFT, CATEGORY_*) have ids
equal to their names; user labels have generated ids (Label_12).
Nested labels use / in the name ("Clients/Acme").
Scopes. Reads use gmail.readonly; create, update and delete
gmail.labels (gmail.modify also works).
Values
LABEL_FIELDS
LABEL_FIELDS: Vec [
"labelListVisibility",
"messageListVisibility",
"color"
]
Functions
build-label
fn (name: Str, opts: Map): Map
The label body for create-label (pure): {name} plus any of labelListVisibility (labelShow, labelShowIfUnread, labelHide), messageListVisibility (show, hide) and color ({textColor, backgroundColor} from Gmail's palette) found in opts.
create-label
fn (name: Str): Map
fn (name: Str, opts: Map): Map
POST /users/me/labels - create a user label. Options: see build-label. Gmail rejects a duplicate name with 409; use ensure-label to reuse an existing one. Scope: gmail.labels.
delete-label
fn (id: Str): Bool
fn (id: Str, opts: Map): Bool
DELETE /users/me/labels/{id} - delete a user label (it is removed from every message; the messages stay). Returns true. Scope: gmail.labels.
ensure-label
fn (name: Str): Map
fn (name: Str, opts: Map): Map
The label named name, created when missing. Scopes: gmail.readonly and gmail.labels.
find-label
fn (name: Str): Map?
fn (name: Str, opts: Map): Map?
The label whose name equals name (case-insensitive), or null. Scope: gmail.readonly.
get-label
fn (id: Str): Map
fn (id: Str, opts: Map): Map
GET /users/me/labels/{id} - one label with its message and thread counts. Scope: gmail.readonly.
list-labels
fn (): Map
fn (opts: Map): Map
GET /users/me/labels - every label in the mailbox: {labels: [{id, name, type, ...}]} (not paginated). Scope: gmail.readonly.
update-label
fn (id: Str, changes: Map): Map
fn (id: Str, changes: Map, opts: Map): Map
PATCH /users/me/labels/{id} - change the given fields of a user label (name, labelListVisibility, messageListVisibility, color). Scope: gmail.labels.