> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://wiki.leviia.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Using the Leviia Drive Pro API - Python

###### Initialization :

This part of the code must be at the beginning of your program.

``` import json import requests domain = "cloud.leviia.com"; # Your pro domain auth=('antoine', 'password'); # admin user headers = {"OCS-APIRequest": "true"}```

_Replace "domain", "antoine" and "password" with your domain name, username and password._  

###### Create a user : 

``` userinfo = { "userid":userid, # Must be unique ! "password":"", # If empty an email will be send "displayName":name, # Anything doesn't have to be unique "email":email, # If email is set and password is empty an email will be send to user to ask for first password "groups":[group-name], # Any group you wish or empty. List of strings "subadmin":[], # As you need "quota":size, # The quota for this user "language":lang # Lowercase ISO standard } # Exemple for a user: "thomas.dupond" with # username: "thomas", email: "thomas.dupond@mail.com", in the group: "test", with 1 To of quota and french. # userinfo = { # "userid":"thomas.dupond", # "password":"", # "displayName":"thomas", # "email":"thomas.dupond@mail.com", # "groups":["test"], # "subadmin":[], # "quota":"1 TB", # "language":"fr" # } req = requests.post("https://"+domain+"/ocs/v2.php/cloud/users", json = userinfo, headers=headers, auth=(auth[0], auth[1]))```
  
###### Modify a user :  

``` userinfo = { "password":"", # If empty an email will be send "displayName":name, # Anything doesn't have to be unique "email":email, # If email is set and password is empty an email will be send to user to ask for first password "groups":[group-name], # Any group you wish or empty. List of strings "subadmin":[], # As you need "quota":size, # The quota for this user "language":lang # Lowercase ISO standard } req = requests.put("https://"+domain+"/ocs/v2.php/cloud/users/"+userid, json = userinfo, headers=headers, auth=(auth[0], auth[1]))```

_Replace "userid" with the id of the user you wish to modify.  _

###### Recover user information :  

``` req = requests.get("https://"+domain+"/ocs/v2.php/cloud/users/"+userid, headers=headers, auth=(auth[0], auth[1]))```

###### Delete a user :  

``` req = requests.delete("https://"+domain+"/ocs/v2.php/cloud/users/"+userid, headers=headers, auth=(auth[0], auth[1]))```

_Replace "userid" with the id of the user you wish to delete._
