Giter VIP home page Giter VIP logo

pyncclient's Introduction

Python client library for nextCloud

This is a fork of https://github.com/owncloud/pyocclient to provide compatibility with nextCloud, this client will not maintain compatibility to ownCloud.

Features

General information

  • retrieve information about nextCloud instance (e.g. version, host, URL, etc.)

Accessing files

  • basic file operations like getting a directory listing, file upload/download, directory creation, etc
  • read/write file contents from strings
  • upload with chunking and mtime keeping
  • upload whole directories
  • directory download as zip
  • access files from public links
  • upload files to files drop link target

Sharing (OCS Share API)

  • share a file/directory via public link
  • share a file/directory with another user or group
  • unshare a file/directory
  • check if a file/directory is already shared
  • get information about a shared resource
  • update properties of a known share

Apps (OCS Provisioning API)

  • enable/disable apps
  • retrieve list of enabled apps

Users (OCS Provisioning API)

  • create/delete users
  • create/delete groups
  • add/remove user from groups

App data

  • store app data as key/values using the privatedata OCS API

Requirements

  • Python >= 2.7 or Python >= 3.5
  • requests module (for making HTTP requests)

Installation

Automatic installation with pip:

$ pip install pyncclient

Manual installation of development version with git:

$ pip install requests
$ git clone https://github.com/pragmaticindustries/pyncclient.git
$ cd pyncclient
$ python setup.py install

Usage

Example for uploading a file then sharing with link:

import nextcloud_client

nc = nextcloud_client.Client('http://domain.tld/nextcloud')

nc.login('user', 'password')

nc.mkdir('testdir')

nc.put_file('testdir/remotefile.txt', 'localfile.txt')

link_info = nc.share_file_with_link('testdir/remotefile.txt')

print("Here is your link: " + link_info.get_link())

Example for uploading a file to a public shared folder:

import nextcloud_client

public_link = 'http://domain.tld/nextcloud/A1B2C3D4'

nc = nextcloud_client.Client.from_public_link(public_link)
nc.drop_file('myfile.zip')

Example for downloading a file from a public shared folder with password:

import nextcloud_client

public_link = 'http://domain.tld/nextcloud/A1B2C3D4'
folder_password = 'secret'

nc = nextcloud_client.Client.from_public_link(public_link, password=folder_password)
nc.get_file('/sharedfile.zip', 'download/destination/sharedfile.zip')

Running the unit tests

To run the unit tests, create a config file called "nextcloud_client/test/config.py". There is a config file example called "nextcloud_client/test/config.py.sample". All the information required is in that file. It should point to a running nextCloud instance to test against.

You might also need to install the unittest-data-provider package:

$ pip install unittest-data-provider

Then run the script "runtests.sh":

$ ./runtests.sh

Building the documentation

To build the documentation, you will need to install Sphinx and docutil. Then run the following commands:

$ sphinx-apidoc -e -f -o docs/source nextcloud_client/ nextcloud_client/test
$ cd docs
$ make html

You can then find the documentation inside of "doc/build/html".

pyncclient's People

Contributors

amicitas avatar b1-luettje avatar blizzz avatar cclauss avatar cosenal avatar erikpel avatar freddii avatar gomez avatar individual-it avatar jamescooke avatar jvillafanez avatar managai avatar marconastasi avatar mrwunderbar666 avatar nickvergessen avatar nikaro avatar nikoschondros avatar pvince81 avatar remjg avatar rullzer avatar sergiobertolinsg avatar viraj96 avatar ziererf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.