Learn R Programming

Microsoft365R (version 1.0.0)

get_sharepoint_site: Get SharePoint site or OneDrive

Description

Methods for the AzureGraph::ms_graph, AzureGraph::az_user and AzureGraph::az_group classes.

Value

For get_sharepoint_site, an object of class ms_site. For get_drive, an object of class ms_drive. For list_drives, a list of ms_drive objects.

Usage

## R6 method for class 'ms_graph'
get_drive(drive_id)

## R6 method for class 'az_user' get_drive(drive_id = NULL)

## R6 method for class 'az_group' get_drive(drive_id = NULL)

## R6 method for class 'ms_graph' get_sharepoint_site(site_url = NULL, site_id = NULL)

## R6 method for class 'az_group' get_sharepoint_site()

## R6 method for class 'az_user' list_drives()

## R6 method for class 'az_group' list_drives()

Arguments

  • drive_id: For get_drive, the ID of the drive or shared document library. For the az_user and az_group methods, if this is NULL the default drive/document library is returned.

  • site_url,site_id: For ms_graph$get_sharepoint_site(), the URL and ID of the site. Provide one or the other, but not both.

Details

get_sharepoint_site retrieves a SharePoint site object. The method for the top-level Graph client object requires that you provide either the site URL or ID. The method for an az_group object will retrieve the site associated with that group, if applicable.

get_drive retrieves a OneDrive or shared document library, and list_drives retrieves all such drives/libraries that the user or group has access to. Whether these are personal or business drives depends on the tenant that was specified in AzureGraph::get_graph_login()/create_graph_login(): if this was "consumers" or "9188040d-6c67-4c5b-b112-36a304b66dad" (the equivalent GUID), it will be the personal OneDrive. See the examples below.

Note that OneDrive for Business and SharePoint require a Microsoft 365 Business license, and are available for organisational tenants only.

See Also

ms_site, ms_drive, az_user, az_group

Examples

Run this code
# NOT RUN {
# 'consumers' tenant -> personal OneDrive for a user
gr <- AzureGraph::get_graph_login("consumers", app="myapp")
me <- gr$get_user()
me$get_drive()

# organisational tenant -> business OneDrive for a user
gr2 <- AzureGraph::get_graph_login("mycompany", app="myapp")
myuser <- gr2$get_user("username@mycompany.onmicrosoft.com")
myuser$get_drive()

# get a site/drive directly from a URL/ID
gr2$get_sharepoint_site("https://mycompany.sharepoint.com/sites/my-site-name")
gr2$get_drive("drive-id")

# site/drive(s) for a group
grp <- gr2$get_group("group-id")
grp$get_sharepoint_site()
grp$list_drives()
grp$get_drive()

# }

Run the code above in your browser using DataLab