| Title: | Interface to Open Collaboration Services (OCS) REST API |
|---|---|
| Description: | Provides an Interface to Open Collaboration Services 'OCS' (<https://www.open-collaboration-services.org/>) REST API. |
| Authors: | Emmanuel Blondel [aut, cre] (ORCID: <https://orcid.org/0000-0002-5870-5762>) |
| Maintainer: | Emmanuel Blondel <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.3.1 |
| Built: | 2026-05-29 07:50:27 UTC |
| Source: | https://github.com/eblondel/ocs4r |
Provides an Interface to 'OCS' (<https://www.open-collaboration-services.org/>) REST API.
Emmanuel Blondel [email protected]
Useful links:
ocs4RLogger
ocs4RLogger
R6Class object.
Object of R6Class for modelling a simple logger
verbose.infois info logger active?
verbose.debugis debug logger active?
loggerTypelogger type
new()
Initializes the logger
ocs4RLogger$new(logger = NULL)
loggerthe type of logger. Default is NULL, accepts INFO or DEBUG
logger()
Logger function
ocs4RLogger$logger(type, text)
typetype of log
texttext
INFO()
Logger to report information. Used internally
ocs4RLogger$INFO(text)
texttext
WARN()
Logger to report warnings. Used internally
ocs4RLogger$WARN(text)
texttext
ERROR()
Logger to report errors Used internally
ocs4RLogger$ERROR(text)
texttext
getClassName()
Get class name
ocs4RLogger$getClassName()
the class name
getClass()
Get class
ocs4RLogger$getClass()
the class
clone()
The objects of this class are cloneable with this method.
ocs4RLogger$clone(deep = FALSE)
deepWhether to make a deep clone.
Logger class used internally by ocs4R
ocsApiSharingManager
ocsApiSharingManager
R6Class object.
Object of R6Class for modelling an ocsManager for the Sharing API
ocs4R::ocs4RLogger -> ocs4R::ocsManager -> ocsApiSharingManager
ocs4R::ocs4RLogger$ERROR()ocs4R::ocs4RLogger$INFO()ocs4R::ocs4RLogger$WARN()ocs4R::ocs4RLogger$getClass()ocs4R::ocs4RLogger$getClassName()ocs4R::ocs4RLogger$logger()ocs4R::ocsManager$connect()ocs4R::ocsManager$getAPISharingManager()ocs4R::ocsManager$getAPIUserProvisioningManager()ocs4R::ocsManager$getAPIWebdavManager()ocs4R::ocsManager$getCapabilities()ocs4R::ocsManager$getVersion()new()
Initialize manager
ocsApiSharingManager$new(url, user, pwd, logger = NULL, keyring_backend = NULL)
urlurl
useruser
pwdpwd
loggerlogger
keyring_backendbackend to use with keyring. Default is NULL
getShares()
Get list of shares as list. To return as data.frame,
set pretty = TRUE. The method accepts additional parameters.
ocsApiSharingManager$getShares( path = NULL, reshares = FALSE, shared_with_me = NULL, state = NULL, subfiles = FALSE, pretty = FALSE )
pathpath
resharesreshares
shared_with_melist only those shared with me?
statestate
subfilessubfiles
prettypretty
the list of shares as list or data.frame
createShare()
Creates a share for the path (file or folder), given a name. The shareType should be among
values 'user','group','publiclink' or 'federated'.The shareWith is required for shareType
'user' and 'group' and corresponds to the username or groupname. The permissions can be set among
values 'read', 'update', 'create', 'delete', 'read-write', 'share', 'all'. By default the permissions will
be the default permissions set by the ocs server (by default 'all').
ocsApiSharingManager$createShare( path, name, shareType, shareWith, publicUpload = NULL, password = NULL, permissions = NULL, expireDate = NULL )
pathpath
namename
shareTypethe type of share
shareWitha list of users to share with
publicUploadpublic upload
passwordto set to access the share
permissionspermissions
expireDateexpire date
shareWithUser()
Shares a resource (file or folder) with a user given its username handled with argument username.
The permissions can be set among values 'read', 'update', 'create', 'delete', 'read-write', 'share',
'all'. By default the permissions will be the default permissions set by the ocs server (by default 'all').
Returns
ocsApiSharingManager$shareWithUser( path, name, username, permissions = NULL, pretty = FALSE )
pathpath
namename
usernameusername
permissionspermissions
prettypretty
groupgroup
the share properties as list (or asdata.frame if pretty is set to TRUE).
shareWithGroup()
Shares a resource (file or folder) with a group given its name handled with argument group.
The permissions can be set among values 'read', 'update', 'create', 'delete', 'read-write', 'share',
'all'. By default the permissions will be the default permissions set by the ocs server (by default 'all').
ocsApiSharingManager$shareWithGroup( path, name, group, permissions = NULL, pretty = FALSE )
pathpath
namename
groupgroup
permissionspermissions
prettypretty
the share properties as list (or asdata.frame if pretty is set to TRUE).
shareAsPublicLink()
Shares a resource (file or folder) as public link. The function returns the public link generated by ocs.
ocsApiSharingManager$shareAsPublicLink( path, name = NULL, publicUpload = FALSE, password = NULL, permissions = NULL, expireDate = NULL )
pathpath
namename
publicUploadpublic upload?
passwordpassword
permissionspermissions
expireDateexpire date
returnthe public sharing link
clone()
The objects of this class are cloneable with this method.
ocsApiSharingManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
ocsApiUserProvisioningManager
ocsApiUserProvisioningManager
R6Class object.
Object of R6Class for modelling an ocsManager for Webdav API
ocs4R::ocs4RLogger -> ocs4R::ocsManager -> ocsApiUserProvisioningManager
ocs4R::ocs4RLogger$ERROR()ocs4R::ocs4RLogger$INFO()ocs4R::ocs4RLogger$WARN()ocs4R::ocs4RLogger$getClass()ocs4R::ocs4RLogger$getClassName()ocs4R::ocs4RLogger$logger()ocs4R::ocsManager$connect()ocs4R::ocsManager$getAPISharingManager()ocs4R::ocsManager$getAPIUserProvisioningManager()ocs4R::ocsManager$getAPIWebdavManager()ocs4R::ocsManager$getCapabilities()ocs4R::ocsManager$getVersion()new()
Initialize manager
ocsApiUserProvisioningManager$new( url, user, pwd, logger = NULL, keyring_backend = "env" )
urlurl
useruser
pwdpwd
loggerlogger
keyring_backendbackend to use with keyring. Default is NULL
addUser()
Adds a user given a userid (required). All other fields (email, password, groups) are
optional for the user creation. Returns TRUE if the user is added, FALSE otherwise.
ocsApiUserProvisioningManager$addUser( userid, email = NULL, password = NULL, groups = NULL )
useriduser ID
emailpassworduser password
groupsgroups
getUsers()
Get the list of users. This method returns a vector of class 'character' giving the user IDs available in the OCS cloud plateform.
ocsApiUserProvisioningManager$getUsers()
getUser()
Get the user details from its userid. If the argument pretty is set to TRUE,
this will return an object of class data.frame, otherwise (by default) it returns
an object of class list.
ocsApiUserProvisioningManager$getUser(userid, pretty = FALSE)
useriduser ID
prettypretty
editUser()
Edits a user, identifier by a userid. The user property to be edited should be set using its
key (eg display) and the value to be modified for this key. Returns TRUE if the user
is edited, FALSE otherwise.
ocsApiUserProvisioningManager$editUser(userid, key, value)
useriduser ID
keykey
valuevalue
editUserDisplayName()
Edits a user display name.
ocsApiUserProvisioningManager$editUserDisplayName(userid, displayName)
useriduser ID
displayNamedisplay name
editUserEmail()
Edits a user email
ocsApiUserProvisioningManager$editUserEmail(userid, email)
useriduser ID
emaileditUserPassword()
Edits a user password
ocsApiUserProvisioningManager$editUserPassword(userid, password)
useriduser ID
passwordpassword
editUserQuota()
Edits a user quota
ocsApiUserProvisioningManager$editUserQuota(userid, quota)
useriduser ID
quotaquota
enableUser()
Enables a user
ocsApiUserProvisioningManager$enableUser(userid)
useriduser ID
TRUE if enabled, FALSE otherwise
disableUser()
Disables a user
ocsApiUserProvisioningManager$disableUser(userid)
useriduser ID
TRUE if disabled, FALSE otherwise
deleteUser()
Deletes a user
ocsApiUserProvisioningManager$deleteUser(userid)
useriduser ID
TRUE if deleted, FALSE otherwise
getUserGroups()
Get user groups
ocsApiUserProvisioningManager$getUserGroups(userid)
useriduser ID
the user groups
addToGroup()
Adds a user to a group.
ocsApiUserProvisioningManager$addToGroup(userid, groupid)
useriduser ID
groupidgroup ID
TRUE if added, FALSE otherwise
removeFromGroup()
Removes a user from a group.
ocsApiUserProvisioningManager$removeFromGroup(userid, groupid)
useriduser ID
groupidgroup ID
TRUE if removed, FALSE otherwise
createSubadmin()
Creates a subadmin
ocsApiUserProvisioningManager$createSubadmin()
removeSubadmin()
Removes a subadmin
ocsApiUserProvisioningManager$removeSubadmin()
getSubadminGroups()
Get subadmin groups
ocsApiUserProvisioningManager$getSubadminGroups()
getGroups()
Get the list of groups. This method returns a vector of class 'character' giving the usergroups IDs
ocsApiUserProvisioningManager$getGroups( search = NULL, limit = NULL, offset = NULL )
searchsearch
limitlimit
offsetoffset
addGroup()
Adds a group
ocsApiUserProvisioningManager$addGroup(groupid)
groupidgroup ID
TRUE if added, FALSE
getGroup()
Gets a group
ocsApiUserProvisioningManager$getGroup(groupid)
groupidgroup ID
the group as list including the group ID and the list of users
deleteGroup()
Deletes a group
ocsApiUserProvisioningManager$deleteGroup(groupid)
groupidgroup ID
TRUE if deleted, FALSE
getSubadmins()
Get subadmins
ocsApiUserProvisioningManager$getSubadmins()
clone()
The objects of this class are cloneable with this method.
ocsApiUserProvisioningManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
ocsApiWebdavManager
ocsApiWebdavManager
R6Class object.
Object of R6Class for modelling an ocsManager for Webdav API
ocs4R::ocs4RLogger -> ocs4R::ocsManager -> ocsApiWebdavManager
ocs4R::ocs4RLogger$ERROR()ocs4R::ocs4RLogger$INFO()ocs4R::ocs4RLogger$WARN()ocs4R::ocs4RLogger$getClass()ocs4R::ocs4RLogger$getClassName()ocs4R::ocs4RLogger$logger()ocs4R::ocsManager$connect()ocs4R::ocsManager$getAPISharingManager()ocs4R::ocsManager$getAPIUserProvisioningManager()ocs4R::ocsManager$getAPIWebdavManager()ocs4R::ocsManager$getCapabilities()ocs4R::ocsManager$getVersion()new()
Initialize manager
ocsApiWebdavManager$new(url, user, pwd, logger = NULL, keyring_backend = NULL)
urlurl
useruser
pwdpwd
loggerlogger
keyring_backendbackend to use with keyring. Default is NULL
getWebdavRoot()
Get the 'ocs' WebDAV root URL
ocsApiWebdavManager$getWebdavRoot()
listFiles()
WebDAV method to list folders/files given a relative path. The relative path is set
to "/" by default, which corresponds to the root of the 'ocs' repository.
ocsApiWebdavManager$listFiles(relPath = "/")
relPathrelative path
the list of files
makeCollection()
WebDAV method to make a collection. By default relPath is set to "/" (root).
The name is the name of the new collection to be created. The function is recursive
in the sense that a name can be provided as relative path of a collection tree
(eg newfolder1/newfolder2/newfolder3), the function will create recursively as
many collections are handled in the name.
ocsApiWebdavManager$makeCollection(name, relPath = "/")
namename
relPathrelative path
uploadFile()
WebDAV method to upload a file. By default relPath is set to "/" (root).
ocsApiWebdavManager$uploadFile( filename, relPath = "/", delete_if_existing = FALSE )
filenamefile name
relPathrelative path
delete_if_existingdelete if existing file? Default is FALSE
deleteFile()
WebDAV method to delete a file. By default relPath is set to "/" (root).
ocsApiWebdavManager$deleteFile(filename, relPath = "/")
filenamefile name
relPathrelative path
downloadFile()
Downloads a file
ocsApiWebdavManager$downloadFile(relPath, filename, outdir = ".")
relPathrelative path
filenamefile name
outdirthe out directory where to download the file
getPublicFile()
Get details of a shared public file given its share token
ocsApiWebdavManager$getPublicFile(share_token)
share_tokenthe share token
clone()
The objects of this class are cloneable with this method.
ocsApiWebdavManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
ocsManager
ocsManager
R6Class object.
Object of R6Class for modelling an ocsManager
ocs4R::ocs4RLogger -> ocsManager
apislist of APIs
new()
This method is used to instantiate an ocsManager. The user/pwd are mandatory in order to connect to 'ocs'. The logger can be either NULL, "INFO" (with minimum logs), or "DEBUG" (for complete curl http calls logs).
The keyring_backend can be set to use a different backend for storing
the user password with keyring (Default value is NULL, meaning the password
is stored as private field).
ocsManager$new(url, user, pwd, logger = NULL, keyring_backend = NULL)
urlurl
useruser
pwdpwd
loggerlogger type
keyring_backendkeyring back-end. Default is NULL
connect()
Method to connect to 'ocs' and set version/capabilities
ocsManager$connect()
getVersion()
Get the 'ocs' server version
ocsManager$getVersion()
getCapabilities()
Get the 'ocs' server capabilities
ocsManager$getCapabilities()
getAPIWebdavManager()
Get the Webdav API manager
ocsManager$getAPIWebdavManager()
an instance of ocsApiWebdavManager
getAPISharingManager()
Get the Sharing API manager
ocsManager$getAPISharingManager()
an instance of ocsApiSharingManager
getAPIUserProvisioningManager()
Get the User Provisioning API manager
ocsManager$getAPIUserProvisioningManager()
an instance of ocsApiUserProvisioningManager
clone()
The objects of this class are cloneable with this method.
ocsManager$clone(deep = FALSE)
deepWhether to make a deep clone.
Emmanuel Blondel <[email protected]>
## Not run: #Not Run: #Connect to an OCS API OCS <- ocsManager$new(url = ocs_url, user = ocs_user, pwd = ocs_pwd, logger = "DEBUG") version <- OCS$getVersion() caps <- OCS$getCapabilities() #OCS User Provisioning API #------------------------------------- #users users <- OCS$getUsers() #get users user <- OCS$getUser("admin") #get a user user.df <- OCS$getUser("admin", TRUE) #the same user as data.frame added <- OCS$addUser("john.doe", password = "ocs4john") #add a user disabled <- OCS$disableUser("john.doe") #disable a user enabled <- OCS$enableUser("john.doe") #enable auser edited <- OCS$editUser("john.doe", key = "display", value = "John Doe") #edit user #edit some user field edited2 <- OCS$editUserDisplayName("john.doe", displayName = "John Doe Jr.") deleted <- OCS$deleteUser("john.doe") #groups admingroups <- OCS$getUserGroups("admin") groups <- OCS$getGroups() added <- OCS$addGroup("scientists") #add a new group sc_group <- OCS$getGroup("scientists") #get group details added <- OCS$addToGroup("john.doe", "scientists") #add user to group removed <- OCS$removeFromGroup("john.doe", "scientists") #remove user from group deleted <- OCS$deleteGroup("scientists") #OCS Webdav API #------------------------------------- #list files files <- OCS$listFiles() subfiles <- OCS$listFiles("Documents") #make collection OCS$makeCollection("myfolder") subfiles <- OCS$listFiles("myfolder") #upload a file? filename <- "magic.txt" file.create(filename); writeLines("ocs4R is great", filename) #we upload the file in 'Documents' folder OCS$uploadFile(filename, "/Documents") #check if file is uploaded OCS$listFiles('Documents') #OCS Sharing API #------------------------------------- #let's add a user with User provisioning API added <- OCS$addUser("john.doe", password = "ocs4john") #add a user #let's share the previously uploaded file with John Doe OCS$shareWithUser("/Documents", filename, "john.doe") ## End(Not run)## Not run: #Not Run: #Connect to an OCS API OCS <- ocsManager$new(url = ocs_url, user = ocs_user, pwd = ocs_pwd, logger = "DEBUG") version <- OCS$getVersion() caps <- OCS$getCapabilities() #OCS User Provisioning API #------------------------------------- #users users <- OCS$getUsers() #get users user <- OCS$getUser("admin") #get a user user.df <- OCS$getUser("admin", TRUE) #the same user as data.frame added <- OCS$addUser("john.doe", password = "ocs4john") #add a user disabled <- OCS$disableUser("john.doe") #disable a user enabled <- OCS$enableUser("john.doe") #enable auser edited <- OCS$editUser("john.doe", key = "display", value = "John Doe") #edit user #edit some user field edited2 <- OCS$editUserDisplayName("john.doe", displayName = "John Doe Jr.") deleted <- OCS$deleteUser("john.doe") #groups admingroups <- OCS$getUserGroups("admin") groups <- OCS$getGroups() added <- OCS$addGroup("scientists") #add a new group sc_group <- OCS$getGroup("scientists") #get group details added <- OCS$addToGroup("john.doe", "scientists") #add user to group removed <- OCS$removeFromGroup("john.doe", "scientists") #remove user from group deleted <- OCS$deleteGroup("scientists") #OCS Webdav API #------------------------------------- #list files files <- OCS$listFiles() subfiles <- OCS$listFiles("Documents") #make collection OCS$makeCollection("myfolder") subfiles <- OCS$listFiles("myfolder") #upload a file? filename <- "magic.txt" file.create(filename); writeLines("ocs4R is great", filename) #we upload the file in 'Documents' folder OCS$uploadFile(filename, "/Documents") #check if file is uploaded OCS$listFiles('Documents') #OCS Sharing API #------------------------------------- #let's add a user with User provisioning API added <- OCS$addUser("john.doe", password = "ocs4john") #add a user #let's share the previously uploaded file with John Doe OCS$shareWithUser("/Documents", filename, "john.doe") ## End(Not run)
ocsRequest
ocsRequest
R6Class object.
Object of R6Class for modelling a generic 'ocs' web-service request
new(type, url, request, user, pwd, token, cookies,
format, namedParams, content, contentType, filename, logger, ...)This method is used to instantiate a object for doing an 'ocs' web-service request
getRequest()Get the request payload
getRequestHeaders()Get the request headers
getStatus()Get the request status code
getResponse()Get the request response
getException()Get the exception (in case of request failure)
getResult()Get the result TRUE if the request is successful, FALSE otherwise
ocs4R::ocs4RLogger -> ocsRequest
new()
This method is used to instantiate a object for doing an 'ocs' web-service request
ocsRequest$new( type, url, request, user = NULL, pwd = NULL, token = NULL, cookies = NULL, format = "json", namedParams = list(), content = NULL, contentType = "text/plain", filename = NULL, logger = NULL, ... )
typetype of request
urlurl
requestrequest
useruser
pwdpwd
tokentoken
cookiescookies
formatformat. Default is "json"
namedParamsa list of named parameters
contentcontent
contentTypecontent type. Default is "text/plain"
filenamefile name
loggerlogger
...additional parameters
execute()
Executes the request
ocsRequest$execute()
getRequest()
Get request
ocsRequest$getRequest()
getRequestHeaders()
Get request headers
ocsRequest$getRequestHeaders()
getStatus()
Get status
ocsRequest$getStatus()
getResponse()
Get response
ocsRequest$getResponse()
getException()
Get exception
ocsRequest$getException()
getResult()
Get result
ocsRequest$getResult()
setResult()
Set result
ocsRequest$setResult(result)
resultresult
clone()
The objects of this class are cloneable with this method.
ocsRequest$clone(deep = FALSE)
deepWhether to make a deep clone.
Abstract class used internally by ocs4R
Emmanuel Blondel <[email protected]>