Learn R Programming

ocs4R (version 0.3)

ocsManager: ocsManager

Description

ocsManager

ocsManager

Arguments

Value

Object of R6Class for modelling an ocsManager

Format

R6Class object.

Author

Emmanuel Blondel <emmanuel.blondel1@gmail.com>

Super class

ocs4R::ocs4RLogger -> ocsManager

Public fields

apis

list of APIs

Methods

Inherited methods


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

Usage

ocsManager$new(url, user, pwd, logger = NULL, keyring_backend = NULL)

Arguments

url

url

user

user

pwd

pwd

logger

logger type

keyring_backend

keyring back-end. Default is NULL


Method connect()

Method to connect to 'ocs' and set version/capabilities

Usage

ocsManager$connect()


Method getVersion()

Get the 'ocs' server version

Usage

ocsManager$getVersion()


Method getCapabilities()

Get the 'ocs' server capabilities

Usage

ocsManager$getCapabilities()


Method getAPIWebdavManager()

Get the Webdav API manager

Usage

ocsManager$getAPIWebdavManager()

Returns

an instance of ocsApiWebdavManager


Method getAPISharingManager()

Get the Sharing API manager

Usage

ocsManager$getAPISharingManager()

Returns

an instance of ocsApiSharingManager


Method getAPIUserProvisioningManager()

Get the User Provisioning API manager

Usage

ocsManager$getAPIUserProvisioningManager()

Returns

an instance of ocsApiUserProvisioningManager


Method clone()

The objects of this class are cloneable with this method.

Usage

ocsManager$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
if (FALSE) {
   #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")
}

Run the code above in your browser using DataLab