nextcloud-api documentation

32
nextcloud-API Documentation Release 0.0.1 EnterpriseyIntranet Jul 11, 2020

Upload: others

Post on 27-Dec-2021

54 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: nextcloud-API Documentation

nextcloud-API DocumentationRelease 0.0.1

EnterpriseyIntranet

Jul 11, 2020

Page 2: nextcloud-API Documentation
Page 3: nextcloud-API Documentation

Contents:

1 Introduction 11.1 Quick start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Which API does it support? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Download and install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.4 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.5 What’s next ? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Examples 32.1 Users API methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Nextcloud-API 53.1 nextcloud module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.2 NextCloud api wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Python Module Index 21

Index 23

i

Page 4: nextcloud-API Documentation

ii

Page 5: nextcloud-API Documentation

CHAPTER 1

Introduction

Nextcloud-API is Python (2 and 3) wrapper for NextCloud’s API. With it you can manage your NextCloud instancesfrom Python scripts.

If you have any question, remark or if you find a bug, don’t hesitate to open an issue.

1.1 Quick start

First, create your NextCloud instance:

import sysimport osfrom os.path import dirnamefrom os.path import join

sys.path.insert(0, join(dirname(__file__), 'src'))

from nextcloud import NextCloud

NEXTCLOUD_URL = "http://{}:80".format(os.environ['NEXTCLOUD_HOSTNAME'])NEXTCLOUD_USERNAME = os.environ.get('NEXTCLOUD_ADMIN_USER')NEXTCLOUD_PASSWORD = os.environ.get('NEXTCLOUD_ADMIN_PASSWORD')

# True if you want to get response as JSON# False if you want to get response as XMLto_js = True

nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_→˓PASSWORD, json_output=to_js)

Then you can work with NextCloud objects:

1

Page 6: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

nxc.get_users()new_user_id = "new_user_username"add_user_res = nxc.add_user(new_user_id, "new_user_password321_123")group_name = "new_group_name"add_group_res = nxc.add_group(group_name)add_to_group_res = nxc.add_to_group(new_user_id, group_name)

1.2 Which API does it support?

API name Implementation status Last checked dateUser provisioning API OK 2019-02-02OCS Share API Partially implemented 2019-02-02WebDAV API OK 2019-02-02Activity app API OK 2019-02-02Notifications app API OK 2019-02-02The LDAP configuration API OK 2019-02-02Capabilities API OK 2019-02-02Group Folders API OK 2019-02-02

1.3 Download and install

python setup.py install

1.4 License

Nextcloud-API is licensed under the GNU General Public License v3.0.

1.5 What’s next ?

Check Examples and Nextcloud-API.

2 Chapter 1. Introduction

Page 7: nextcloud-API Documentation

CHAPTER 2

Examples

2.1 Users API methods

import sysimport osfrom os.path import dirnamefrom os.path import join

sys.path.insert(0, join(dirname(__file__), 'src'))

from nextcloud import NextCloud

NEXTCLOUD_URL = "http://{}:80".format(os.environ['NEXTCLOUD_HOSTNAME'])NEXTCLOUD_USERNAME = os.environ.get('NEXTCLOUD_ADMIN_USER')NEXTCLOUD_PASSWORD = os.environ.get('NEXTCLOUD_ADMIN_PASSWORD')

# True if you want to get response as JSON# False if you want to get response as XMLto_js = True

nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_→˓PASSWORD, json_output=to_js)

# Quick startnxc.get_users()new_user_id = "new_user_username"add_user_res = nxc.add_user(new_user_id, "new_user_password321_123")group_name = "new_group_name"add_group_res = nxc.add_group(group_name)add_to_group_res = nxc.add_to_group(new_user_id, group_name)# End quick start

assert add_group_res.status_code == 100assert new_user_id in nxc.get_group(group_name).data['users']

(continues on next page)

3

Page 8: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

(continued from previous page)

assert add_user_res.status_code == 100assert add_to_group_res.status_code == 100

# remove userremove_user_res = nxc.delete_user(new_user_id)assert remove_user_res.status_code == 100user_res = nxc.get_user(new_user_id)assert user_res.status_code == 404

4 Chapter 2. Examples

Page 9: nextcloud-API Documentation

CHAPTER 3

Nextcloud-API

3.1 nextcloud module

class nextcloud.NextCloud.NextCloud(endpoint, user, password, json_output=True)Bases: object

get_connection_issues()Return Falsy falue if everything is OK, or string representing the connection problem (bad hostname,password, whatever)

class nextcloud.NextCloud.OCSRequester(endpoint, user, passwd, json_output=False)Bases: nextcloud.requester.Requester

Requester for OCS API

rtn(resp)

nextcloud.NextCloud.WEBDAV_CLASSalias of nextcloud.api_wrappers.webdav.WebDAV

class nextcloud.NextCloud.WebDAVRequester(*args, **kwargs)Bases: nextcloud.requester.Requester

