Skip to main content

DOIP Client Library - Python Version

Project description

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.

Project details


Download files

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

Source Distribution

cnri_doip_client-1.1.0.tar.gz (526.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cnri_doip_client-1.1.0-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file cnri_doip_client-1.1.0.tar.gz.

File metadata

  • Download URL: cnri_doip_client-1.1.0.tar.gz
  • Upload date:
  • Size: 526.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for cnri_doip_client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 dab0f7a7f8b825c89b568a22ac16526a9c8ce569c2a80ca387c104144a34dbdc
MD5 cdd36e349b137bbf8e85a6b5bb663f49
BLAKE2b-256 a8dd8a58d4cf26c9cbef6e58b529adbdcf7ad9b32b1a3e43a9b46b8f3b42faaa

See more details on using hashes here.

File details

Details for the file cnri_doip_client-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cnri_doip_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90dae5849cd0a7d91cef3ec199bb577781e19b886a5d43dd47f35aa716718c00
MD5 5676cd0f00a6b6c730cdd6608198784b
BLAKE2b-256 f30e52cd8c3e65e13be8687dc54f9f58049a2cbeecd5292086628622e6b10537

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page