Skip to main content

Python client for the Mayan EDMS REST API.

Project description

Mayan API Client

Python client for the Mayan EDMS REST API.

  • Free software: ISC license

Installation

Install from PyPI:

pip install mayan-api_client

Usage

This is a thin wrapper of the slumber API client. Use the <app>.<resource>.<verb> nomeclature.

Examples:

from mayan_api_client import API

api = API(host='http://127.0.0.1:8000', username='admin', password='password')

Show general information of the connected Mayan EDMS server:

api._info

{u'contact': u'roberto.rosario@mayan-edms.com',
 u'description': u'Free Open Source Document Management System.',
 u'license': u'Apache 2.0',
 u'licenseUrl': u'http://www.apache.org/licenses/LICENSE-2.0.html',
 u'title': u'Mayan EDMS API Documentation'}

Show a list of all available apps:

api._apps

[u'checkouts',
 u'document_indexing',
 u'documents',
 u'dynamic_search',
 u'folders',
 u'metadata',
 u'ocr',
 u'permissions',
 u'rest',
 u'sources',
 u'tags',
 u'user_management']

Create a document type:

api.documents.document_types.post({'label': 'new document type'})

{u'delete_time_period': 30,
 u'delete_time_unit': u'days',
 u'documents': u'http://127.0.0.1:8000/api/documents/document_types/2/documents/',
 u'documents_count': 0,
 u'id': 2,
 u'label': u'new document type',
 u'trash_time_period': None,
 u'trash_time_unit': None,
 u'url': u'http://127.0.0.1:8000/api/documents/document_types/2/'}

Upload a new document:

with open('/tmp/test_document.pdf') as file_object:
    response = api.documents.documents.post({'document_type': 2}, files={'file': file_object})

print response

{u'label': u'test_document.pdf', u'document_type': 2, u'description': u'', u'language': u'eng', u'id': 2}

Get a list of all documents:

api.documents.documents.get()

{u'count': 1,
 u'next': u'http://127.0.0.1:8000/api/documents/documents/?page=2',
 u'previous': None,
 u'results': [{u'date_added': u'2016-02-02T23:06:44.880732Z',
   u'description': u'',
   u'document_type': u'http://127.0.0.1:8000/api/documents/document_types/2/',
   u'document_type_label': u'Default',
   u'id': 2,
   u'label': u'test_document.pdf',
   u'language': u'eng',
   u'latest_version': {u'checksum': u'452a6e59f3320f99bfe88b5f7efb0b9323df20457c19c320efce2b9404b96d82',
    u'comment': u'',
    u'document': u'http://127.0.0.1:8000/api/documents/documents/2/',
    u'encoding': u'binary',
    u'file': u'1a8b87de-bca9-416a-beb2-49d817625d56',
    u'mimetype': u'application/pdf',
    u'pages': [{u'document_version': u'http://127.0.0.1:8000/api/documents/document_version/2/',
      u'image': u'http://127.0.0.1:8000/api/documents/document_page/2/image/',
      u'page_number': 1,
      u'url': u'http://127.0.0.1:8000/api/documents/document_page/2/'}],
    u'revert': u'http://127.0.0.1:8000/api/documents/document_version/2/revert/',
    u'timestamp': u'2016-02-02T23:06:45.318494Z',
    u'url': u'http://127.0.0.1:8000/api/documents/document_version/2/'},
   u'url': u'http://127.0.0.1:8000/api/documents/documents/2/',
   u'uuid': u'b1973f42-41f2-41e7-b812-07fa929689ec',
   u'versions': u'http://127.0.0.1:8000/api/documents/documents/19/versions/'},]
}

Get second page of a list of all documents:

api.documents.documents.get(page=2)

Get documents by id:

api.documents.documents(2).get()

Add a document to a folder:

api.folders.folders(1).documents.post({'document': 2})

{u'document': 2}

Credits

Roberto Rosario

History

0.5.0 (2016-1-22)

  • Initial release.

Project details


Release history Release notifications

This version
History Node

0.5.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
mayan_api_client-0.5.0-py2.py3-none-any.whl (6.3 kB) Copy SHA256 hash SHA256 Wheel 2.7 Feb 2, 2016
mayan-api_client-0.5.0.tar.gz (6.2 kB) Copy SHA256 hash SHA256 Source None Feb 2, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page