Sharing: links (createLink), invitations (invite), item permissions (list, get, update, delete), and app grants for Files.SelectedOperations.Selected.

Permissions. Files.ReadWrite / Files.ReadWrite.All or Sites.ReadWrite.All to share; Sites.FullControl.All (or a fullcontrol / owner selected grant) to grant apps.

Values

APP_ROLES

APP_ROLES: Vec [
  "read",
  "write",
  "owner",
  "fullcontrol"
]

INVITE_ROLES

INVITE_ROLES: Vec [
  "read",
  "write",
  "owner"
]
LINK_SCOPES: Vec [
  "anonymous",
  "organization",
  "users"
]
LINK_TYPES: Vec [
  "view",
  "edit",
  "embed"
]

Functions

build-app-grant

fn (app-id: Str, display-name: Str?, roles: Vec): Map

The body granting an app a role on a resource (pure): {roles, grantedToV2: {application: {id, displayName}}}. Roles are read, write, owner, fullcontrol.

build-invite

fn (recipients: Vec, roles: Vec, opts: Map): Map

The invite body (pure): recipients (emails or {email} / {objectId} Maps), roles (read, write; default ["read"]), and from opts message, require-sign-in (default true), send-invitation (default false: grant silently), expiration.

fn (link-type: Str, opts: Map): Map

The createLink body (pure): type (view, edit, embed), and from opts scope (anonymous, organization, users), expiration (RFC 3339), password (personal OneDrive only), retain-inherited (retainInheritedPermissions), recipients (emails, for users links). An Err for an unknown type or scope.

fn (item: Any, link-type: Str): Map
fn (item: Any, link-type: Str, opts: Map): Map

POST {item}/createLink - create (or return the existing) sharing link. Returns the permission; the URL is link.webUrl. Anonymous links may be disabled by the tenant admin.

perm ::microsoft::onedrive::sharing/create-link("/Reports/Q3.pdf", "view", {scope: "organization"})
perm.link.webUrl

delete-permission

fn (item: Any, permission-id: Str): Bool
fn (item: Any, permission-id: Str, opts: Map): Bool

DELETE {item}/permissions/{id} - remove a link or a person's access (inherited permissions cannot be removed here). Returns true.

get-permission

fn (item: Any, permission-id: Str): Map
fn (item: Any, permission-id: Str, opts: Map): Map

GET {item}/permissions/{id}.

grant-app

fn (item: Any, app-id: Str, display-name: Str?, roles: Vec): Map
fn (item: Any, app-id: Str, display-name: Str?, roles: Vec, opts: Map): Map

POST {item}/permissions - grant an app (by client id) a role on one file or folder, for apps consented Files.SelectedOperations.Selected (or ListItems.SelectedOperations.Selected). An admin step: the caller needs Sites.FullControl.All or an owner/fullcontrol grant. Breaks permission inheritance on the item. Returns the permission; delete it with delete-permission to revoke.

invite

fn (item: Any, recipients: Vec, roles: Vec): Vec
fn (item: Any, recipients: Vec, roles: Vec, opts: Map): Vec

POST {item}/invite - share an item with people. Returns the created permissions (value). No email is sent unless send-invitation: true.

::microsoft::onedrive::sharing/invite("/Reports/Q3.pdf", ["alex@contoso.com"], ["read"], {send-invitation: true, message: "Q3 numbers"})

json

fn (method: Str, path: Str, body: Any, opts: Map): Any

list-permissions

fn (item: Any): Vec
fn (item: Any, opts: Map): Vec

GET {item}/permissions - the item's permissions (links, people, inherited). Returns a Vec.

update-permission

fn (item: Any, permission-id: Str, roles: Vec): Map
fn (item: Any, permission-id: Str, roles: Vec, opts: Map): Map

PATCH {item}/permissions/{id} - change roles (e.g. ["write"]). Returns the permission.