Skip to main content

JsonActionClient

A Python wrapper for the FairCom JSON Action API.

What it does

This class provides a Python "client" that manages logging into the server (createSession), logging out of the server (deleteSession), and provides an easy way to POST to the server and access the session authToken.

When your program closes, any client you created will automatically log out of the FairCom server.

Exceptions are caught and re-raised as a JsonActionError (or a derived exception).

What it does not do

The client does not perform any "keepalive" operations. By default, the session will expire after 30 seconds. This timeout can be set by using the "timeout" parameter when instantiating the client.

Installation

pip install faircom-json-action-client

Usage

Both secure and insecure connections are possible. All certificate files should be PEM-encoded X.509 certificates.

Example mTLS usage:

from json_action_client import JsonActionClient

client = JsonActionClient( "https://127.0.0.1:8444/api", ca_cert = "/FairCom/ca.crt", cert_file = "/FairCom/client.pem" )
client.login()

with client:
    list_databases_json = client.build_basic_request( api = "db", action = "listDatabases" )
    response = client.post_json( list_databases_json )
    print( f"Response: {response}" )

This connection is considered the most secure and when done properly will be adequate to use over public networks. In the example above a client certificate and CA certificate are used to enable mutual-TLS (mTLS) with the FairCom server.

The CA certificate (ca.crt in this example) must have signed both the client certificate (client.pem) and the server certificate. This provides TLS encryption for client communications and user-level access controls on the server (the client certificate CN must match a user account on the server). Client certificates can be invalidated by disabling the account on the server, avoiding the hassle of CRLs.

More details on FairCom TLS can be found here.

Example TLS (one-sided) and credential usage:

from json_action_client import JsonActionClient

client = JsonActionClient( "https://127.0.0.1:8443/api", ca_cert = "/FairCom/ca.crt" )
client.login( "admin", "ADMIN" )

with client:
    list_databases_json = client.build_basic_request( api = "db", action = "listDatabases" )
    response = client.post_json( list_databases_json )
    print( f"Response: {response}" )

This connection is also considered secure enough to use over public networks when properly configured. Ensure the FairCom server TLS settings are adequate for modern threats (particularly the allowed cipher suites).

Example insecure usage (credentials without TLS):

from json_action_client import JsonActionClient

client = JsonActionClient( "http://127.0.0.1:8080/api" )
client.login( "admin", "ADMIN" )

with client:
    list_databases_json = client.build_basic_request( api = "db", action = "listDatabases" )
    response = client.post_json( list_databases_json )
    print( f"Response: {response}" )

An insecure connection should only be used on private networks where security is guaranteed via other means (e.g., an enterprise-grade firewall).

Links

Package info on PyPI

Source code on GitHub

Notes

  • This project is a work in progress and may change at any time.
  • Breaking changes for versions at 1.0 or higher will always result in a new major version.
  • I try to use type hints wherever possible. Please report undocumented raises.

Release files for faircom-json-action-client 0.0.13

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

Source distribution (sdist)

Source distribution for faircom-json-action-client 0.0.13
File Size Uploaded
faircom_json_action_client-0.0.13.tar.gz 19.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for faircom-json-action-client 0.0.13
File Interpreter ABI Platform
faircom_json_action_client-0.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / faircom_json_action_client-0.0.13.tar.gz

Download URL faircom_json_action_client-0.0.13.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
33a7996c9c2d89bfac3f31ff82d07b9bce068eee15bfd6c7241a935ca1a00732
BLAKE2b-256 checksum
How to use checksums
da205d88f056eb3bd8965a19535253526d59bd1a563da53cc6bf80142a5d11c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / faircom_json_action_client-0.0.13-py3-none-any.whl

Download URL faircom_json_action_client-0.0.13-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8701a2dc929a970f734051bb5fb14c1c8a7df3e45ba5cbf343a0b54c02fd043
BLAKE2b-256 checksum
How to use checksums
35dae011820aa5ad0fcb37045ba155d7673c418c2f80e98bdef0c9e5a9d7b774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.0.13 This release

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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