Open nickdickinson opened 1 month ago
Add updateResource() using https://www.activityinfo.org/support/docs/api/reference/updateDatabase.html and providing resourceUpdates with the resource to change. See folder example.
here's an example I created for my own usage, if it might help:
create_folder_activityinfo <- function(folderId = NULL, folderLabel, databaseId, locationId = NULL) {
## if folderId isn't specified, create a folder
if (is.null(folderId)) {
## create new folder
request <- databaseUpdates()
request$resourceUpdates <- list(list(
id = cuid(), ## generate new folder using random new CUID
parentId = databaseId, ## create it at first level of db
type = "FOLDER",
label = folderLabel)
)
result <- activityinfo:::postResource(
sprintf("databases/%s", databaseId),
request,
task = sprintf("Requesting to create folder '%s' with id %s from database %s", folderLabel, folderId, databaseId)
)
} else {
if (is.null(locationId)) stop("Please input a new location ID (folder ID or database ID)")
## move existing folder cwsp8ywlo79hmox3 to another location within db
request <- databaseUpdates()
request$resourceUpdates <- list(list(
id = folderId, ## id of existing folder
parentId = locationId, ## move to NEW location: another folder or back to top database
type = "FOLDER")
)
result <- postResource(
sprintf("databases/%s", databaseId),
request,
task = sprintf("Requesting to move folder '%s' with id %s from database %s", folderLabel, folderId, databaseId)
)
}
}
At the moment, there are no functions in the package to add or change folders. Should we consider this in a future release?