Skip to main content

DecisionRulesPy

VERSION 3 CONTAINS MAJOR CHANGES IN API INTERFACES AND NOW SUPPORTS RULEFLOWS CRUD

A simple library that allows you to easily connect to DecisionRules.io from your application.

Usage

  • Solver (DecisionTables, ScriptRules, RuleFlow)
  • Management API (CRUD operations on DecisionTables and RuleFlows)

1 - Solver

Solver is designed for solving rules made in DecisionRules application.

1.1 - Defining solver init

Before you start solving rules you need to setup an SolverApi instance. How to do so is shown below.

import decisionrules

async def solver_test():
    solver = decisionrules.SolverApi(solver_api_key)

1.2 - Defining solver method with data

Solver method expects 5 arguments

  • SolverType - enum value - mandatory
  • RuleId - str - mandatory
  • Data - dict or json str - mandatory
  • SolverStrategy - enum value - mandatory
  • Version - str - optional
async def solver_test():
    data = {"say": "Hello from python"}

    solver = decisionrules.SolverApi(api_key)

    # SolverType enum defines type of solver (Rule or Compostion)
    response = await solver.solve(decisionrules.SolverType.RULE, get_rule, data, decisionrules.SolverStrategies.STANDARD)

    response2 = await solver.solve(decisionrules.SolverType.RULEFLOW, compo_rule, data, decisionrules.SolverStrategies.STANDARD)

1.3 Solver with custom domain

For using custom domain just add CustomDomain instance to the init method with url and protocol parameters.

async def solver_test():
    data = {"say": "Hello from python"}

    solver = decisionrules.SolverApi(api_key, decisionrules.CustomDomain("YOUR_URL", decisionrules.Protocols.HTTPS))
    
    response = await solver.solve(decisionrules.SolverType.RULE, get_rule, data, decisionrules.SolverStrategies.STANDARD)

    response2 = await solver.solve(decisionrules.SolverType.RULEFLOW, compo_rule, data, decisionrules.SolverStrategies.STANDARD)

2 - Management API

Management api is accessible via ManagementApi and required management api key that you can obtain in api key section in DecisionRules app.

Data for ruleflow import methods are represented as an array where index0 = RF, and index1...indexn are DTs

async def management_api_test():
    manager = decisionrules.ManagementApi(mng_key)

    #Or with custom domain

    manager = decisionrules.ManagementApi(mng_key, decisionrules.CustomDomain("YOUR_URL", decisionrules.Protocols.HTTPS))

2.1 Management API usage example

async def management_api_test():
    manager = decisionrules.ManagementApi(mng_key)

    await manager.get_rule(get_rule)
    await manager.get_rule(get_rule, "1")
    await manager.get_space(get_space)

    await manager.update_rule(put_rule, "1", put_data)
    await manager.create_rule(post_rule, post_data)
    await manager.delete_rule(delete_rule, "1")

    await manager.create_ruleflow(new_ruleflow)
    await manager.get_ruleflow(id)
    await manager.get_ruleflow(id, 1)
    await manager.update_ruleflow(id, 1, ruleflow)
    await manager.export_ruleflow(id, 1)
    await manager.export_ruleflow(id)
    await manager.import_ruleflow([new_ruleflow_with_dt], 1,)
    await manager.import_ruleflow(id, 1, [new_ruleflow_with_dt])
    await manager.import_ruleflow([new_ruleflow_with_dt])
    await manager.delele_ruleflow(id)

    await manager.getItems(tags)
    await manager.updateTags(ruleId, data, version)
    await manager.delete(ruleId, version)

2.3 All available methods in management API

Metadata

Release files for decisionrulespy 3.0.5

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

Source distribution (sdist)

Source distribution for decisionrulespy 3.0.5
File Size Uploaded
decisionrulespy-3.0.5.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for decisionrulespy 3.0.5
File Interpreter ABI Platform
decisionrulespy-3.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / decisionrulespy-3.0.5.tar.gz

Download URL decisionrulespy-3.0.5.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
110cc1a4684e4ca921717429c07eacc87689485bc42e6f270e1f4b15b449cd29
BLAKE2b-256 checksum
How to use checksums
d804aae99433cfdf7c4c33864fc8f72315cc9c84f2a1aee25c8f4498864b794b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / decisionrulespy-3.0.5-py3-none-any.whl

Download URL decisionrulespy-3.0.5-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79ff2c6d8b197d17e9d85bd970dbe31d005404a16b5bf080b976402b75e858c8
BLAKE2b-256 checksum
How to use checksums
aff835e9b5bbf3df801c71b15a6e3222f88ee126cd62666c02cff268a2732b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

3.0.5 This release

2 release files

3.0.3

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.2.5

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

0.0.6

2 release files

0.0.5

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