Package: egnyte
Egnyte SDKThis is the official Python client library for Egnyte’s Public APIs.
For overview of the HTTP API, go tohttps://developers.egnyte.comGetting an API keyRegister onhttps://developers.egnyte.com/member/registerto get API key
for your Egnyte account. This key is required to generate an Egnyte OAuth
token.ExamplesInclude this libraryGenerate an access tokenCreate a client objectclient=egnyte.EgnyteClient({"domain":"apidemo.egnyte.com","access_token":"68zc95e3xv954u6k3hbnma3q"})Create a folderfolder=client.folder("/Shared/new").create(ignore_if_exists=True)Delete a folderclient.folder("/Shared/time to say goodbye").delete()Get a list of files in a folder, download a file, replace it’s contents, add a notefolder=client.folder("/Shared/foo that need to be bar")folder.list()forfile_objinfolder.files:withfile_obj.download()asdownload:data=download.read()# replace file contentsfile_obj.upload(data.replace(b"foo",b"bar"))file_obj.add_note("all occurrences of 'foo' replaced by 'bar'!")Get a list of files in a subfoldersfolder=client.folder("/Shared")folder.list()forfolder_objinfolder.folders:do_something(folder_obj)Upload a new file from local filefile_obj=client.file("/Private/smeagol/my precious")withopen("local path","rb")asfp:file_obj.upload(fp)Delete a filefile_obj.delete()Do a recursive downloadclient.bulk_download(['/Shared/a dir','/Shared/another dir'],'/home/smeagol/',overwrite=True)Do a recursive uploadclient.bulk_upload(['/tmp/some directory','/tmp/some file'],'/Shared/Marketing')Search for filesimportdatetimeresults=api.search.files('"some text" OR "other text"',folder='/Shared',modified_after=datetime.date(2015,1,15))Get and process events from serverevents=api.events.filter(folder='/Shared',suppress='user')old_events=events.list(events.latest_event_id-10,count=10)# get events in batchesfuture_events=iter(events)foreventinfuture_events:# polls server continously, iterator over single events, iterator will never enddo_something(event)ifcondition(event):breakFull documentationThe docs subdirectory contains just the source for the documentation.
You can read the documentation athttp://egnyte.github.io/python-egnyte-docs/Command lineIf you’re using implicit flow, you’ll need to provide access token directly.
If you’re using API token with resource flow, you can generate API access token using command line options.
See the full documentation or install, then use:python-megnyte-hCreate configurationConfiguration file will be created in ~/.egnyte/config.jsonpython-megnyteconfigcreate-dDOMAIN[-lLOGIN][-pPASSWORD]-kAPI_KEY[-tACCESS_TOKEN][-TTIMEOUT]Set request timeoutpython-megnyteconfigupdate--timeoutTIMEOUT_INTEGERDependenciesThis library depends on:requests 2.13.0 or later - for HTTPS callssix 1.10.0 or later - for Python 2 and 3 compatibility using same
sourceThread safetyEach client object should be used from one thread at a time. This
library does no locking of it’s own - it is responsibility of the caller
to do so if necessary.Running testsTests can be run with nose or trial directly on the egnyte package, or
from setup.py:pythonsetup.pytestorpython-munittestdiscoverIn order to run tests, you need to create test configuration file: ~/.egnyte/test_config.json{"access_token":"access token you received after passing the auth flow","api_key":"key you received after registering your developer account","domain":"your Egnyte domain, e.g. example.egnyte.com","login":"username of Egnyte admin user","password":"password of the same Egnyte admin user"}You can create this file manually or with following command:python-megnyte-ctest\_config.jsonconfigcreate-k<API_Key>-d<domain>-l<username>-p<password>-t<access_token>Tests will be run against your domain on behalf on admin user.Please refer tohttps://developers.egnyte.com/docs/read/Public_API_Authentication#Internal-Applicationsfor information
about how to generate access token.Helping with developmentPlease report any problems you find toapi-support@egnyte.comorpint@egnyte.comIf you’d like to fix something yourself, please fork this repository,
commit the fixes and updates to tests, then set up a pull request with
information what you’re fixing.Please remember to assign copyright of your fixes to Egnyte or make them
public domain so we can legally merge them.