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.

Example

grant ::microsoft::onedrive::sharing/build-app-grant("11111111-2222-3333-4444-555555555555", "Hot Worker", ["read"])
grant.roles  // ["read"]
grant.grantedToV2.application.displayName  // "Hot Worker"

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.

Example

body ::microsoft::onedrive::sharing/build-invite(["alex@contoso.com"], [], {message: "Q3 numbers"})
body.roles  // ["read"]
body.sendInvitation  // false
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.

Example

::microsoft::onedrive::sharing/build-link("view", {scope: "organization"})  // {type: "view", scope: "organization"}
::microsoft::onedrive::sharing/build-link("edit", {scope: "users", recipients: ["alex@contoso.com"]}).recipients  // [{email: "alex@contoso.com"}]
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.

Example

::microsoft::onedrive::sharing/delete-permission("/Reports/Q3.pdf", "aTowIy5mfG1lbWJlcnNoaXA")

get-permission

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

GET {item}/permissions/{id}.

Example

perm ::microsoft::onedrive::sharing/get-permission("/Reports/Q3.pdf", "aTowIy5mfG1lbWJlcnNoaXA")
perm.roles

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.

Example

perm ::microsoft::onedrive::sharing/grant-app("/Reports", "11111111-2222-3333-4444-555555555555", "Hot Worker", ["read"])

// Revoke it later
::microsoft::onedrive::sharing/delete-permission("/Reports", perm.id)

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"})

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.

Example

perms ::microsoft::onedrive::sharing/list-permissions("/Reports/Q3.pdf")
map(perms, %.roles)

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.

Example

perm ::microsoft::onedrive::sharing/update-permission("/Reports/Q3.pdf", "aTowIy5mfG1lbWJlcnNoaXA", ["write"])
perm.roles