Requester for WebDAV API

copy(url, destination, overwrite=False)

download(url=”, params=None)

make_collection(additional_url=”)

move(url, destination, overwrite=False)

propfind(additional_url=”, headers=None, data=None)

proppatch(additional_url=”, data=None)

report(additional_url=”, data=None)

rtn(resp, data=None)

5

Page 10: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

3.2 NextCloud api wrappers

class nextcloud.api_wrappers.Activity(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v2.php/apps/activity/api/v2/activity'

SUCCESS_CODE = 200

get_activities(since=None, limit=None, object_type=None, object_id=None, sort=None)Get an activity feed showing your file changes and other interesting things going on in your Nextcloud

All args are optional

Parameters

• since (int) – ID of the last activity that you’ve seen

• limit (int) – How many activities should be returned (default: 50)

• object_type (string) – Filter the activities to a given object. May only appeartogether with object_id

• object_id (string) – Filter the activities to a given object. May only appear togetherwith object_type

• sort (str, "asc" or "desc") – Sort activities ascending or descending (from thesince) (Default: desc)

Returns:

class nextcloud.api_wrappers.Apps(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v1.php/cloud/apps'

SUCCESS_CODE = 100

disable_app(app_id)Disable the specified app

Parameters app_id – str, app id

Returns

enable_app(app_id)Enable an app

Parameters app_id – str, app id

Returns

get_app(app_id)Provide information on a specific application

Parameters app_id – str, app id

Returns

get_apps(filter=None)Get a list of apps installed on the Nextcloud server

Parameters filter – str, optional “enabled” or “disabled”

Returns

6 Chapter 3. Nextcloud-API

Page 11: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

class nextcloud.api_wrappers.Capabilities(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v1.php/cloud/capabilities'

SUCCESS_CODE = 100

get_capabilities()Obtain capabilities provided by the Nextcloud server and its apps

class nextcloud.api_wrappers.FederatedCloudShare(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v2.php/apps/files_sharing/api/v1'

FEDERATED = 'remote_shares'

SUCCESS_CODE = 200

accept_pending_federated_cloudshare(sid)

decline_pending_federated_cloudshare(sid)

delete_accepted_federated_cloudshare(sid)

get_federated_url(additional_url=”)

get_known_federated_cloudshare(sid)

list_accepted_federated_cloudshares()

list_pending_federated_cloudshares()

class nextcloud.api_wrappers.Group(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v1.php/cloud/groups'

SUCCESS_CODE = 100

add_group(gid)Add a new group

Parameters gid – str, group name

Returns

delete_group(gid)Remove a group

Parameters gid – str, group name

Returns

get_group(gid)Retrieve a list of group members

Parameters gid – str, group name

Returns

get_groups(search=None, limit=None, offset=None)Retrieve a list of groups from the Nextcloud server

Parameters

• search – string, optional search string

• limit – int, optional limit value

3.2. NextCloud api wrappers 7

Page 12: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

• offset – int, optional offset value

Returns

get_subadmins(gid)List subadmins of the group

Parameters gid – str, group name

Returns

class nextcloud.api_wrappers.GroupFolders(requester)Bases: nextcloud.base.WithRequester

API_URL = '/apps/groupfolders/folders'

SUCCESS_CODE = 100

create_group_folder(mountpoint)Create a new group folder

Parameters mountpoint (str) – name for the new folder

Returns:

delete_group_folder(fid)Delete a group folder

Parameters fid (int/str) – group folder id

Returns:

get_group_folder(fid)Return a specific configured folder and it’s settings

Parameters fid (int/str) – group folder id

Returns:

get_group_folders()Return a list of call configured folders and their settings

Returns:

grant_access_to_group_folder(fid, gid)Give a group access to a folder

Parameters

• fid (int/str) – group folder id

• gid (str) – group to share with id

Returns:

rename_group_folder(fid, mountpoint)Change the name of a folder

Parameters

• fid (int/str) – group folder id

• mountpoint (str) – The new name for the folder

Returns:

revoke_access_to_group_folder(fid, gid)Remove access from a group to a folder

8 Chapter 3. Nextcloud-API

Page 13: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

Parameters

• fid (int/str) – group folder id

• gid (str) – group id

Returns:

set_permissions_to_group_folder(fid, gid, permissions)Set the permissions a group has in a folder

Parameters

• fid (int/str) – group folder id

• gid (str) – group id

• permissions (int) – The new permissions for the group as attribute of Permissionclass

Returns:

set_quota_of_group_folder(fid, quota)Set the quota for a folder in bytes

Parameters

• fid (int/str) – group folder id

• quota (int/str) – The new quota for the folder in bytes, user -3 for unlimited

Returns:

class nextcloud.api_wrappers.Notifications(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v2.php/apps/notifications/api/v2/notifications'

SUCCESS_CODE = 200

delete_all_notifications()Delete all notification for a logged in user

Notes

This endpoint was added for Nextcloud 14

delete_notification(notification_id)Delete single notification by id for a user

Parameters notification_id (int) – Notification id

Returns:

get_notification(notification_id)Get single notification by id for a user

Parameters notification_id (int) – Notification id

Returns:

get_notifications()Get list of notifications for a logged in user

class nextcloud.api_wrappers.Share(requester)Bases: nextcloud.base.WithRequester

3.2. NextCloud api wrappers 9

Page 14: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

API_URL = '/ocs/v2.php/apps/files_sharing/api/v1'

LOCAL = 'shares'

SUCCESS_CODE = 200

create_share(path, share_type, share_with=None, public_upload=None, password=None, permis-sions=None)

Share a file/folder with a user/group or as public link

Mandatory fields: share_type, path and share_with for share_type USER (0) or GROUP (1).

Parameters

• path (str) – path to the file/folder which should be shared

• share_type (int) – ShareType attribute

• share_with (str) – user/group id with which the file should be shared

• public_upload (bool) – bool, allow public upload to a public shared folder(true/false)

• password (str) – password to protect public link Share with

• permissions (int) – sum of selected Permission attributes

Returns:

delete_share(sid)Remove the given share

Parameters sid (str) – share id

Returns:

get_local_url(additional_url=”)

get_share_info(sid)Get information about a given share

Parameters sid (int) – share id

Returns:

get_shares()Get all shares from the user

get_shares_from_path(path, reshares=None, subfiles=None)Get all shares from a given file/folder

Parameters

• path (str) – path to file/folder

• reshares (bool) – (optional) return not only the shares from the current user but allshares from the given file

• subfiles (bool) – (optional) return all shares within a folder, given that path defines afolder

Returns:

update_share(sid, permissions=None, password=None, public_upload=None, expire_date=”)Update a given share, only one value can be updated per request

Parameters

• sid (str) – share id

10 Chapter 3. Nextcloud-API

Page 15: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

• permissions (int) – sum of selected Permission attributes

• password (str) – password to protect public link Share with

• public_upload (bool) – bool, allow public upload to a public shared folder(true/false)

• expire_date (str) – set an expire date for public link shares. Format: ‘YYYY-MM-DD’

Returns:

static validate_share_parameters(path, share_type, share_with)Check if share parameters make sense

Parameters

• path (str) – path to the file/folder which should be shared

• share_type (int) – ShareType attribute

• share_with (str) – user/group id with which the file should be shared

Returns True if parameters make sense together, False otherwise

Return type bool

class nextcloud.api_wrappers.User(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v1.php/cloud/users'

SUCCESS_CODE = 100

add_to_group(uid, gid)Add the specified user to the specified group

Parameters

• uid – str, uid of user

• gid – str, name of group

Returns

add_user(uid, passwd)Create a new user on the Nextcloud server

Parameters

• uid – str, uid of new user

• passwd – str, password of new user

Returns

create_subadmin(uid, gid)Make a user the subadmin of a group

Parameters

• uid – str, uid of user

• gid – str, name of group

Returns

delete_user(uid)Delete a user from the Nextcloud server

3.2. NextCloud api wrappers 11

Page 16: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

Parameters uid – str, uid of user

Returns

disable_user(uid)Disable a user on the Nextcloud server so that the user cannot login anymore

Parameters uid – str, uid of user

Returns

edit_user(uid, what, value)Edit attributes related to a user

Users are able to edit email, displayname and password; admins can also edit the quota value

Parameters

• uid – str, uid of user

• what – str, the field to edit

• value – str, the new value for the field

Returns

enable_user(uid)Enable a user on the Nextcloud server so that the user can login again

Parameters uid – str, uid of user

Returns

get_subadmin_groups(uid)Get the groups in which the user is a subadmin

Parameters uid – str, uid of user

Returns

get_user(uid)Retrieve information about a single user

Parameters uid – str, uid of user

Returns

get_users(search=None, limit=None, offset=None)Retrieve a list of users from the Nextcloud server

Parameters

• search – string, optional search string

• limit – int, optional limit value

• offset – int, optional offset value

Returns

remove_from_group(uid, gid)Remove the specified user from the specified group

Parameters

• uid – str, uid of user

• gid – str, name of group

12 Chapter 3. Nextcloud-API

Page 17: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

Returns

remove_subadmin(uid, gid)Remove the subadmin rights for the user specified from the group specified

Parameters

• uid – str, uid of user

• gid – str, name of group

Returns

resend_welcome_mail(uid)Trigger the welcome email for this user again

Parameters uid – str, uid of user

Returns

class nextcloud.api_wrappers.UserLDAP(requester)Bases: nextcloud.base.WithRequester

API_URL = '/ocs/v2.php/apps/user_ldap/api/v1/config'

CONFIG_KEYS = ['ldapHost', 'ldapPort', 'ldapBackupHost', 'ldapBackupPort', 'ldapBase', 'ldapBaseUsers', 'ldapBaseGroups', 'ldapAgentName', 'ldapAgentPassword', 'ldapTLS', 'turnOffCertCheck', 'ldapUserDisplayName', 'ldapGidNumber', 'ldapUserFilterObjectclass', 'ldapUserFilterGroups', 'ldapUserFilter', 'ldapUserFilterMode', 'ldapGroupFilter', 'ldapGroupFilterMode', 'ldapGroupFilterObjectclass', 'ldapGroupFilterGroups', 'ldapGroupMemberAssocAttr', 'ldapGroupDisplayName', 'ldapLoginFilter', 'ldapLoginFilterMode', 'ldapLoginFilterEmail', 'ldapLoginFilterUsername', 'ldapLoginFilterAttributes', 'ldapQuotaAttribute', 'ldapQuotaDefault', 'ldapEmailAttribute', 'ldapCacheTTL', 'ldapUuidUserAttribute', 'ldapUuidGroupAttribute', 'ldapOverrideMainServer', 'ldapConfigurationActive', 'ldapAttributesForUserSearch', 'ldapAttributesForGroupSearch', 'ldapExperiencedAdmin', 'homeFolderNamingRule', 'hasMemberOfFilterSupport', 'useMemberOfToDetectMembership', 'ldapExpertUsernameAttr', 'ldapExpertUUIDUserAttr', 'ldapExpertUUIDGroupAttr', 'lastJpegPhotoLookup', 'ldapNestedGroups', 'ldapPagingSize', 'turnOnPasswordChange', 'ldapDynamicGroupMemberURL', 'ldapDefaultPPolicyDN']

SUCCESS_CODE = 200

create_ldap_config()Create a new and empty LDAP configuration

delete_ldap_config(config_id)Delete a given LDAP configuration

Parameters config_id (str) – User LDAP config id

Returns:

edit_ldap_config(config_id, data)Update a configuration with the provided values

You can find list of all config keys in get_ldap_config method response or in Nextcloud docs

Parameters

• config_id (str) – User LDAP config id

• data (dict) – config values to update

Returns:

get_ldap_agent_name(config_id)

get_ldap_agent_password(config_id)

get_ldap_attributes_for_group_search(config_id)

get_ldap_attributes_for_user_search(config_id)

get_ldap_backup_host(config_id)

get_ldap_backup_port(config_id)

get_ldap_base(config_id)

get_ldap_base_groups(config_id)

get_ldap_base_users(config_id)

3.2. NextCloud api wrappers 13

Page 18: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

get_ldap_cache_ttl(config_id)

get_ldap_config(config_id, show_password=None)Get all keys and values of the specified LDAP configuration

Parameters

• config_id (str) – User LDAP config id

• show_password (int) – 0 or 1 whether to return the password in clear text (default 0)

Returns:

get_ldap_config_id(idx=1)The LDAP config ID is a string. Given the number of the config file, return the corresponding string ID ifthe configuration exists.

Parameters idx – The index of the configuration. If a single configuration exists on the serverfrom the beginning, it is going to have index of 1.

Returns Configuration string or None

get_ldap_configuration_active(config_id)

get_ldap_default_ppolicy_dn(config_id)

get_ldap_dynamic_group_member_url(config_id)

get_ldap_email_attribute(config_id)

get_ldap_experienced_admin(config_id)

get_ldap_expert_username_attr(config_id)

get_ldap_expert_uuidgroup_attr(config_id)

get_ldap_expert_uuiduser_attr(config_id)

get_ldap_gid_number(config_id)

get_ldap_group_display_name(config_id)

get_ldap_group_filter(config_id)

get_ldap_group_filter_groups(config_id)

get_ldap_group_filter_mode(config_id)

get_ldap_group_filter_objectclass(config_id)

get_ldap_group_member_assoc_attr(config_id)

get_ldap_has_member_of_filter_support(config_id)

get_ldap_home_folder_naming_rule(config_id)

get_ldap_host(config_id)

get_ldap_last_jpeg_photo_lookup(config_id)

get_ldap_login_filter(config_id)

get_ldap_login_filter_attributes(config_id)

get_ldap_login_filter_email(config_id)

get_ldap_login_filter_mode(config_id)

get_ldap_login_filter_username(config_id)

14 Chapter 3. Nextcloud-API

Page 19: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

get_ldap_lowest_existing_config_id(lower_bound=1, upper_bound=10)Given (inclusive) lower and upper bounds, try to guess an existing LDAP config ID that corresponds to anindex within those bounds.

Parameters

• lower_bound – The lowest index of the configuration possible.

• upper_bound – The greatest index of the configuration possible.

Returns Configuration string or None

get_ldap_nested_groups(config_id)

get_ldap_override_main_server(config_id)

get_ldap_paging_size(config_id)

get_ldap_port(config_id)

get_ldap_quota_attribute(config_id)

get_ldap_quota_default(config_id)

get_ldap_tls(config_id)

get_ldap_turn_off_cert_check(config_id)

get_ldap_turn_on_password_change(config_id)

get_ldap_use_member_of_to_detect_membership(config_id)

get_ldap_user_display_name(config_id)

get_ldap_user_filter(config_id)

get_ldap_user_filter_groups(config_id)

get_ldap_user_filter_mode(config_id)

get_ldap_user_filter_objectclass(config_id)

get_ldap_uuid_group_attribute(config_id)

get_ldap_uuid_user_attribute(config_id)

ldap_cache_flush(config_id)Flush the cache, so the fresh LDAP DB data is used.

Implementation detail: This is performed by a fake update of LDAP cache TTL as indicated by

Parameters config_id (str) – User LDAP config id

set_ldap_agent_name(config_id, value)

set_ldap_agent_password(config_id, value)

set_ldap_attributes_for_group_search(config_id, value)

set_ldap_attributes_for_user_search(config_id, value)

set_ldap_backup_host(config_id, value)

set_ldap_backup_port(config_id, value)

set_ldap_base(config_id, value)

set_ldap_base_groups(config_id, value)

set_ldap_base_users(config_id, value)

3.2. NextCloud api wrappers 15

Page 20: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

set_ldap_cache_ttl(config_id, value)

set_ldap_configuration_active(config_id, value)

set_ldap_default_ppolicy_dn(config_id, value)

set_ldap_dynamic_group_member_url(config_id, value)

set_ldap_email_attribute(config_id, value)

set_ldap_experienced_admin(config_id, value)

set_ldap_expert_username_attr(config_id, value)

set_ldap_expert_uuidgroup_attr(config_id, value)

set_ldap_expert_uuiduser_attr(config_id, value)

set_ldap_gid_number(config_id, value)

set_ldap_group_display_name(config_id, value)

set_ldap_group_filter(config_id, value)

set_ldap_group_filter_groups(config_id, value)

set_ldap_group_filter_mode(config_id, value)

set_ldap_group_filter_objectclass(config_id, value)

set_ldap_group_member_assoc_attr(config_id, value)

set_ldap_has_member_of_filter_support(config_id, value)

set_ldap_home_folder_naming_rule(config_id, value)

set_ldap_host(config_id, value)

set_ldap_last_jpeg_photo_lookup(config_id, value)

set_ldap_login_filter(config_id, value)

set_ldap_login_filter_attributes(config_id, value)

set_ldap_login_filter_email(config_id, value)

set_ldap_login_filter_mode(config_id, value)

set_ldap_login_filter_username(config_id, value)

set_ldap_nested_groups(config_id, value)

set_ldap_override_main_server(config_id, value)

set_ldap_paging_size(config_id, value)

set_ldap_port(config_id, value)

set_ldap_quota_attribute(config_id, value)

set_ldap_quota_default(config_id, value)

set_ldap_tls(config_id, value)

set_ldap_turn_off_cert_check(config_id, value)

set_ldap_turn_on_password_change(config_id, value)

set_ldap_use_member_of_to_detect_membership(config_id, value)

set_ldap_user_display_name(config_id, value)

16 Chapter 3. Nextcloud-API

Page 21: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

set_ldap_user_filter(config_id, value)

set_ldap_user_filter_groups(config_id, value)

set_ldap_user_filter_mode(config_id, value)

set_ldap_user_filter_objectclass(config_id, value)

set_ldap_uuid_group_attribute(config_id, value)

set_ldap_uuid_user_attribute(config_id, value)

nextcloud.api_wrappers.WEBDAV_CLASSalias of nextcloud.api_wrappers.webdav.WebDAV

class nextcloud.api_wrappers.WebDAV(*args, **kwargs)Bases: nextcloud.base.WithRequester

API_URL = '/remote.php/dav/files'

assure_folder_exists(uid, folder_path)Create folder on Nextcloud storage, don’t do anything if the folder already exists. :param uid: uid of user:type uid: str :param folder_path: folder path :type folder_path: str

Returns:

assure_tree_exists(uid, tree_path)Make sure that the folder structure on Nextcloud storage exists :param uid: uid of user :type uid: str :paramfolder_path: The folder tree :type folder_path: str

Returns:

copy_path(uid, path, destination_path, overwrite=False)Copy file or folder to destination

Parameters

• uid (str) – uid of user

• path (str) – file or folder path to copy

• destionation_path (str) – destination where to copy

• overwrite (bool) – allow destination path overriding

create_folder(uid, folder_path)Create folder on Nextcloud storage

Parameters

• uid (str) – uid of user

• folder_path (str) – folder path

delete_path(uid, path)Delete file or folder with all content of given user by path

Parameters

• uid (str) – uid of user

• path (str) – file or folder path to delete

download_file(uid, path)Download file of given user by path File will be saved to working directory path argument must be validfile path Modified time of saved file will be synced with the file properties in Nextcloud

Exception will be raised if:

3.2. NextCloud api wrappers 17

Page 22: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

• path doesn’t exist,

• path is a directory, or if

• file with same name already exists in working directory

Parameters

• uid (str) – uid of user

• path (str) – file path

Returns None

list_favorites(uid, path=”)Set files of a user favorite

Parameters

• uid (str) – uid of user

• path (str) – file or folder path to make favorite

list_folders(uid, path=None, depth=1, all_properties=False)Get path files list with files properties for given user, with given depth

Parameters

• uid (str) – uid of user

• path (str/None) – files path

• depth (int) – depth of listing files (directories content for example)

• all_properties (bool) – list all available file properties in Nextcloud

Returns list of dicts if json_output list of File objects if not json_output

move_path(uid, path, destination_path, overwrite=False)Move file or folder to destination

Parameters

• uid (str) – uid of user

• path (str) – file or folder path to move

• destionation_path (str) – destination where to move

• overwrite (bool) – allow destination path overriding

set_favorites(uid, path)Set files of a user favorite

Parameters

• uid (str) – uid of user

• path (str) – file or folder path to make favorite

upload_file(uid, local_filepath, remote_filepath, timestamp=None)Upload file to Nextcloud storage

Parameters

• uid (str) – uid of user

• local_filepath (str) – path to file on local storage

18 Chapter 3. Nextcloud-API

Page 23: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

• remote_filepath (str) – path where to upload file on Nextcloud storage

• timestamp (int) – timestamp of upload file. If None, get time by local file.

upload_file_contents(uid, file_contents, remote_filepath, timestamp=None)Upload file to Nextcloud storage

Parameters

• uid (str) – uid of user

• file_contents (bytes) – Bytes the file to be uploaded consists of

• remote_filepath (str) – path where to upload file on Nextcloud storage

• timestamp (int) – mtime of upload file

3.2. NextCloud api wrappers 19

Page 24: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

20 Chapter 3. Nextcloud-API

Page 25: nextcloud-API Documentation

Python Module Index

nnextcloud.api_wrappers, 6nextcloud.NextCloud, 5

21

Page 26: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

22 Python Module Index

Page 27: nextcloud-API Documentation

Index

Aaccept_pending_federated_cloudshare()

(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

Activity (class in nextcloud.api_wrappers), 6add_group() (nextcloud.api_wrappers.Group

method), 7add_to_group() (nextcloud.api_wrappers.User

method), 11add_user() (nextcloud.api_wrappers.User method),

11API_URL (nextcloud.api_wrappers.Activity attribute), 6API_URL (nextcloud.api_wrappers.Apps attribute), 6API_URL (nextcloud.api_wrappers.Capabilities at-

tribute), 7API_URL (nextcloud.api_wrappers.FederatedCloudShare

attribute), 7API_URL (nextcloud.api_wrappers.Group attribute), 7API_URL (nextcloud.api_wrappers.GroupFolders

attribute), 8API_URL (nextcloud.api_wrappers.Notifications at-

tribute), 9API_URL (nextcloud.api_wrappers.Share attribute), 9API_URL (nextcloud.api_wrappers.User attribute), 11API_URL (nextcloud.api_wrappers.UserLDAP at-

tribute), 13API_URL (nextcloud.api_wrappers.WebDAV attribute),

17Apps (class in nextcloud.api_wrappers), 6assure_folder_exists()

(nextcloud.api_wrappers.WebDAV method), 17assure_tree_exists()

(nextcloud.api_wrappers.WebDAV method), 17

CCapabilities (class in nextcloud.api_wrappers), 6CONFIG_KEYS (nextcloud.api_wrappers.UserLDAP at-

tribute), 13copy() (nextcloud.NextCloud.WebDAVRequester

method), 5copy_path() (nextcloud.api_wrappers.WebDAV

method), 17create_folder() (nextcloud.api_wrappers.WebDAV

method), 17create_group_folder()

(nextcloud.api_wrappers.GroupFoldersmethod), 8

create_ldap_config()(nextcloud.api_wrappers.UserLDAP method),13

create_share() (nextcloud.api_wrappers.Sharemethod), 10

create_subadmin() (nextcloud.api_wrappers.Usermethod), 11

Ddecline_pending_federated_cloudshare()

(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

delete_accepted_federated_cloudshare()(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

delete_all_notifications()(nextcloud.api_wrappers.Notificationsmethod), 9

delete_group() (nextcloud.api_wrappers.Groupmethod), 7

delete_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 8

delete_ldap_config()(nextcloud.api_wrappers.UserLDAP method),13

delete_notification()(nextcloud.api_wrappers.Notificationsmethod), 9

delete_path() (nextcloud.api_wrappers.WebDAVmethod), 17

23

Page 28: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

delete_share() (nextcloud.api_wrappers.Sharemethod), 10

delete_user() (nextcloud.api_wrappers.Usermethod), 11

disable_app() (nextcloud.api_wrappers.Appsmethod), 6

disable_user() (nextcloud.api_wrappers.Usermethod), 12

download() (nextcloud.NextCloud.WebDAVRequestermethod), 5

download_file() (nextcloud.api_wrappers.WebDAVmethod), 17

Eedit_ldap_config()

(nextcloud.api_wrappers.UserLDAP method),13

edit_user() (nextcloud.api_wrappers.User method),12

enable_app() (nextcloud.api_wrappers.Appsmethod), 6

enable_user() (nextcloud.api_wrappers.Usermethod), 12

FFEDERATED (nextcloud.api_wrappers.FederatedCloudShare

attribute), 7FederatedCloudShare (class in

nextcloud.api_wrappers), 7

Gget_activities() (nextcloud.api_wrappers.Activity

method), 6get_app() (nextcloud.api_wrappers.Apps method), 6get_apps() (nextcloud.api_wrappers.Apps method), 6get_capabilities()

(nextcloud.api_wrappers.Capabilities method),7

get_connection_issues()(nextcloud.NextCloud.NextCloud method),5

get_federated_url()(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

get_group() (nextcloud.api_wrappers.Groupmethod), 7

get_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 8

get_group_folders()(nextcloud.api_wrappers.GroupFoldersmethod), 8

get_groups() (nextcloud.api_wrappers.Groupmethod), 7

get_known_federated_cloudshare()(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

get_ldap_agent_name()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_agent_password()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_attributes_for_group_search()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_attributes_for_user_search()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_backup_host()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_backup_port()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_base() (nextcloud.api_wrappers.UserLDAPmethod), 13

get_ldap_base_groups()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_base_users()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_cache_ttl()(nextcloud.api_wrappers.UserLDAP method),13

get_ldap_config()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_config_id()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_configuration_active()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_default_ppolicy_dn()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_dynamic_group_member_url()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_email_attribute()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_experienced_admin()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_expert_username_attr()

24 Index

Page 29: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_expert_uuidgroup_attr()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_expert_uuiduser_attr()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_gid_number()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_group_display_name()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_group_filter()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_group_filter_groups()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_group_filter_mode()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_group_filter_objectclass()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_group_member_assoc_attr()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_has_member_of_filter_support()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_home_folder_naming_rule()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_host() (nextcloud.api_wrappers.UserLDAPmethod), 14

get_ldap_last_jpeg_photo_lookup()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_login_filter()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_login_filter_attributes()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_login_filter_email()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_login_filter_mode()(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_login_filter_username()(nextcloud.api_wrappers.UserLDAP method),

14get_ldap_lowest_existing_config_id()

(nextcloud.api_wrappers.UserLDAP method),14

get_ldap_nested_groups()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_override_main_server()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_paging_size()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_port() (nextcloud.api_wrappers.UserLDAPmethod), 15

get_ldap_quota_attribute()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_quota_default()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_tls() (nextcloud.api_wrappers.UserLDAPmethod), 15

get_ldap_turn_off_cert_check()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_turn_on_password_change()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_use_member_of_to_detect_membership()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_user_display_name()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_user_filter()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_user_filter_groups()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_user_filter_mode()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_user_filter_objectclass()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_uuid_group_attribute()(nextcloud.api_wrappers.UserLDAP method),15

get_ldap_uuid_user_attribute()(nextcloud.api_wrappers.UserLDAP method),15

get_local_url() (nextcloud.api_wrappers.Share

Index 25

Page 30: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

method), 10get_notification()

(nextcloud.api_wrappers.Notificationsmethod), 9

get_notifications()(nextcloud.api_wrappers.Notificationsmethod), 9

get_share_info() (nextcloud.api_wrappers.Sharemethod), 10

get_shares() (nextcloud.api_wrappers.Sharemethod), 10

get_shares_from_path()(nextcloud.api_wrappers.Share method),10

get_subadmin_groups()(nextcloud.api_wrappers.User method),12

get_subadmins() (nextcloud.api_wrappers.Groupmethod), 8

get_user() (nextcloud.api_wrappers.User method),12

get_users() (nextcloud.api_wrappers.User method),12

grant_access_to_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 8

Group (class in nextcloud.api_wrappers), 7GroupFolders (class in nextcloud.api_wrappers), 8

Lldap_cache_flush()

(nextcloud.api_wrappers.UserLDAP method),15

list_accepted_federated_cloudshares()(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

list_favorites() (nextcloud.api_wrappers.WebDAVmethod), 18

list_folders() (nextcloud.api_wrappers.WebDAVmethod), 18

list_pending_federated_cloudshares()(nextcloud.api_wrappers.FederatedCloudSharemethod), 7

LOCAL (nextcloud.api_wrappers.Share attribute), 10

Mmake_collection()

(nextcloud.NextCloud.WebDAVRequestermethod), 5

move() (nextcloud.NextCloud.WebDAVRequestermethod), 5

move_path() (nextcloud.api_wrappers.WebDAVmethod), 18

NNextCloud (class in nextcloud.NextCloud), 5nextcloud.api_wrappers (module), 6nextcloud.NextCloud (module), 5Notifications (class in nextcloud.api_wrappers), 9

OOCSRequester (class in nextcloud.NextCloud), 5

Ppropfind() (nextcloud.NextCloud.WebDAVRequester

method), 5proppatch() (nextcloud.NextCloud.WebDAVRequester

method), 5

Rremove_from_group()

(nextcloud.api_wrappers.User method),12

remove_subadmin() (nextcloud.api_wrappers.Usermethod), 13

rename_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 8

report() (nextcloud.NextCloud.WebDAVRequestermethod), 5

resend_welcome_mail()(nextcloud.api_wrappers.User method),13

revoke_access_to_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 8

rtn() (nextcloud.NextCloud.OCSRequester method), 5rtn() (nextcloud.NextCloud.WebDAVRequester

method), 5

Sset_favorites() (nextcloud.api_wrappers.WebDAV

method), 18set_ldap_agent_name()

(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_agent_password()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_attributes_for_group_search()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_attributes_for_user_search()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_backup_host()(nextcloud.api_wrappers.UserLDAP method),15

26 Index

Page 31: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

set_ldap_backup_port()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_base() (nextcloud.api_wrappers.UserLDAPmethod), 15

set_ldap_base_groups()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_base_users()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_cache_ttl()(nextcloud.api_wrappers.UserLDAP method),15

set_ldap_configuration_active()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_default_ppolicy_dn()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_dynamic_group_member_url()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_email_attribute()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_experienced_admin()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_expert_username_attr()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_expert_uuidgroup_attr()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_expert_uuiduser_attr()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_gid_number()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_group_display_name()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_group_filter()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_group_filter_groups()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_group_filter_mode()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_group_filter_objectclass()

(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_group_member_assoc_attr()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_has_member_of_filter_support()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_home_folder_naming_rule()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_host() (nextcloud.api_wrappers.UserLDAPmethod), 16

set_ldap_last_jpeg_photo_lookup()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_login_filter()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_login_filter_attributes()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_login_filter_email()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_login_filter_mode()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_login_filter_username()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_nested_groups()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_override_main_server()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_paging_size()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_port() (nextcloud.api_wrappers.UserLDAPmethod), 16

set_ldap_quota_attribute()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_quota_default()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_tls() (nextcloud.api_wrappers.UserLDAPmethod), 16

set_ldap_turn_off_cert_check()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_turn_on_password_change()

Index 27

Page 32: nextcloud-API Documentation

nextcloud-API Documentation, Release 0.0.1

(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_use_member_of_to_detect_membership()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_user_display_name()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_user_filter()(nextcloud.api_wrappers.UserLDAP method),16

set_ldap_user_filter_groups()(nextcloud.api_wrappers.UserLDAP method),17

set_ldap_user_filter_mode()(nextcloud.api_wrappers.UserLDAP method),17

set_ldap_user_filter_objectclass()(nextcloud.api_wrappers.UserLDAP method),17

set_ldap_uuid_group_attribute()(nextcloud.api_wrappers.UserLDAP method),17

set_ldap_uuid_user_attribute()(nextcloud.api_wrappers.UserLDAP method),17

set_permissions_to_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 9

set_quota_of_group_folder()(nextcloud.api_wrappers.GroupFoldersmethod), 9

Share (class in nextcloud.api_wrappers), 9SUCCESS_CODE (nextcloud.api_wrappers.Activity at-

tribute), 6SUCCESS_CODE (nextcloud.api_wrappers.Apps at-

tribute), 6SUCCESS_CODE (nextcloud.api_wrappers.Capabilities

attribute), 7SUCCESS_CODE (nextcloud.api_wrappers.FederatedCloudShare

attribute), 7SUCCESS_CODE (nextcloud.api_wrappers.Group

attribute), 7SUCCESS_CODE (nextcloud.api_wrappers.GroupFolders

attribute), 8SUCCESS_CODE (nextcloud.api_wrappers.Notifications

attribute), 9SUCCESS_CODE (nextcloud.api_wrappers.Share at-

tribute), 10SUCCESS_CODE (nextcloud.api_wrappers.User at-

tribute), 11SUCCESS_CODE (nextcloud.api_wrappers.UserLDAP

attribute), 13

Uupdate_share() (nextcloud.api_wrappers.Share

method), 10upload_file() (nextcloud.api_wrappers.WebDAV

method), 18upload_file_contents()

(nextcloud.api_wrappers.WebDAV method), 19User (class in nextcloud.api_wrappers), 11UserLDAP (class in nextcloud.api_wrappers), 13

Vvalidate_share_parameters()

(nextcloud.api_wrappers.Share static method),11

WWebDAV (class in nextcloud.api_wrappers), 17WEBDAV_CLASS (in module nextcloud.api_wrappers),

17WEBDAV_CLASS (in module nextcloud.NextCloud), 5WebDAVRequester (class in nextcloud.NextCloud), 5

28 Index