Skip to content

Commit

Permalink
feat: add get_sp_list_metadata
Browse files Browse the repository at this point in the history
Also swap default for as_data_frame to FALSE for get_sp_list (but not list_sp_lists
  • Loading branch information
elipousson committed Oct 4, 2023
1 parent aef7185 commit c824253
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 10 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export(get_sp_item)
export(get_sp_item_properties)
export(get_sp_list)
export(get_sp_list_item)
export(get_sp_list_metadata)
export(get_sp_plan)
export(get_sp_site)
export(get_sp_site_group)
Expand Down
50 changes: 45 additions & 5 deletions R/sp_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ NULL
#' @rdname sp_list
#' @name get_sp_list
#' @param list_name,list_id SharePoint List name or ID string.
#' @param as_data_frame If `TRUE` (default), return a data frame with a
#' "ms_list" column. [get_sp_list()] returns a 1 row data frame and
#' [list_sp_lists()] returns a data frame with n rows or all lists available
#' for the SharePoint site or drive.
#' @param as_data_frame If `TRUE`, return a data frame with a "ms_list" column.
#' [get_sp_list()] returns a 1 row data frame and [list_sp_lists()] returns a
#' data frame with n rows or all lists available for the SharePoint site or
#' drive. Defaults to `FALSE`. Ignored is `metadata = TRUE` as list metadata
#' is always returned as a data frame.
#' @param metadata If `TRUE`, [get_sp_list()] applies the `get_column_info`
#' method to the returned SharePoint list and returns a data frame with column
#' metadata for the list.
Expand All @@ -91,7 +92,7 @@ get_sp_list <- function(list_name = NULL,
drive_id = NULL,
drive = NULL,
metadata = FALSE,
as_data_frame = TRUE,
as_data_frame = FALSE,
call = caller_env()) {
# FIXME: URL parsing is not set up for links to SharePoint lists
if (is_url(list_name)) {
Expand Down Expand Up @@ -186,3 +187,42 @@ list_sp_lists <- function(site_url = NULL,
keep_list_cols = c("createdBy", "lastModifiedBy")
)
}

#' @rdname sp_list
#' @name get_sp_list_metadata
#' @param sp_list A `ms_list` object. If supplied, `list_name`, `list_id`,
#' `site_url`, `site`, `drive_name`, `drive_id`, `drive`, and any additional
#' parameters passed to `...` are all ignored.
#' @export
get_sp_list_metadata <- function(list_name = NULL,
list_id = NULL,
sp_list = NULL,
...,
site_url = NULL,
site = NULL,
drive_name = NULL,
drive_id = NULL,
drive = NULL,
call = caller_env()) {
if (is.null(sp_list)) {
sp_list_metadata <- get_sp_list(
list_name = list_name,
list_id = list_id,
...,
as_data_frame = FALSE,
metadata = TRUE,
site_url = site_url,
site = site,
drive_name = drive_name,
drive_id = drive_id,
drive = drive,
call = call
)

return(sp_list_metadata)
}

check_ms(sp_list, "ms_list", call = call)

sp_list$get_column_info()
}
29 changes: 24 additions & 5 deletions man/sp_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c824253

Please sign in to comment.