Title: | Interface to 'D4Science' 'StorageHub' API |
---|---|
Description: | Provides an interface to 'D4Science' 'StorageHub' API (<https://dev.d4science.org/>). Allows to get user profile, and perform actions over the 'StorageHub' (workspace) including creation of folders, files management (upload/update/deletion/sharing), and listing of stored resources. |
Authors: | Emmanuel Blondel [aut, cre] |
Maintainer: | Emmanuel Blondel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4-4 |
Built: | 2024-11-03 05:21:05 UTC |
Source: | https://github.com/eblondel/d4storagehub4r |
Provides an interface to 'D4Science' 'StorageHub' API (<https://dev.d4science.org/>). Allows to get user profile, and perform actions over the 'StorageHub' (workspace) including creation of folders, files management (upload/update/deletion/sharing), and listing of stored resources.
Emmanuel Blondel [email protected]
d4storagehub4RLogger
d4storagehub4RLogger
R6Class
object.
Object of R6Class
for modelling a simple logger
INFO(text)
Logger to report information. Used internally
WARN(text)
Logger to report warnings. Used internally
ERROR(text)
Logger to report errors. Used internally
verbose.info
verbose info, default is FALSE
verbose.debug
verbose debug, default is FALSE
loggerType
logger type
logger()
Logger function
d4storagehub4RLogger$logger(type, text)
type
type
text
text
INFO()
INFO logger function
d4storagehub4RLogger$INFO(text)
text
text
WARN()
WARN logger function
d4storagehub4RLogger$WARN(text)
text
text
ERROR()
ERROR logger function
d4storagehub4RLogger$ERROR(text)
text
text
new()
Initializes a basic logger class
d4storagehub4RLogger$new(logger = NULL)
logger
the type of logger, either NULL
(default), INFO
, or DEBUG
getClassName()
Get class name
d4storagehub4RLogger$getClassName()
the class name
getClass()
Get class
d4storagehub4RLogger$getClass()
the class
clone()
The objects of this class are cloneable with this method.
d4storagehub4RLogger$clone(deep = FALSE)
deep
Whether to make a deep clone.
Logger class used internally by d4storagehub4R
StoragehubManager
StoragehubManager
Object of R6Class
for modelling a D4Science StoragehubManager
d4storagehub4R::d4storagehub4RLogger
-> StoragehubManager
new()
Method is used to instantiate the StoragehubManager.
StoragehubManager$new( token, token_type = "gcube", logger = NULL, keyring_backend = "env" )
token
user access token
token_type
token type, either 'gcube' (default) or 'jwt'
logger
logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs)
keyring_backend
keyring backend to use.it can be set to use a different backend for storing the D4science gcube token with keyring (Default value is 'env').
getToken()
Get token
StoragehubManager$getToken()
the user access token
getUserProfile()
Get user profile
StoragehubManager$getUserProfile()
the user profile
getUserWorkspace()
Get user workspace
StoragehubManager$getUserWorkspace()
the user workspace root path
fetchWSEndpoint()
Fetches the workspace endpoint from the D4Science ICProxy service
StoragehubManager$fetchWSEndpoint()
fetchUserProfile()
Fetches the user profile
StoragehubManager$fetchUserProfile()
getWSRoot()
Get workspace root
StoragehubManager$getWSRoot()
the workspace root, as list
getWSRootID()
Get workspace root ID
StoragehubManager$getWSRootID()
the workspace root ID, as character
getWSItem()
Get workspace item given a itemPath
in a parent folder
StoragehubManager$getWSItem( parentFolderID = NULL, itemPath, showHidden = FALSE )
parentFolderID
parent folder ID
itemPath
item path
showHidden
show hidden files
the workspace item, NULL
if no workspace item existing
getWSItemID()
Get workspace item ID given a itemPath
in a parent folder
StoragehubManager$getWSItemID( parentFolderID = NULL, itemPath, showHidden = FALSE )
parentFolderID
parent folder ID
itemPath
item path
showHidden
show hidden files
the workspace item ID, NULL
if no workspace item existing
getWSVREFolder()
Get VRE Folder
StoragehubManager$getWSVREFolder()
the VRE folder, as list
getWSVREFolderID()
Get VRE Folder ID
StoragehubManager$getWSVREFolderID()
the VRE folder ID, as character
listWSItems()
Lists workspace items given a parentFolder ID
StoragehubManager$listWSItems(parentFolderID = NULL, showHidden = FALSE)
parentFolderID
parent folder ID
showHidden
show hidden files
an object of class data.frame
listWSItemsByPath()
Lists workspace items given a folder path
StoragehubManager$listWSItemsByPath(folderPath, showHidden = FALSE)
folderPath
folder path where to list items
showHidden
show hidden files
an object of class data.frame
searchWSItem()
Searches for a workspace item given a item path
StoragehubManager$searchWSItem( itemPath, includeVreFolder = TRUE, showHidden = FALSE )
itemPath
path of the item
includeVreFolder
search also in VRE folder
showHidden
show hidden files
the item, NULL
if nothing found
searchWSItemID()
Searches for a workspace item ID given a item path
StoragehubManager$searchWSItemID( itemPath, includeVreFolder = TRUE, showHidden = FALSE )
itemPath
path of the item
includeVreFolder
search also in VRE folder
showHidden
show hidden files
the item, NULL
if nothing found
createFolder()
Creates a folder, given a folder path, a folder name/description. By default recursive = TRUE
meaning
that a folder path matching nested folders will trigger all nested folders. Setting recursive = FALSE
, the
folder creation will work only if the folder path matches an existing folder. The hidden
(default
FALSE
) argument can be used to set hidden folders on the workspace. Using folderID
, recursive
will be
set to FALSE
.
StoragehubManager$createFolder( folderPath = NULL, folderID = NULL, name, description = "", hidden = FALSE, recursive = TRUE )
folderPath
parent folder path where to create the folder
folderID
parent folder ID where to create the folder
name
name of the folder
description
description of the folder
hidden
hidden, default is FALSE
recursive
recursive, default is TRUE
the ID of the created folder
uploadFile()
Uploads a file to a folder (given a folder path). The argument description
can be used to further describe the
file to upload. The argument archive
(default = FALSE) indicates the type of item (FILE or ARCHIVE) to be uploaded.
StoragehubManager$uploadFile( folderPath = NULL, folderID = NULL, file, description = basename(file), archive = FALSE )
folderPath
folder path where to upload the file
folderID
folder ID where to upload the file
file
file to upload
description
file description, default would be the file basename
archive
archive, default is FALSE
the ID of the uploaded file
deleteItem()
Deletes an item given its path on the workspace
StoragehubManager$deleteItem(itemPath, force = FALSE)
itemPath
item path
force
whether to force deletion, default is FALSE
TRUE
if deleted, FALSE
otherwise
shareItem()
Shares an item with users
StoragehubManager$shareItem(itemPath, defaultAccessType, users)
itemPath
item path
defaultAccessType
access type to use for sharing, among 'WRITE_ALL', 'WRITE_OWNER', 'READ_ONLY', 'ADMINISTRATOR'
users
one or more user names with whom the item has to be shared
TRUE
if shared, FALSE
otherwise
unshareItem()
unshare an item
StoragehubManager$unshareItem(itemPath, users)
itemPath
item path
users
users
TRUE
if unshared, FALSE
otherwise
downloadItem()
Download item
StoragehubManager$downloadItem(item = NULL, wd = NULL)
item
item
wd
working directory where to download the item
downloadItemByPath()
Download item by path
StoragehubManager$downloadItemByPath(path, wd = NULL)
path
path
wd
working directory where to download the item
getPublicFileLinkByID()
Get public file link by ID
StoragehubManager$getPublicFileLinkByID(pathID)
pathID
file item ID
the public file URL
getPublicFileLink()
Get public file link
StoragehubManager$getPublicFileLink(path)
path
file path
the public file URL
clone()
The objects of this class are cloneable with this method.
StoragehubManager$clone(deep = FALSE)
deep
Whether to make a deep clone.
Main user class to be used with d4storagehub4R
Deprecated
Emmanuel Blondel <[email protected]>
## Not run: manager <- StoragehubManager$new( token = "<your token>", logger = "DEBUG" ) ## End(Not run)
## Not run: manager <- StoragehubManager$new( token = "<your token>", logger = "DEBUG" ) ## End(Not run)