The following examples serve as a guide for using the JS7 Python Client.
They can be useful for performing initial operations but do not represent the full functionality of the JS7 Python Client.

Order Management

Cancel All Orders

orders = client.order.manage.get_orders(
    controller_id="primary-controller",
    filter=js7.model.GetOrderFilter()
)

ok = client.order.operate.cancel_orders(
    controller_id="primary-controller", 
    workflow_paths=[o.workflow_path for o in orders]
)
print(f"Operation successful: {ok}")


IAM Management

Create Identity Service and User

ok = client.iam.manage.store_identity_service(
    identity_service=js7.model.IdentityService(
        identity_service_name="TEST-IDENTITY-SERVICE",
        identity_service_type="CERTIFICATE",
        service_authentication_scheme="SINGLE-FACTOR"
    )
)
print(f"Operation 'store_identity_service' successful: {ok}")

ok = client.iam.manage.store_role(
    identity_service_name="TEST-IDENTITY-SERVICE",
    role_name="test-role"
)
print(f"Operation 'store_role' successful: {ok}")

ok = client.iam.manage.store_account(
    account=js7.model.Account(
        account_name="test-user",
        identity_service_name="TEST-IDENTITY-SERVICE",
        password="changeit",
        roles=["test-role"]
    )
)
print(f"Operation 'store_account' successful: {ok}")


Controller Management

Register a Controller

ok = client.controller.manage.register_controller(
    url="http://primary-controller-service:4444",
    title="PRIMARY",
    role="STANDALONE"
)
print(f"Operation 'register_controller' successful: {ok}")


Agent Management

Store and Deploy a Standalone Agent

ok = client.agent.manage.store_standalone_agents(
    controller_id="primary-controller",
    agents=[
        js7.model.StoreAgent(
            url="http://primary-agent-service:4445",
            id="primary-agent",
            name="primary-agent",
            aliases=["primary"]
        )
    ]
)
print(f"Operation 'store_standalone_agents' successful: {ok}")

ok = client.agent.deploy.standalone_agents(
    controller_id="primary-controller",
    agent_ids=["primary-agent"]
)
print(f"Operation 'deploy.standalone_agents' successful: {ok}")