Calendar sharing (access control rules): list, share with a user, group, domain or everyone, and remove a rule.

Roles: freeBusyReader (free/busy only), reader, writer, owner (none removes access). Scope types: user, group (email), domain (a domain name), default (public).

Scopes. Listing uses calendar.acls.readonly; sharing and removing calendar.acls (calendar also works).

Values

ROLES

ROLES: Vec [
  "none",
  "freeBusyReader",
  "reader",
  "writer",
  "owner"
]

SCOPE_TYPES

SCOPE_TYPES: Vec [
  "default",
  "user",
  "group",
  "domain"
]

Functions

build-rule

fn (role: Str, scope-type: Str, value: Str?): Map

An AclRule body (pure): {role, scope: {type, value?}}; value is omitted for default. An Err for an unknown role or scope type, or a missing value.

Example

::google::calendar::acl/build-rule("reader", "user", "ada@example.com")  // {role: "reader", scope: {type: "user", value: "ada@example.com"}}
::google::calendar::acl/build-rule("reader", "default", null)  // {role: "reader", scope: {type: "default"}}

delete-rule

fn (calendar-id: Str, rule-id: Str): Bool
fn (calendar-id: Str, rule-id: Str, opts: Map): Bool

DELETE /calendars/{id}/acl/{ruleId} - remove a rule (rule ids look like user:ada@example.com). Returns true. Scope: calendar.acls.

Example

::google::calendar::acl/delete-rule("team@group.calendar.google.com", "user:ada@example.com")

insert-rule

fn (calendar-id: Str, role: Str, scope-type: Str, value: Str?): Map
fn (calendar-id: Str, role: Str, scope-type: Str, value: Str?, opts: Map): Map

POST /calendars/{id}/acl - add a rule (see build-rule). Options: sendNotifications (default true: the grantee is emailed). Returns the rule with its id. Scope: calendar.acls.

Example

// Everyone at example.com sees free/busy. Nobody is emailed.
rule ::google::calendar::acl/insert-rule("team@group.calendar.google.com", "freeBusyReader", "domain", "example.com", {sendNotifications: false})
rule.id

list-acl

fn (calendar-id: Str): Map
fn (calendar-id: Str, opts: Map): Map

GET /calendars/{id}/acl - one page of rules: {items: [{id, role, scope: {type, value}}], nextPageToken?, nextSyncToken?}. Options: maxResults, pageToken, showDeleted, syncToken. Scope: calendar.acls.readonly.

Example

page ::google::calendar::acl/list-acl("team@group.calendar.google.com", {maxResults: 50})
map(page.items, %.id)
page.nextPageToken

list-all-acl

fn (calendar-id: Str): Vec
fn (calendar-id: Str, opts: Map): Vec

Every rule on a calendar (all pages). Scope: calendar.acls.readonly.

Example

rules ::google::calendar::acl/list-all-acl("team@group.calendar.google.com")
filter(rules, eq(%.role, "owner"))

share-calendar

fn (calendar-id: Str, email: Str, role: Str): Map
fn (calendar-id: Str, email: Str, role: Str, opts: Map): Map

Share a calendar with one person: share-calendar("team@group.calendar.google.com", "ada@example.com", "reader"). Scope: calendar.acls.

Example

rule ::google::calendar::acl/share-calendar("team@group.calendar.google.com", "ada@example.com", "reader")
rule.id

// Share without the notification email
::google::calendar::acl/share-calendar("team@group.calendar.google.com", "bob@example.com", "writer", {sendNotifications: false})