Introduction


The JS7 Python Client can be used to perform deployment operations and status operations:

  • Controller Deployment
    • Initial Operation: register, unregister
    • Agent Management: store, delete, deploy, revoke
  • Controller Status Operations
    • Controller Operations: terminate, restart, cancel, status
    • Agent Operations: enable, disable, status, reset
    • Cluster Operations on Controller and Agents: switch-over
  • Workflow Deployment
    • Objects: export, import, deploy, release, store, remove
    • Trash: restore, delete
  • Workflow Status Operations
    • Orders: add, cancel, suspend, resume, let run, transfer
    • Workflows: suspend, resume
    • Jobs and Instructions: stop, unstop, skip, unskip
  • Daily Plan Operations
    • Orders: add, submit, cancel, delete, generate, copy, modify
    • Submissions: delete
    • Projections: get calendar, get date, create
  • JOC Cockpit Status Operations
    • status, check license

Installation

Requirements

  • For encryption/decryption operations Java 17 or newer is required. All other operations do not require Java.
  • Currently, Windows for ARM is not supported because the Cryptography package required for signing inventory configurations is not compiled for this platform. All other platforms should work.

    • Possible Workaround: Advanced users may attempt to compile the required dependencies manually for Windows on ARM. This requires building the cryptography package from source and ensuring that all required build tools and libraries are available for the platform. Detailed instructions for building the package can be found in the official documentation: https://cryptography.io/en/stable/installation

Installation with Pip

The JS7 Python Client can be installed directly via PyPI using the following command:

pip install js7-client-python

This installs the latest release directly into the existing Python environment.

(info) The PyPi package can be found here: PyPI - js7-client-python.

Quick Start

The following example shows how to create a client instance and perform an operation.

(info) All client methods include a docstring that explains the parameters. Depending on the IDE used, this can be easily displayed, e.g., by hovering over the method.

Client Initialization

Client initialization begins with configuring the JOC Cockpit's REST Web Service API endpoint and the user’s credentials.

import js7

client = js7.Client(
    http_config=js7.model.HTTPConfiguration(
        host="192.168.1.14",
        port=4443
    ),
    auth_config=js7.model.AuthConfiguration(
        basic_auth=js7.model.BasicAuth(
            username="root",
            password="changeit"
        )
    )
)

SSL and Certificate-Based Authentication

The code snippet above shows authentication using Basic Auth.
However, the JS7 Python Client also supports certificate-based authentication and client certificates for HTTPS connections.

client = js7.Client(
    http_config=js7.model.HTTPConfiguration(
        host="192.168.1.14",
        port=4446,
        ssl=True,
        cafile_path="./certificate.crt"
    ),
    auth_config=js7.model.AuthConfiguration(
        cert_auth=js7.model.CertAuth(
            certfile_path="./client.crt",
            keyfile_path="./client.key"
        )
    )
)

Import Inventory Configurations

A common use case is importing inventory configurations into JS7 JOC Cockpit.
We use the previously created client instance to import configurations.

ok = client.inventory.manage.import_configurations(
    file_path="/path/to/file/or/folder",
    inventory_target_folder="/test-folder"
)

print(f"Operation successful: {ok}")

Namespaces

The Client class follows the domains of the JS7 JOC  Cockpit REST Web Service API, but groups its methods into the following namespaces:

  • Manage: Used to manage configurations and resources, such as importing, updating, or removing them

  • Operate: Used to control run-time behavior, such as resuming a workflow or canceling an order

  • Deploy: Used to deploy configurations, such as workflows

Namespace Example
import js7

# Initialize the client
client = js7.Client(...)

# Import inventory configurations into JS7 JOC Cockpit
client.inventory.manage.import_configurations(...)

# Create a deployment for configurations stored in the inventory to the specified Controller
client.inventory.deploy.configurations(...)

# Cancel orders on the specified Controller
client.order.operate.cancel_orders(...)

Resources