Skip to main content

A lightweight client for an AHBicht powered Backend

Project description

AHBicht Functions Python Client

Unittests status badge Coverage status badge Linting status badge Black status badge PyPi Status Badge

This repository contains a lightweight client for an AHBicht powered backend by Hochfrequenz. It does not duplicate the core AHBicht logic but provides a PackageResolver that accesses a database (via a REST API) that stores PackageKeyConditionExpressionMappings. The database is maintained by Hochfrequenz.

Internally this client uses and requires aiohttp.

How to use the Client

  • Install using pip:
pip install ahbichtfunctionsclient

Then call it

import asyncio

from ahbicht.mapping_results import PackageKeyConditionExpressionMapping, ConditionKeyConditionTextMapping
from ahbichtfunctionsclient import HochfrequenzPackageResolver
from maus.edifact import EdifactFormat, EdifactFormatVersion


async def retrieve_package_key_condition_expression_mapping():
    # for a documentation about the purpose of a package resolver, you should read the ahbicht docs
    package_resolver = HochfrequenzPackageResolver(EdifactFormatVersion.FV2204, EdifactFormat.UTILMD)
    # the following data are just hardcoded to provide you a minimal working example
    package_mapping = await package_resolver.get_condition_expression("10P")  # this does an HTTP GET request
    assert isinstance(package_mapping, PackageKeyConditionExpressionMapping)  # the result is ahbicht compatible


async def retrieve_condition_key_condition_text_mapping():
    condition_resolver = HochfrequenzPackageResolver(EdifactFormatVersion.FV2204, EdifactFormat.UTILMD)
    # the following data are just hardcoded to provide you a minimal working example
    condition_mapping = await condition_resolver.get_condition_expression("56")  # this does an HTTP GET request
    assert isinstance(condition_mapping, ConditionKeyConditionTextMapping)  # the result is ahbicht compatible


async def minimal_working_example():
    await retrieve_condition_key_condition_text_mapping()
    await retrieve_package_key_condition_expression_mapping()


loop = asyncio.get_event_loop()
loop.run_until_complete(minimal_working_example())

Production Readiness

This AHBicht client has a 100% code coverage, is linted, statically type checked and PEP561 compatible. It relies on a Hochfrequenz API which is, as of today (2022-03-17), free to use. Hochfrequenz does not give any guarantees regarding the stability or uptime of the API. Also at one point it might require authorization.

How to use this Repository on Your Machine (for development)

Please follow the instructions in our Python Template Repository. And for futher information, see the Tox Repository.

You can also check out our MIG AHB Utility Stack (MAUS) and AHBicht repositories.

Contribute

You are very welcome to contribute to this template repository by opening a pull request against the main branch.

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

ahbichtfunctionsclient-0.0.5.tar.gz (11.4 kB view hashes)

Uploaded Source

Built Distribution

ahbichtfunctionsclient-0.0.5-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

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