Skip to main content

DOIP Client Library - Python Version

A Python client library for the Digital Object Interface Protocol (DOIP).

This DOIP Client Library can be used to develop Python applications that are based on DOIP. It provides a set of classes for interacting with DOIP servers, including methods for making requests and handling responses.

Requirements

Since this is a client library, you will need a DOIP service to connect to. The library itself does not provide a DOIP service. For testing purposes, you can use a local service that implements DOIP, such as Cordra. Setting up such a service is beyond the scope of this README.

This library requires Python 3.12 or later.

Installation

pip install cnri_doip_client

Usage

Create a client instance using the DOIP native TCP interface:

import cnri_doip_client as doip_client

service_info = doip_client.ServiceInfo(ip_address="localhost", port=9000)
client = doip_client.StandardDoipClient(service_info=service_info)

The DOIP API for HTTP Clients is also supported:

import cnri_doip_client as doip_client

client = doip_client.StandardDoipClient("https://localhost:8443/doip"))

Here is an example of searching a Cordra server for all Schema objects, printing out their IDs and names:

results = client.search('type:Schema')
print(f'Number of results: {results.size}')
for result in results:
    print(f'{result.id}: {result.attributes["content"]["name"]}')

Here is an example of retrieving a specific object by ID:

import json
result = client.retrieve('20.500.123/1')
print(json.dumps(result.attributes["content"], indent=2))

Here is an example of creating, updating, and deleting an object. The client is created with a username and password which is used for each request:

import cnri_doip_client as doip_client

password_auth_info = doip_client.PasswordAuthenticationInfo('username', 'password')
service_info = doip_client.ServiceInfo(ip_address="localhost", port=9000)
client = doip_client.StandardDoipClient(
    service_info=service_info, authentication=password_auth_info
)

dobj = doip_client.DigitalObject(
    type="Document",
    attributes={
        "content": {
          "name": 'Example Document'
        }
      }
)
dobj = client.create(dobj)
print(dobj.id)
dobj.attributes["content"]["name"] = 'Updated Example Document'
dobj = client.update(dobj)
print(dobj.attributes["content"]["name"])
client.delete(dobj.id)
dobj = client.retrieve(dobj.id)
print('Delete successful' if dobj is None else 'Error: Object found after deletion')
client.close()

For more information on how to use this library, see the API documentation. You can also read the DOIP Specification for more information about DOIP and its various components; Cordra documentation also includes sections on DOIP and the DOIP API for HTTP Clients.

Metadata

Release files for cnri-doip-client 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnri-doip-client 1.1.0
File Size Uploaded
cnri_doip_client-1.1.0.tar.gz 526.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cnri-doip-client 1.1.0
File Interpreter ABI Platform
cnri_doip_client-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 572.3 kB

Release files / cnri_doip_client-1.1.0.tar.gz

Download URL cnri_doip_client-1.1.0.tar.gz
Size 526.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dab0f7a7f8b825c89b568a22ac16526a9c8ce569c2a80ca387c104144a34dbdc
BLAKE2b-256 checksum
How to use checksums
a8dd8a58d4cf26c9cbef6e58b529adbdcf7ad9b32b1a3e43a9b46b8f3b42faaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / cnri_doip_client-1.1.0-py3-none-any.whl

Download URL cnri_doip_client-1.1.0-py3-none-any.whl
Size 46.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90dae5849cd0a7d91cef3ec199bb577781e19b886a5d43dd47f35aa716718c00
BLAKE2b-256 checksum
How to use checksums
f30e52cd8c3e65e13be8687dc54f9f58049a2cbeecd5292086628622e6b10537
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page