Package: docuware-client
docuware-clientThis is a client library for the REST API ofDocuWareDMS. SinceDocuWare's documentationregarding the REST API is very sparse (at the
time these lines were written), this client serves only a part of the API's
functionality.Please keep in mind:This software is not related to DocuWare.It is a work
in progress, may yield unexpected results, and almost certainly contains bugs.[!NOTE] Version 0.4.x has only been partially tested and is subject to
extensive refactoring. If you require a better tested release, it is
recommended that you use 0.2.x or 0.3.x. However, I recommend that you try
the latest 0.4 release first.UsageFirst you have to log in and create a persistent session:importjsonimportpathlibimportdocuwaredw=docuware.Client("http://localhost")session=dw.login("username","password","organization")withopen(".session","w")asf:json.dump(session,f)From then on you have to reuse the session, otherwise you will be locked out of
the DocuWare service for a period of time (10 minutes or even longer). As the
session cookie may change on subsequent logins, update the session file on
every login.session_file=pathlib.Path(".session")ifsession_file.exists():withopen(session_file)asf:session=json.load(f)else:session=Nonedw=docuware.Client("http://localhost")session=dw.login("username","password","organization",cookiejar=session)withopen(session_file,"w")asf:json.dump(session,f)Iterate over the organizations and file cabinets:fororgindw.organizations:print(org)forfcinorg.file_cabinets:print("   ",fc)If you already know the ID or name of the objects, you can also access them
directly.org=dw.organization("1")fc=org.file_cabinet("Archive")Now some examples of how to search for documents. First you need a search
dialog:# Let's use the first one:dlg=fc.search_dialog()# Or a specific search dialog:dlg=fc.search_dialog("Default search dialog")Each search term consists of a field name and a search pattern. Each search
dialog knows its fields:forfieldindlg.fields.values():print("Id    =",field.id)print("Length=",field.length)print("Name  =",field.name)print("Type  =",field.type)print("-------")Let's search for some documents:# Search for DOCNO equal to '123456':forresultindlg.search("DOCNO=123456"):print(result)# Search for two patterns alternatively:forresultindlg.search(["DOCNO=123456","DOCNO=654321"],operation=docuware.OR):print(result)# Search for documents in a date range (01-31 January 2023):forresultindlg.search("DWSTOREDATETIME=2023-01-01T00:00:00,2023-02-01T00:00:00")print(result)Please note that search terms may also contain metacharacters such as*,(,), which may need to be escaped when searching for these characters
themselves.forresultindlg.search("DOCTYPE=Invoice\\(incoming\\)"):print(result)Search terms can be as simple as a single string, but can also be more complex.
The following two queries are equivalent:dlg.search(["FIELD1=TERM1,TERM2","FIELD2=TERM3"])dlg.search({"FIELD1":["TERM1","TERM2"],"FIELD2":["TERM3"]})The result of a search is always an iterator over the search results, even if
no result was obtained. Each individual search result holds adocumentattribute, which gives access to the document in the archive. The document
itself can be downloaded as a whole or only individual attachments.forresultindlg.search("DOCNO=123456"):doc=result.document# Download the complete document ...data,content_type,filename=doc.download(keep_annotations=True)docuware.write_binary_file(data,filename)# ... or individual attachments (or sections, as DocuWare calls them)forattindoc.attachments:data,content_type,filename=att.download()docuware.write_binary_file(data,filename)Create data entry in file cabinet:data={"FIELD1":"value1","FIELD2":"value2",}response=fc.create_data_entry(data)Subject to rewrite:Update data fields of document. The search parameter must
return a single document. Use a loop to execute this function on multiple
documents:fields={"FIELD1":"value1","FIELD2":99999}response=fc.update_data_entry(["FIELD1=TERM1,TERM2","FIELD2=TERM3"],user_fields)Delete documents:dlg=fc.search_dialog()forresultindlg.search(["FIELD1=TERM1,TERM2","FIELD2=TERM3"]):document=result.documentdocument.delete()Users and groups of an organisation can be accessed and managed:# Iterate over the list of users and groups:foruserinorg.users:print(user)forgroupinorg.groups:print(group)# Find a specific user:user=org.users["John Doe"]# or: org.users.get("John Doe")# Add a user to a group:group=org.groups["Managers"]# or: org.groups.get("Managers")group.add_user(user)# oruser.add_to_group(group)# Deactivate user:user.active=False# or True to activate user# Create a new user:user=docuware.User(first_name="John",last_name="Doe")org.users.add(user,password="123456")CLI usageThis package also includes a simple CLI program for collecting information
about the archive and searching and downloading documents or attachments.First you need to log in:$dw-clientlogin--urlhttp://localhost/--username"Doe, John"--passwordFooBar--organization"Doe Inc."The credentials and the session cookie are stored in the.credentialsand.sessionfiles in the current directory.Of course,--helpwill give you a list of all options:$dw-client--helpSome search examples (Bash shell syntax):$dw-clientsearch--file-cabinetArchiveCustomer=Foo\*$dw-clientsearch--file-cabinetArchiveDocNo=123456"DocType=Invoice \\(incoming\\)"$dw-clientsearch--file-cabinetArchiveDocDate=2022-02-14Downloading documents:$dw-clientsearch--file-cabinetArchiveCustomer=Foo\*--downloaddocument--annotationsDownloading attachments (or sections):$dw-clientsearch--file-cabinetArchiveDocNo=123456--downloadattachmentsSome information about your DocuWare installation:$dw-clientinfoListing all organizations, file cabinets and dialogs at once:$dw-clientlistA more specific list, only one file cabinet:$dw-clientlist--file-cabinetArchiveYou can also display a (partial) selection of the contents of individual fields:$dw-clientlist--file-cabinetArchive--dialogcustom--fieldDocNoFurther readingEntry point toDocuWare's official documentationof the REST API.Notable endpoint:/DocuWare/Platform/Content/PlatformLinkModel.pdfLicenseThis work is released under the BSD 3 license. You may use and redistribute
this software as long as the copyright notice is preserved.