Articles on: API

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.

Updated on: 05/01/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!