| Title: | 'Microsoft SharePoint' Interface for the 'connector' Package |
| Version: | 0.1.0 |
| Description: | Extends the 'connector' package to provide a convenient interface for accessing and interacting with 'Microsoft SharePoint' directly from 'R'. Supports listing, reading, writing, uploading, downloading, and removing files and directories on 'SharePoint' document libraries. Authentication is handled through 'Azure' tokens via the 'AzureAuth' package. |
| License: | Apache License (≥ 2) |
| URL: | https://novonordisk-opensource.github.io/connector.sharepoint/, https://github.com/novonordisk-opensource/connector.sharepoint |
| BugReports: | https://github.com/NovoNordisk-OpenSource/connector.sharepoint/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | AzureAuth, checkmate, cli, connector (≥ 1.0.0), Microsoft365R, R6, tools, zephyr, rlang |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0), tibble, withr, whirl (≥ 0.2.0), glue, mockery |
| VignetteBuilder: | knitr, rmarkdown |
| Config/Needs/website: | rmarkdown |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-28 10:07:34 UTC; vlob |
| Author: | Vladimir Obucina |
| Maintainer: | Vladimir Obucina <vlob@novonordisk.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-01 08:50:06 UTC |
Connector Object for Sharepoint class, built on top of connector::Connector class
Description
This object is used to interact with Sharepoint, adding the ability to list, read, write, download, upload, create directories and remove files.
Details
About the token, you can retrieve it by following the guideline in your enterprise.
Super classes
connector::Connector -> connector::ConnectorFS -> ConnectorSharepoint
Active bindings
Methods
Public methods
Inherited methods
connector::Connector$list_content_cnt()connector::Connector$print()connector::Connector$read_cnt()connector::Connector$remove_cnt()connector::Connector$write_cnt()connector::ConnectorFS$create_directory_cnt()connector::ConnectorFS$download_cnt()connector::ConnectorFS$download_directory_cnt()connector::ConnectorFS$remove_directory_cnt()connector::ConnectorFS$tbl_cnt()connector::ConnectorFS$upload_cnt()connector::ConnectorFS$upload_directory_cnt()
Method new()
Initializes the ConnectorSharepoint class
Usage
ConnectorSharepoint$new( site_url, token = get_token(), folder = "", extra_class = NULL, ... )
Arguments
site_urlcharacter The URL of the Sharepoint site
tokencharacter The Azure token. By default, it will be retrieve by get_token
foldercharacter The path of the folder to interact with, if you don't want to interact with the root folder "Documents"
extra_classcharacter Extra class added to the object.
...Additional parameters to pass to the
get_sharepoint_sitefunction
Returns
A ConnectorSharepoint object
Method get_conn()
Get the connection
Usage
ConnectorSharepoint$get_conn()
Returns
The connection
Examples
## Not run:
# Connect to Sharepoint
cs <- ConnectorSharepoint$new(
site_url = Sys.getenv("SHAREPOINT_SITE_URL")
)
cs
# List content
cs$list_content_cnt()
# Write to the connector
cs$write_cnt(iris, "iris.rds")
# Check it is there
cs$list_content_cnt()
# Read the result back
cs$read_cnt("iris.rds") |>
head()
# Remove a file or directory
cs$remove_cnt("iris.rds")
# Check it is there
cs$list_content_cnt()
## End(Not run)
Options for connector.sharepoint
Description
Configuration options for the connector.sharepoint
overwrite
Overwrite existing content if it exists in the connector?
Default:
FALSEOption:
connector.sharepoint.overwriteEnvironment:
R_CONNECTOR.SHAREPOINT_OVERWRITE
verbosity_level
Verbosity level for functions in connector. See zephyr::verbosity_level for details.
Default:
"verbose"Option:
connector.sharepoint.verbosity_levelEnvironment:
R_CONNECTOR.SHAREPOINT_VERBOSITY_LEVEL
Internal parameters for reuse in functions
Description
Internal parameters for reuse in functions
Arguments
overwrite |
Overwrite existing content if it exists in the connector?. Default: |
verbosity_level |
Verbosity level for functions in connector. See
zephyr::verbosity_level for details.. Default: |
Details
See connector-options-sharepoint for more information.
Create sharepoint connector object
Description
Create a new sharepoint connector object. See ConnectorSharepoint for details.
Usage
connector_sharepoint(
site_url,
token = get_token(),
folder = "",
extra_class = NULL,
...
)
Arguments
site_url |
character The URL of the Sharepoint site |
token |
AzureAuth::AzureToken The Azure token. By default, it will be retrieved by get_token |
folder |
character The path of the folder to interact with, if you don't want to interact with the root folder. |
extra_class |
character Extra class added to the object. |
... |
Additional parameters to pass to the ConnectorSharepoint object |
Details
The extra_class parameter allows you to create a subclass of the
ConnectorSharepoint object. This can be useful if you want to create a
custom connection object for easier dispatch of new s3 methods,
while still inheriting the methods from the ConnectorSharepoint object.
Authentication is handled through Azure tokens. See get_token() for details
on token acquisition and management.
Value
A new ConnectorSharepoint object
Examples
## Not run:
# Connect
cs <- connector_sharepoint(Sys.getenv("SHAREPOINT_SITE_URL"))
cs
# Create subclass connection
cs_subclass <- connector_sharepoint(Sys.getenv("SHAREPOINT_SITE_URL"),
extra_class = "subclass"
)
cs_subclass
class(cs_subclass)
## End(Not run)
Create a directory
Description
Addition list content methods for sharepoint connectors implemented for
connector::create_directory_cnt():
-
ConnectorSharepoint: Reuses the
connector::create_directory_cnt()method forConnectorSharepoint()
Usage
create_directory_cnt(connector_object, name, open = TRUE, ...)
## S3 method for class 'ConnectorSharepoint'
create_directory_cnt(connector_object, name, open = TRUE, ...)
Arguments
connector_object |
Connector The connector object to use. |
name |
character The name of the directory to create |
open |
create a new connector object |
... |
ConnectorSharepoint: Additional parameters to pass to
|
Value
ConnectorSharepoint object or ConnectorSharepoint object of a newly built directory
Disconnect (close) the connection of the connector
Description
Generic implementing of how to disconnect from the relevant connections. Mostly relevant for DBI connectors.
-
ConnectorDBI: Uses
DBI::dbDisconnect()to create a table reference to close a DBI connection.
Usage
disconnect_cnt(connector_object, ...)
Arguments
connector_object |
Connector The connector object to use. |
... |
Additional arguments passed to the method for the individual connector. |
Value
invisible connector_object.
Download content from the connector
Description
Addition list content methods for sharepoint connectors implemented for
connector::download_cnt():
-
ConnectorSharepoint: Reuses the
connector::download_cnt()method forConnectorSharepoint()
Usage
download_cnt(connector_object, src, dest = basename(src), ...)
## S3 method for class 'ConnectorSharepoint'
download_cnt(connector_object, src, dest = basename(src), ...)
Arguments
connector_object |
Connector The connector object to use. |
src |
The name of the file to download from SharePoint |
dest |
The local path to save the downloaded file |
... |
ConnectorSharepoint: Additional parameters to pass to the
|
Value
ConnectorSharepoint object
Download a directory
Description
Addition list content methods for sharepoint connectors implemented for
connector::download_directory_cnt():
Usage
download_directory_cnt(connector_object, src, dest = basename(src), ...)
## S3 method for class 'ConnectorSharepoint'
download_directory_cnt(
connector_object,
src,
dest = basename(src),
...,
recursive = TRUE
)
Arguments
connector_object |
Connector The connector object to use. |
src |
The name of the directory to download from SharePoint |
dest |
The local directory path to save the downloaded content |
... |
additional parameters passed on to |
recursive |
If |
Value
ConnectorSharepoint object
Get the default hash
Description
Two solutions are possible:
The user has set the environment variable SHAREPOINT_AZURE_HASH
The user has set the file .active_hash in the AzureR directory
Usage
get_default_hash()
Value
A character string with the token hash, or NULL if not found
Examples
## Not run:
hash <- get_default_hash()
## End(Not run)
Retrieve a token from the AzureAuth package
Description
Retrieve a token from the AzureAuth package
Usage
get_token(hash = get_default_hash())
Arguments
hash |
The hash of the token to use. By default, use this function to retrieve it get_default_hash. If not found, use the first token found. |
Value
An AzureAuth::AzureToken object
Examples
## Not run:
token <- get_token()
## End(Not run)
List available content from the connector
Description
Addition list content methods for sharepoint connectors implemented for
connector::list_content_cnt():
-
ConnectorSharepoint: Reuses the
connector::list_content_cnt()method forConnectorSharepoint()
Usage
list_content_cnt(connector_object, ...)
## S3 method for class 'ConnectorSharepoint'
list_content_cnt(connector_object, ...)
Arguments
connector_object |
Connector The connector object to use. |
... |
ConnectorSharepoint: Additional parameters to pass to the
|
Value
A character vector of content names
Connector Logging Functions
Description
-
ConnectorSharepoint: Implementation of the
log_read_connectorfunction for the ConnectorSharepoint class.
Addition log read methods for sharepoint connectors implemented for
connector::log_read_connector():
Usage
## S3 method for class 'ConnectorSharepoint'
log_read_connector(connector_object, name, ...)
log_read_connector(connector_object, name, ...)
Arguments
connector_object |
The connector object to log operations for. Can be any connector class (ConnectorFS, ConnectorDBI, ConnectorLogger, etc.) |
name |
Character string specifying the name or identifier of the resource being operated on (e.g., file name, table name) |
... |
Additional parameters passed to specific method implementations. May include connector-specific options or metadata. |
Details
Connector Logging Functions
The logging system is built around S3 generic functions that dispatch to specific implementations based on the connector class. Each operation is logged with contextual information including connector details, operation type, and resource names.
Value
These are primarily side-effect functions that perform logging. The actual return value depends on the specific method implementation, typically:
-
log_read_connector: Result of the read operation -
log_write_connector: Invisible result of write operation -
log_remove_connector: Invisible result of remove operation -
log_list_content_connector: List of connector contents
Connector Logging Functions
Description
-
ConnectorSharepoint: Implementation of the
log_remove_connectorfunction for the ConnectorSharepoint class.
Addition log remove methods for sharepoint connectors implemented for
connector::log_remove_connector():
Usage
## S3 method for class 'ConnectorSharepoint'
log_remove_connector(connector_object, name, ...)
log_remove_connector(connector_object, name, ...)
Arguments
connector_object |
The connector object to log operations for. Can be any connector class (ConnectorFS, ConnectorDBI, ConnectorLogger, etc.) |
name |
Character string specifying the name or identifier of the resource being operated on (e.g., file name, table name) |
... |
Additional parameters passed to specific method implementations. May include connector-specific options or metadata. |
Details
Connector Logging Functions
The logging system is built around S3 generic functions that dispatch to specific implementations based on the connector class. Each operation is logged with contextual information including connector details, operation type, and resource names.
Value
These are primarily side-effect functions that perform logging. The actual return value depends on the specific method implementation, typically:
-
log_read_connector: Result of the read operation -
log_write_connector: Invisible result of write operation -
log_remove_connector: Invisible result of remove operation -
log_list_content_connector: List of connector contents
Connector Logging Functions
Description
-
ConnectorSharepoint: Implementation of the
log_write_connectorfunction for the ConnectorSharepoint class.
Addition log write methods for sharepoint connectors implemented for
connector::log_write_connector():
Usage
## S3 method for class 'ConnectorSharepoint'
log_write_connector(connector_object, name, ...)
log_write_connector(connector_object, name, ...)
Arguments
connector_object |
The connector object to log operations for. Can be any connector class (ConnectorFS, ConnectorDBI, ConnectorLogger, etc.) |
name |
Character string specifying the name or identifier of the resource being operated on (e.g., file name, table name) |
... |
Additional parameters passed to specific method implementations. May include connector-specific options or metadata. |
Details
Connector Logging Functions
The logging system is built around S3 generic functions that dispatch to specific implementations based on the connector class. Each operation is logged with contextual information including connector details, operation type, and resource names.
Value
These are primarily side-effect functions that perform logging. The actual return value depends on the specific method implementation, typically:
-
log_read_connector: Result of the read operation -
log_write_connector: Invisible result of write operation -
log_remove_connector: Invisible result of remove operation -
log_list_content_connector: List of connector contents
Read content from the connector
Description
Addition read methods for sharepoint connectors implemented for
connector::read_cnt():
-
ConnectorSharepoint: Reuses the
connector::read_cnt()method forConnectorSharepoint()
Usage
read_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorSharepoint'
read_cnt(connector_object, name, ...)
Arguments
connector_object |
Connector The connector object to use. |
name |
The name of the file to read |
... |
ConnectorSharepoint: Additional parameters to pass to the
|
Value
R object with the content. For rectangular data a data.frame.
Remove content from the connector
Description
Addition remove methods for sharepoint connectors implemented for
connector::remove_cnt():
-
ConnectorSharepoint: Reuses the
connector::remove_cnt()method forConnectorSharepoint()
Usage
remove_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorSharepoint'
remove_cnt(connector_object, name, ...)
Arguments
connector_object |
Connector The connector object to use. |
name |
character Name of the content to read, write, or remove. Typically the table name. |
... |
ConnectorSharepoint: Additional parameters to pass to the
|
Value
ConnectorSharepoint object
Remove a directory
Description
Addition list content methods for sharepoint connectors implemented for
connector::remove_directory_cnt():
-
ConnectorSharepoint: Reuses the
connector::remove_directory_cnt()method forConnectorSharepoint()
Usage
remove_directory_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorSharepoint'
remove_directory_cnt(connector_object, name, ...)
Arguments
connector_object |
Connector The connector object to use. |
name |
character The name of the directory to remove |
... |
ConnectorSharepoint: Additional parameters to pass to
|
Value
ConnectorSharepoint object
Use dplyr verbs to interact with the remote database table
Description
Addition tbl methods for sharepoint connectors implemented for
connector::tbl_cnt():
-
ConnectorSharepoint: Uses
read_cnt()to allow redundancy.
Usage
tbl_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorSharepoint'
tbl_cnt(connector_object, name, ...)
Arguments
connector_object |
Connector The connector object to use. |
name |
character Name of the content to read, write, or remove. Typically the table name. |
... |
Additional arguments passed to the method for the individual connector. |
Value
A dplyr::tbl object.
Upload content to the connector
Description
Addition list content methods for sharepoint connectors implemented for
connector::upload_cnt():
-
ConnectorSharepoint: Reuses the
connector::upload_cnt()method forConnectorSharepoint()
Usage
upload_cnt(
connector_object,
src,
dest = basename(src),
overwrite = zephyr::get_option("overwrite", "connector"),
...
)
## S3 method for class 'ConnectorSharepoint'
upload_cnt(
connector_object,
src,
dest = basename(src),
overwrite = zephyr::get_option("overwrite", "connector.sharepoint"),
...,
recursive = FALSE
)
Arguments
connector_object |
Connector The connector object to use. |
src |
The local file path to upload |
dest |
The destination name/path in SharePoint |
overwrite |
Overwrite existing content if it exists in the connector?
See connector-options for details. Default can be set globally with
|
... |
ConnectorSharepoint: Additional parameters to pass to
the |
recursive |
If |
Value
ConnectorSharepoint object
Upload a directory
Description
Addition list content methods for sharepoint connectors implemented for
connector::upload_directory_cnt():
Usage
upload_directory_cnt(
connector_object,
src,
dest,
overwrite = zephyr::get_option("overwrite", "connector"),
open = FALSE,
...
)
## S3 method for class 'ConnectorSharepoint'
upload_directory_cnt(
connector_object,
src,
dest = basename(src),
overwrite = zephyr::get_option("overwrite", "connector.sharepoint"),
open = FALSE,
...,
recursive = TRUE
)
Arguments
connector_object |
Connector The connector object to use. |
src |
The local directory path to upload |
dest |
The destination directory name/path in SharePoint |
overwrite |
Overwrite existing content if it exists in the connector?
See connector-options for details. Default can be set globally with
|
open |
logical Open the directory as a new connector object. |
... |
additional parameters passed on to |
recursive |
If |
Value
ConnectorSharepoint object
Write content to the connector
Description
Addition write methods for sharepoint connectors implemented for
connector::write_cnt():
-
ConnectorSharepoint: Reuses the
connector::write_cnt()method forConnectorSharepoint()
Usage
write_cnt(
connector_object,
x,
name,
overwrite = zephyr::get_option("overwrite", "connector"),
...
)
## S3 method for class 'ConnectorSharepoint'
write_cnt(
connector_object,
x,
name,
overwrite = zephyr::get_option("overwrite", "connector.sharepoint"),
...
)
Arguments
connector_object |
Connector The connector object to use. |
x |
The object to write to the connection |
name |
character Name of the content to read, write, or remove. Typically the table name. |
overwrite |
Overwrite existing content if it exists in the connector?
See connector-options for details. Default can be set globally with
|
... |
ConnectorSharepoint: Additional parameters to pass to the
|
Value
invisible connector_object.