SharePoint sites: the tenant root site, a site by URL or by hostname + server-relative path, search, subsites, every site (app-only), and a site's document libraries (drives).
Permissions. Sites.Read.All (delegated or application), or
Sites.Selected with a grant on the site (app-only reads of a
granted site by id work; search and get-all-sites do not see sites
the app has no grant on).
Functions
drive-opts
fn (drive: Any): Map
fn (drive: Any, opts: Map): Map
Opts that point microsoft-onedrive at a library: {drive: id} from a drive Map or id, merged into opts (pure).
**Example**
```hot
site-id "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE"
lib ::microsoft::sharepoint::sites/find-drive(site-id, "Contracts")
::microsoft::onedrive::items/list-all-children("root", ::microsoft::sharepoint::sites/drive-opts(lib))
```
find-drive
fn (site-id: Str, name: Str): Map
fn (site-id: Str, name: Str, opts: Map): Map
The site library whose name matches (case-insensitive), or an Err
listing the names there are. Library names are display names, e.g.
"Documents", "Contracts".
Example
site-id "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE"
lib ::microsoft::sharepoint::sites/find-drive(site-id, "Contracts")
if(is-err(lib), "no such library", lib.id)
get-all-sites
fn (): Vec
fn (opts: Map): Vec
fn (opts: Map, limit: Int?): Vec
GET /sites/getAllSites - every site in the tenant (app-only with
Sites.Read.All), all pages or at most limit. Includes OneDrive
personal sites unless filtered.
Example
// App-only: at most 500 sites, with two fields each
sites ::microsoft::sharepoint::sites/get-all-sites({select: "id,webUrl"}, 500)
map(sites, %.webUrl)
get-default-drive
fn (site-id: Str): Map
fn (site-id: Str, opts: Map): Map
GET /sites/{site-id}/drive - the site's default document library ("Documents" / "Shared Documents").
Example
site-id "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE"
lib ::microsoft::sharepoint::sites/get-default-drive(site-id)
lib.id
get-root-site
fn (): Map
fn (opts: Map): Map
GET /sites/root - the tenant's root site
(https://{tenant}.sharepoint.com).
Example
root ::microsoft::sharepoint::sites/get-root-site()
root.webUrl
// Only the fields you need
::microsoft::sharepoint::sites/get-root-site({select: "id,displayName"})
get-site
fn (site-id: Str): Map
fn (site-id: Str, opts: Map): Map
GET /sites/{site-id}. opts takes select, expand (e.g. "drive",
"lists").
Example
site-id "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE"
site ::microsoft::sharepoint::sites/get-site(site-id)
site.displayName
// With its default library
with-drive ::microsoft::sharepoint::sites/get-site(site-id, {expand: "drive"})
with-drive.drive.id
get-site-by-path
fn (hostname: Str, path: Str): Map
fn (hostname: Str, path: Str, opts: Map): Map
GET /sites/{hostname}:/{server-relative-path} - a site by host and path.
Example
site ::microsoft::sharepoint::sites/get-site-by-path("contoso.sharepoint.com", "/sites/engineering")
site.id // "contoso.sharepoint.com,2C712604-...,2D2244C3-..."
get-site-by-url
fn (url: Str): Map
fn (url: Str, opts: Map): Map
GET a site from its browser URL (https://contoso.sharepoint.com/sites/eng,
or a library or page URL inside it). See parse-site-url.
Example
site ::microsoft::sharepoint::sites/get-site-by-url("https://contoso.sharepoint.com/sites/engineering")
list-drives
fn (site-id: Str): Vec
fn (site-id: Str, opts: Map): Vec
GET /sites/{site-id}/drives - the site's document libraries, each a
drive (id, name, webUrl, driveType: "documentLibrary"). Pass
a library's id as opts.drive to microsoft-onedrive.
Example
site-id "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE"
libraries ::microsoft::sharepoint::sites/list-drives(site-id)
map(libraries, %.name)
list-subsites
fn (site-id: Str): Vec
fn (site-id: Str, opts: Map): Vec
GET /sites/{site-id}/sites - a site's direct subsites, all pages.
Example
site-id "contoso.sharepoint.com,2C712604-1370-44E7-A1F5-426573FDA80A,2D2244C3-251A-49EA-93A8-39E1C3A060FE"
subsites ::microsoft::sharepoint::sites/list-subsites(site-id)
map(subsites, %.displayName)
parse-site-url
fn (url: Str): Map
Split a site URL into {hostname, path} (pure), dropping any query
or fragment, and a library/page suffix after the site
(/Shared Documents/..., /Lists/..., /SitePages/...,
/_layouts/...). Returns an Err for a non-https URL.
Example
::microsoft::sharepoint::sites/parse-site-url("https://contoso.sharepoint.com/sites/eng/Shared%20Documents/Forms/AllItems.aspx")
// {hostname: "contoso.sharepoint.com", path: "/sites/eng"}
search-path
fn (query: Str): Str
The site search path (pure): /sites?search={encoded query} (Graph's
search parameter, not OData $search).
Example
::microsoft::sharepoint::sites/search-path("engineering docs")
// "/sites?search=engineering%20docs"
search-sites
fn (query: Str): Vec
fn (query: Str, opts: Map): Vec
fn (query: Str, opts: Map, limit: Int?): Vec
GET /sites?search={query} - sites whose name or description matches,
all pages or at most limit. "*" lists every site the caller can
see.
Example
hits ::microsoft::sharepoint::sites/search-sites("engineering", {}, 20)
map(hits, (s) { s.webUrl })
site-by-path-path
fn (hostname: Str, path: Str?): Str
The Graph path for a site by host and server-relative path (pure):
/sites/{hostname}:/{path} (each segment encoded), or
/sites/{hostname} for the host's root site.
Example
::microsoft::sharepoint::sites/site-by-path-path("Contoso.SharePoint.com", "/sites/eng")
// "/sites/contoso.sharepoint.com:/sites/eng"
::microsoft::sharepoint::sites/site-by-path-path("contoso.sharepoint.com", "/")
// "/sites/contoso.sharepoint.com"