Skip to main content

Client for connection to the OPA service

Project description

Python Open Policy Agent (OPA) Client

See offical documentation page Open Policy Agent

>>> from opa_client.opa import OpaClient
>>> client = OpaClient() # default host='localhost', port=8181, version='v1'
>>> print(client.check_connection())
True
>>>  test_policy = """
...     package play
... 
...     import data.testapi.testdata
... 
...     default hello = false
... 
...     hello {
...         m := input.message
...         testdata[i] == "world"
...     }
... """

>>> print(client.update_opa_policy_fromstring(test_policy, "testpolicy"))
True
>>> print(client.get_policies_list())
['testpolicy']
>>> data = ["world", "hello"]
>>> print(client.update_or_create_opa_data(data, "testapi/testdata"))
True
>>> check_data = {"input": {"message": "hello"}}
>>> print(client.check_permission(input_data=check_data, policy_name="testpolicy", rule_name="hello"))
{'result': True}

OPA-python-client supports Python >= 3.6

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

OPA-python-client-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

OPA_python_client-1.0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file OPA-python-client-1.0.1.tar.gz.

File metadata

  • Download URL: OPA-python-client-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

File hashes

Hashes for OPA-python-client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f81f6440bb9f89daa0aa71033dc1434a80867a7ead99871ac5d2d251f8ea2768
MD5 19d36667d99cc20b26052f6e3239c052
BLAKE2b-256 b6fc91c7d25501b233eb10c3e13846c63a43f8b4f4f1f08f75dc132a5151e589

See more details on using hashes here.

File details

Details for the file OPA_python_client-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: OPA_python_client-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

File hashes

Hashes for OPA_python_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6eebed8c4e6d81ec904c3a70dc18908b0cd71da78f9b0d78c6d4789b8ec9f4b3
MD5 ef2f371b71747357f4ac9ae86cfd097b
BLAKE2b-256 850ea6c036852b663d2f7c0173240958c18255cddeb2b1d533b8b99a92a111de

See more details on using hashes here.

Supported by

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