ocsManager: ocsManager

ocsManagerR Documentation

ocsManager

Description

ocsManager

Format

R6Class object.

Value

Object of R6Class for modelling an ocsManager

General Methods

new(url, user, pwd, logger, keyring_backend)

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 'env').

connect()

A method to connect to 'ocs' and set version/capabilities

getVersion()

Get the 'ocs' server version

getCapabilities()

Get the 'ocs' server capabilities

getWebdavRoot()

Get the 'ocs' WebDAV root URL

WebDAV methods

listFiles(relPath)

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.

makeCollection(name, relPath)

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.

uploadFile(filename, relPath)

WebDAV method to upload a file. By default relPath is set to "/" (root).

'OCS' Share API methods

getShares(path, reshares, shared_with_me, state, subfiles, pretty)

Get list of shares as list. To return as data.frame, set pretty = TRUE. The method accepts additional parameters.

createShare(path, name, shareType, shareWith, publicUpload, password, permissions = NULL, expireDate = NULL)

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').

shareWithUser(path, name, username, permissions, pretty)

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 the share properties as list (or asdata.frame if pretty is set to TRUE).

shareWithGroup(path, name, group, permissions, pretty)

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'). Returns the share properties as list (or asdata.frame if pretty is set to TRUE).

shareAsPublicLink(path, name, publicUpload, password, permissions, expireDate)

Shares a resource (file or folder) as public link. The function returns the public link generated by ocs.

Author(s)

Emmanuel Blondel <emmanuel.blondel1@gmail.com>

Examples

## 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)


ocs4R documentation built on March 18, 2022, 6:31 p.m.