openadr3-client


Nameopenadr3-client JSON
Version 0.0.9 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2025-08-06 11:27:26
maintainerNone
docs_urlNone
authorNick van der Burgt
requires_python<4,>=3.12
licenseApache Software License 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![CodeQL](https://github.com/ElaadNL/openadr3-client/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/ElaadNL/openadr3-client/actions/workflows/github-code-scanning/codeql)
[![Python Default CI](https://github.com/ElaadNL/openadr3-client/actions/workflows/ci.yml/badge.svg)](https://github.com/ElaadNL/openadr3-client/actions/workflows/ci.yml)
![PYPI-DL](https://img.shields.io/pypi/dm/openadr3-client?style=flat)
[![image](https://img.shields.io/pypi/v/openadr3-client?label=pypi)](https://pypi.python.org/pypi/openadr3-client)
[![Python Versions](https://img.shields.io/pypi/pyversions/openadr3-client)](https://pypi.python.org/pypi/openadr3-client)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)

# OpenADR3 Client

This library provides two main interfaces for interacting with OpenADR3 (Open Automated Demand Response) systems:

1. Business Logic (BL) Client - For VTN operators (for example, DSOs).
2. Virtual End Node (VEN) Client - For end users (for example, device operators).

## Business Logic (BL) Client

The BL client is designed for VTN operators to manage OpenADR3 programs and events. It provides full control over the following interfaces:

- **Events**: Create, read, update, and delete events
- **Programs**: Create, read, update, and delete programs
- **Reports**: Read-only access to reports
- **VENS**: Read-only access to VEN information
- **Subscriptions**: Read-only access to subscriptions

### Example BL Usage

```python
from datetime import UTC, datetime, timedelta

from openadr3_client.bl.http_factory import BusinessLogicHttpClientFactory
from openadr3_client.models.common.unit import Unit
from openadr3_client.models.event.event import EventPayload, Interval, NewEvent
from openadr3_client.models.event.event_payload import EventPayloadType
from openadr3_client.models.program.program import (
    EventPayloadDescriptor,
    IntervalPeriod,
    NewProgram,
    Target,
)

# Initialize the client with the required OAuth configuration.
bl_client = BusinessLogicHttpClientFactory.create_http_bl_client(
    vtn_base_url="https://vtn.example.com",
    client_id="your_client_id",
    client_secret="your_client_secret", 
    token_url="https://auth.example.com/token",
    scopes=["read_all", "write_events", "write_programs"]  # Optional: specify required scopes
)

# Create a new program (NewProgram allows for more properties, this is just a simple example).
program = NewProgram(
        id=None, # ID cannot be set by the client, assigned by the VTN.
        program_name="Example Program",
        program_long_name="Example Program Long Name",
        interval_period=IntervalPeriod(
            start=datetime(2023, 1, 1, 12, 30, 0, tzinfo=UTC),
            duration=timedelta(minutes=5),
            randomize_start=timedelta(minutes=5),
        ),
        payload_descriptor=(EventPayloadDescriptor(payload_type=EventPayloadType.PRICE, units=Unit.KWH, currency="EUR"),),
        targets=(Target(type="test-target-1", values=("test-value-1",)),),
)

created_program = bl_client.programs.create_program(new_program=program)

# Create an event inside the program
event = NewEvent(
    id=None,
    programID=created_program.id, # ID of program is known after creation
    event_name="test-event",
    priority=999,
    targets=(Target(type="test-target-1", values=("test-value-1",)),),
    payload_descriptor=(
        EventPayloadDescriptor(payload_type=EventPayloadType.PRICE, units=Unit.KWH, currency="EUR"),
    ),
    # Top Level interval definition, each interval specified with the None value will inherit this
    # value by default as its interval period. In this case, each interval will have an implicit
    # duration of 5 minutes.
    interval_period=IntervalPeriod(
        start=datetime(2023, 1, 1, 12, 30, 0, tzinfo=UTC),
        duration=timedelta(minutes=5),
    ),
    intervals=(
        Interval(
            id=0,
            interval_period=None,
            payloads=(EventPayload(type=EventPayloadType.PRICE, values=(2.50,)),),
        ),
    ),
)

created_event = bl_client.events.create_event(new_event=event)


```

## Virtual End Node (VEN) Client

The VEN client is designed for end users and device operators to receive and process OpenADR3 programs and events. It provides:

- **Events**: Read-only access to events
- **Programs**: Read-only access to programs
- **Reports**: Create and manage reports
- **VENS**: Register and manage VEN information
- **Subscriptions**: Manage subscriptions to programs and events

### Example VEN Client Usage

```python
from openadr3_client.ven.http_factory import VirtualEndNodeHttpClientFactory

# Initialize the client with the required OAuth configuration.
ven_client = VirtualEndNodeHttpClientFactory.create_http_ven_client(
    vtn_base_url="https://vtn.example.com",
    client_id="your_client_id",
    client_secret="your_client_secret",
    token_url="https://auth.example.com/token",
    scopes=["read_all", "write_reports"]  # Optional: specify required scopes
)

# Search for events inside the VTN.
events = ven_client.events.get_events(target=..., pagination=..., program_id=...)

# Process the events as needed...
```

## Data Format Conversion

The library provides convenience methods to convert between OpenADR3 event intervals and common data formats. These conversions can be used both for input (creating event intervals from a common data format) and output (processing existing event intervals to a common data format).

### Pandas DataFrame Format

The library supports conversion between event intervals and pandas DataFrames. The DataFrame format is validated using a `pandera` schema to ensure data integrity.

#### Pandas Input Format

When creating an event interval from a DataFrame, the input must match the following schema:

| Column Name | Type | Required | Description |
|------------|------|----------|-------------|
| type | str | Yes | The type of the event interval |
| values | list[Union[int, float, str, bool, Point]] | Yes | The payload values for the interval |
| start | datetime64[ns, UTC] | Yes | The start time of the interval (UTC timezone) |
| duration | timedelta64[ns] | Yes | The duration of the interval |
| randomize_start | timedelta64[ns] | No | The randomization window for the start time |

Important notes:

- All datetime values must be timezone-aware and in UTC
- All datetime and timedelta values must use nanosecond precision (`[ns]`)
- The id column of an event interval cannot be provided as input - the client will automatically assign incrementing integer IDs to the event intervals, in the same order as they were given.

Example DataFrame:

```python
import pandas as pd

df = pd.DataFrame({
    'type': ['SIMPLE'],
    'values': [[1.0, 2.0]],
    'start': [pd.Timestamp("2023-01-01 00:00:00.000Z").as_unit("ns")],
    'duration': [pd.Timedelta(hours=1)],
    'randomize_start': [pd.Timedelta(minutes=5)]
})
```

#### Pandas Output Format

When converting an event interval to a DataFrame, the output will match the same schema as the input format, with one addition: the event interval's `id` field will be included as the DataFrame index. The conversion process includes validation to ensure the data meets the schema requirements, including timezone and precision specifications.

### TypedDict Format

The library also supports conversion between event intervals and lists of dictionaries using a TypedDict format.

#### Dictionary Input Format

When creating an event interval from a dictionary, the input must follow the `EventIntervalDictInput` format:

| Field Name | Type | Required | Description |
|------------|------|----------|-------------|
| type | str | Yes | The type of the event interval |
| values | list[Union[int, float, str, bool, Point]] | Yes | The payload values for the interval |
| start | datetime | No | The start time of the interval (must be timezone aware) |
| duration | timedelta | No | The duration of the interval |
| randomize_start | timedelta | No | The randomization window for the start time |

Important notes:

- All datetime values must be timezone-aware and in UTC
- The id field cannot be provided as input - the client will automatically assign incrementing integer IDs to the event intervals, in the same order as they were given

Example input:

```python
from datetime import datetime, timedelta, UTC

dict_iterable_input = [
    {
        # Required fields
        'type': 'SIMPLE',
        'values': [1.0, 2.0],
        
        # Optional fields
        'start': datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
        'duration': timedelta(hours=1),
        'randomize_start': timedelta(minutes=15)
    },
]
```

#### Dictionary Output Format

When converting an event interval to a list of dictionaries, the output is checked against the `EventIntervalDictInput` TypedDict with type hints to ensure compliance. The output is a list of `EventIntervalDictInput` values.

## Getting Started

1. Install the package
2. Configure the required environment variables
3. Choose the appropriate client interface (BL or VEN)
4. Initialize the client with the required interfaces
5. Start interacting with the OpenADR3 VTN system.

## Model Immutability

All domain models defined in the openadr3-client are immutable by design. This is enforced through Pydantic's `frozen = True` configuration. This means that once a model instance is created, its properties cannot be modified directly.

To make changes to an existing resource (like a Program or VEN), you must use the `update` method provided by the corresponding `Existing{ResourceName}` class. This method takes an update object that contains only the properties that are valid to be altered.

For example, to update a program:

```python
existing:program : ExistingProgram = ...

# Create an update object with the properties you want to change
program_update = ProgramUpdate(
    program_name="Updated Program Name",
    program_long_name="Updated Program Long Name"
)

# Apply the update to an existing program, this returns a new ExistingProgram object with the update changes applied.
updated_program = existing_program.update(program_update)
```

This pattern ensures data consistency and makes it clear which properties can be modified after creation.

## Custom Enumeration Cases

The library supports both predefined and custom enumeration cases for various types like `Unit`, `EventPayloadType`, and `ReportPayloadType`. This flexibility allows for adherence to the OpenADR3 specification, which specifies both common default enumeration values, while also allowing for arbitrary custom values.

To support this as best as possible, ensuring type safety and ease of use through the standard enum interface for these common cases, the choice was made to extend the enumeration classes and allow for dynamic case construction only when needed for custom values.

### Predefined Cases

Predefined enumeration cases are type-safe and can be used directly:

```python
from openadr3_client.models.common.unit import Unit
from openadr3_client.models.event.event_payload import EventPayloadDescriptor, EventPayloadType

# Using predefined cases
unit = Unit.KWH
payload_type = EventPayloadType.SIMPLE

# These can be used in payload descriptors
descriptor = EventPayloadDescriptor(
    payload_type=unit,
    units=payload_type
)
```

### Custom Cases

To use custom enumeration cases, you must use the functional constructor. The library will validate and create a new enumeration case dynamically:

```python
from openadr3_client.models.common.unit import Unit
from openadr3_client.models.event.event_payload import EventPayloadDescriptor, EventPayloadType

# Using custom cases
custom_unit = Unit("CUSTOM_UNIT")
custom_payload_type = EventPayloadType("CUSTOM_PAYLOAD")

# These can be used in payload descriptors
descriptor = EventPayloadDescriptor(
    payload_type=custom_payload_type,
    units=custom_unit
)
```

Note that custom enumeration cases are validated according to the OpenADR3 specification:

- For `EventPayloadType`, values must be strings between 1 and 128 characters
- For `ReportPayloadType`, values must be strings between 1 and 128 characters
- For `Unit`, any string value is accepted

## Creation Guard Pattern

All `New{Resource}` classes (such as `NewProgram`, `NewVen`, etc.) inherit from the `CreationGuarded` class. This implements a creation guard pattern that ensures each instance can only be used to create a resource in the VTN exactly once.

This pattern prevents accidental reuse of creation objects, which could lead to duplicate resources or unintended side effects. If you attempt to use the same `New{Resource}` instance multiple times to create a resource, the library will raise a `ValueError`.

For example:

```python
# Create a new program instance
new_program = NewProgram(
    program_name="Example Program",
    program_long_name="Example Program Long Name",
    # ... other required fields ...
)

# First creation - this will succeed
created_program = bl_client.programs.create_program(new_program=new_program)

# Second creation with the same instance - this will raise ValueError
try:
    duplicate_program = bl_client.programs.create_program(new_program=new_program)
except ValueError as e:
    print(f"Error: {e}")  # Will print: "Error: CreationGuarded object has already been created."
```

## GAC compliance

An additional plugin package is available [here](https://github.com/ElaadNL/openadr3-client-gac-compliance) which adds additional domain validation rules to the OpenADR3 domain models to enforce compliance with the Dutch GAC (Grid Aware Charging) specification.

Integrating this plugin with the OpenADR3 client can be done by importing the gac compliance package once globally:

```python
# This could be done for example in the root __init__.py of your python project.
import openadr3_client_gac_compliance 
```

## Development

- To run all linters and formatters with automatic fixes applied
```sh
poetry run task fix
```

- To run tests
```sh
poetry run task test
```

- To dry run ci locally (no automatic fixes applied)
```sh
poetry run task local-ci
```

### Testing

#### Prerequisites

- Allow usage of the Docker Socket
    - MacOS: advanced settings ??
    - Linux: check if you are part of the Docker user group `groups $USER | grep docker`, otherwise add yourself to it `sudo usermod -aG docker $USER`

### Running the tests

1. Have the Docker Deamon running
2. (`poetry install`)
3. `poetry run pytest`


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "openadr3-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Nick van der Burgt",
    "author_email": "nick.van.der.burgt@elaad.nl",
    "download_url": "https://files.pythonhosted.org/packages/9e/85/46f901a30d7bbc1864993dcdeea25c2e0157e4fd976dd05b452845a77cb3/openadr3_client-0.0.9.tar.gz",
    "platform": null,
    "description": "[![CodeQL](https://github.com/ElaadNL/openadr3-client/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/ElaadNL/openadr3-client/actions/workflows/github-code-scanning/codeql)\n[![Python Default CI](https://github.com/ElaadNL/openadr3-client/actions/workflows/ci.yml/badge.svg)](https://github.com/ElaadNL/openadr3-client/actions/workflows/ci.yml)\n![PYPI-DL](https://img.shields.io/pypi/dm/openadr3-client?style=flat)\n[![image](https://img.shields.io/pypi/v/openadr3-client?label=pypi)](https://pypi.python.org/pypi/openadr3-client)\n[![Python Versions](https://img.shields.io/pypi/pyversions/openadr3-client)](https://pypi.python.org/pypi/openadr3-client)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n\n# OpenADR3 Client\n\nThis library provides two main interfaces for interacting with OpenADR3 (Open Automated Demand Response) systems:\n\n1. Business Logic (BL) Client - For VTN operators (for example, DSOs).\n2. Virtual End Node (VEN) Client - For end users (for example, device operators).\n\n## Business Logic (BL) Client\n\nThe BL client is designed for VTN operators to manage OpenADR3 programs and events. It provides full control over the following interfaces:\n\n- **Events**: Create, read, update, and delete events\n- **Programs**: Create, read, update, and delete programs\n- **Reports**: Read-only access to reports\n- **VENS**: Read-only access to VEN information\n- **Subscriptions**: Read-only access to subscriptions\n\n### Example BL Usage\n\n```python\nfrom datetime import UTC, datetime, timedelta\n\nfrom openadr3_client.bl.http_factory import BusinessLogicHttpClientFactory\nfrom openadr3_client.models.common.unit import Unit\nfrom openadr3_client.models.event.event import EventPayload, Interval, NewEvent\nfrom openadr3_client.models.event.event_payload import EventPayloadType\nfrom openadr3_client.models.program.program import (\n    EventPayloadDescriptor,\n    IntervalPeriod,\n    NewProgram,\n    Target,\n)\n\n# Initialize the client with the required OAuth configuration.\nbl_client = BusinessLogicHttpClientFactory.create_http_bl_client(\n    vtn_base_url=\"https://vtn.example.com\",\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\", \n    token_url=\"https://auth.example.com/token\",\n    scopes=[\"read_all\", \"write_events\", \"write_programs\"]  # Optional: specify required scopes\n)\n\n# Create a new program (NewProgram allows for more properties, this is just a simple example).\nprogram = NewProgram(\n        id=None, # ID cannot be set by the client, assigned by the VTN.\n        program_name=\"Example Program\",\n        program_long_name=\"Example Program Long Name\",\n        interval_period=IntervalPeriod(\n            start=datetime(2023, 1, 1, 12, 30, 0, tzinfo=UTC),\n            duration=timedelta(minutes=5),\n            randomize_start=timedelta(minutes=5),\n        ),\n        payload_descriptor=(EventPayloadDescriptor(payload_type=EventPayloadType.PRICE, units=Unit.KWH, currency=\"EUR\"),),\n        targets=(Target(type=\"test-target-1\", values=(\"test-value-1\",)),),\n)\n\ncreated_program = bl_client.programs.create_program(new_program=program)\n\n# Create an event inside the program\nevent = NewEvent(\n    id=None,\n    programID=created_program.id, # ID of program is known after creation\n    event_name=\"test-event\",\n    priority=999,\n    targets=(Target(type=\"test-target-1\", values=(\"test-value-1\",)),),\n    payload_descriptor=(\n        EventPayloadDescriptor(payload_type=EventPayloadType.PRICE, units=Unit.KWH, currency=\"EUR\"),\n    ),\n    # Top Level interval definition, each interval specified with the None value will inherit this\n    # value by default as its interval period. In this case, each interval will have an implicit\n    # duration of 5 minutes.\n    interval_period=IntervalPeriod(\n        start=datetime(2023, 1, 1, 12, 30, 0, tzinfo=UTC),\n        duration=timedelta(minutes=5),\n    ),\n    intervals=(\n        Interval(\n            id=0,\n            interval_period=None,\n            payloads=(EventPayload(type=EventPayloadType.PRICE, values=(2.50,)),),\n        ),\n    ),\n)\n\ncreated_event = bl_client.events.create_event(new_event=event)\n\n\n```\n\n## Virtual End Node (VEN) Client\n\nThe VEN client is designed for end users and device operators to receive and process OpenADR3 programs and events. It provides:\n\n- **Events**: Read-only access to events\n- **Programs**: Read-only access to programs\n- **Reports**: Create and manage reports\n- **VENS**: Register and manage VEN information\n- **Subscriptions**: Manage subscriptions to programs and events\n\n### Example VEN Client Usage\n\n```python\nfrom openadr3_client.ven.http_factory import VirtualEndNodeHttpClientFactory\n\n# Initialize the client with the required OAuth configuration.\nven_client = VirtualEndNodeHttpClientFactory.create_http_ven_client(\n    vtn_base_url=\"https://vtn.example.com\",\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    token_url=\"https://auth.example.com/token\",\n    scopes=[\"read_all\", \"write_reports\"]  # Optional: specify required scopes\n)\n\n# Search for events inside the VTN.\nevents = ven_client.events.get_events(target=..., pagination=..., program_id=...)\n\n# Process the events as needed...\n```\n\n## Data Format Conversion\n\nThe library provides convenience methods to convert between OpenADR3 event intervals and common data formats. These conversions can be used both for input (creating event intervals from a common data format) and output (processing existing event intervals to a common data format).\n\n### Pandas DataFrame Format\n\nThe library supports conversion between event intervals and pandas DataFrames. The DataFrame format is validated using a `pandera` schema to ensure data integrity.\n\n#### Pandas Input Format\n\nWhen creating an event interval from a DataFrame, the input must match the following schema:\n\n| Column Name | Type | Required | Description |\n|------------|------|----------|-------------|\n| type | str | Yes | The type of the event interval |\n| values | list[Union[int, float, str, bool, Point]] | Yes | The payload values for the interval |\n| start | datetime64[ns, UTC] | Yes | The start time of the interval (UTC timezone) |\n| duration | timedelta64[ns] | Yes | The duration of the interval |\n| randomize_start | timedelta64[ns] | No | The randomization window for the start time |\n\nImportant notes:\n\n- All datetime values must be timezone-aware and in UTC\n- All datetime and timedelta values must use nanosecond precision (`[ns]`)\n- The id column of an event interval cannot be provided as input - the client will automatically assign incrementing integer IDs to the event intervals, in the same order as they were given.\n\nExample DataFrame:\n\n```python\nimport pandas as pd\n\ndf = pd.DataFrame({\n    'type': ['SIMPLE'],\n    'values': [[1.0, 2.0]],\n    'start': [pd.Timestamp(\"2023-01-01 00:00:00.000Z\").as_unit(\"ns\")],\n    'duration': [pd.Timedelta(hours=1)],\n    'randomize_start': [pd.Timedelta(minutes=5)]\n})\n```\n\n#### Pandas Output Format\n\nWhen converting an event interval to a DataFrame, the output will match the same schema as the input format, with one addition: the event interval's `id` field will be included as the DataFrame index. The conversion process includes validation to ensure the data meets the schema requirements, including timezone and precision specifications.\n\n### TypedDict Format\n\nThe library also supports conversion between event intervals and lists of dictionaries using a TypedDict format.\n\n#### Dictionary Input Format\n\nWhen creating an event interval from a dictionary, the input must follow the `EventIntervalDictInput` format:\n\n| Field Name | Type | Required | Description |\n|------------|------|----------|-------------|\n| type | str | Yes | The type of the event interval |\n| values | list[Union[int, float, str, bool, Point]] | Yes | The payload values for the interval |\n| start | datetime | No | The start time of the interval (must be timezone aware) |\n| duration | timedelta | No | The duration of the interval |\n| randomize_start | timedelta | No | The randomization window for the start time |\n\nImportant notes:\n\n- All datetime values must be timezone-aware and in UTC\n- The id field cannot be provided as input - the client will automatically assign incrementing integer IDs to the event intervals, in the same order as they were given\n\nExample input:\n\n```python\nfrom datetime import datetime, timedelta, UTC\n\ndict_iterable_input = [\n    {\n        # Required fields\n        'type': 'SIMPLE',\n        'values': [1.0, 2.0],\n        \n        # Optional fields\n        'start': datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),\n        'duration': timedelta(hours=1),\n        'randomize_start': timedelta(minutes=15)\n    },\n]\n```\n\n#### Dictionary Output Format\n\nWhen converting an event interval to a list of dictionaries, the output is checked against the `EventIntervalDictInput` TypedDict with type hints to ensure compliance. The output is a list of `EventIntervalDictInput` values.\n\n## Getting Started\n\n1. Install the package\n2. Configure the required environment variables\n3. Choose the appropriate client interface (BL or VEN)\n4. Initialize the client with the required interfaces\n5. Start interacting with the OpenADR3 VTN system.\n\n## Model Immutability\n\nAll domain models defined in the openadr3-client are immutable by design. This is enforced through Pydantic's `frozen = True` configuration. This means that once a model instance is created, its properties cannot be modified directly.\n\nTo make changes to an existing resource (like a Program or VEN), you must use the `update` method provided by the corresponding `Existing{ResourceName}` class. This method takes an update object that contains only the properties that are valid to be altered.\n\nFor example, to update a program:\n\n```python\nexisting:program : ExistingProgram = ...\n\n# Create an update object with the properties you want to change\nprogram_update = ProgramUpdate(\n    program_name=\"Updated Program Name\",\n    program_long_name=\"Updated Program Long Name\"\n)\n\n# Apply the update to an existing program, this returns a new ExistingProgram object with the update changes applied.\nupdated_program = existing_program.update(program_update)\n```\n\nThis pattern ensures data consistency and makes it clear which properties can be modified after creation.\n\n## Custom Enumeration Cases\n\nThe library supports both predefined and custom enumeration cases for various types like `Unit`, `EventPayloadType`, and `ReportPayloadType`. This flexibility allows for adherence to the OpenADR3 specification, which specifies both common default enumeration values, while also allowing for arbitrary custom values.\n\nTo support this as best as possible, ensuring type safety and ease of use through the standard enum interface for these common cases, the choice was made to extend the enumeration classes and allow for dynamic case construction only when needed for custom values.\n\n### Predefined Cases\n\nPredefined enumeration cases are type-safe and can be used directly:\n\n```python\nfrom openadr3_client.models.common.unit import Unit\nfrom openadr3_client.models.event.event_payload import EventPayloadDescriptor, EventPayloadType\n\n# Using predefined cases\nunit = Unit.KWH\npayload_type = EventPayloadType.SIMPLE\n\n# These can be used in payload descriptors\ndescriptor = EventPayloadDescriptor(\n    payload_type=unit,\n    units=payload_type\n)\n```\n\n### Custom Cases\n\nTo use custom enumeration cases, you must use the functional constructor. The library will validate and create a new enumeration case dynamically:\n\n```python\nfrom openadr3_client.models.common.unit import Unit\nfrom openadr3_client.models.event.event_payload import EventPayloadDescriptor, EventPayloadType\n\n# Using custom cases\ncustom_unit = Unit(\"CUSTOM_UNIT\")\ncustom_payload_type = EventPayloadType(\"CUSTOM_PAYLOAD\")\n\n# These can be used in payload descriptors\ndescriptor = EventPayloadDescriptor(\n    payload_type=custom_payload_type,\n    units=custom_unit\n)\n```\n\nNote that custom enumeration cases are validated according to the OpenADR3 specification:\n\n- For `EventPayloadType`, values must be strings between 1 and 128 characters\n- For `ReportPayloadType`, values must be strings between 1 and 128 characters\n- For `Unit`, any string value is accepted\n\n## Creation Guard Pattern\n\nAll `New{Resource}` classes (such as `NewProgram`, `NewVen`, etc.) inherit from the `CreationGuarded` class. This implements a creation guard pattern that ensures each instance can only be used to create a resource in the VTN exactly once.\n\nThis pattern prevents accidental reuse of creation objects, which could lead to duplicate resources or unintended side effects. If you attempt to use the same `New{Resource}` instance multiple times to create a resource, the library will raise a `ValueError`.\n\nFor example:\n\n```python\n# Create a new program instance\nnew_program = NewProgram(\n    program_name=\"Example Program\",\n    program_long_name=\"Example Program Long Name\",\n    # ... other required fields ...\n)\n\n# First creation - this will succeed\ncreated_program = bl_client.programs.create_program(new_program=new_program)\n\n# Second creation with the same instance - this will raise ValueError\ntry:\n    duplicate_program = bl_client.programs.create_program(new_program=new_program)\nexcept ValueError as e:\n    print(f\"Error: {e}\")  # Will print: \"Error: CreationGuarded object has already been created.\"\n```\n\n## GAC compliance\n\nAn additional plugin package is available [here](https://github.com/ElaadNL/openadr3-client-gac-compliance) which adds additional domain validation rules to the OpenADR3 domain models to enforce compliance with the Dutch GAC (Grid Aware Charging) specification.\n\nIntegrating this plugin with the OpenADR3 client can be done by importing the gac compliance package once globally:\n\n```python\n# This could be done for example in the root __init__.py of your python project.\nimport openadr3_client_gac_compliance \n```\n\n## Development\n\n- To run all linters and formatters with automatic fixes applied\n```sh\npoetry run task fix\n```\n\n- To run tests\n```sh\npoetry run task test\n```\n\n- To dry run ci locally (no automatic fixes applied)\n```sh\npoetry run task local-ci\n```\n\n### Testing\n\n#### Prerequisites\n\n- Allow usage of the Docker Socket\n    - MacOS: advanced settings ??\n    - Linux: check if you are part of the Docker user group `groups $USER | grep docker`, otherwise add yourself to it `sudo usermod -aG docker $USER`\n\n### Running the tests\n\n1. Have the Docker Deamon running\n2. (`poetry install`)\n3. `poetry run pytest`\n\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": null,
    "version": "0.0.9",
    "project_urls": {
        "Bug Tracker": "https://github.com/ElaadNL/openadr3-client/issues",
        "Changelog": "https://github.com/ElaadNL/openadr3-client/releases",
        "Homepage": "https://github.com/ElaadNL/openadr3-client",
        "Repository": "https://github.com/ElaadNL/openadr3-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "89b587d34a7e656639a53891a0d04db2604fd08fcef8ae95670424cffd16326e",
                "md5": "ae413a8e6487d88eae0dfb125c5926d1",
                "sha256": "677da3b0fe434c6020e09c51f09201065a78bd9973b7d634533aa70a5b98bb80"
            },
            "downloads": -1,
            "filename": "openadr3_client-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ae413a8e6487d88eae0dfb125c5926d1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.12",
            "size": 61635,
            "upload_time": "2025-08-06T11:27:25",
            "upload_time_iso_8601": "2025-08-06T11:27:25.394972Z",
            "url": "https://files.pythonhosted.org/packages/89/b5/87d34a7e656639a53891a0d04db2604fd08fcef8ae95670424cffd16326e/openadr3_client-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9e8546f901a30d7bbc1864993dcdeea25c2e0157e4fd976dd05b452845a77cb3",
                "md5": "6d01ddcb843309356a77c1a541ca9cbc",
                "sha256": "0f848230e271281708994d1262231ddfcbff9a3ae9fa6cc473e3df71b0c65520"
            },
            "downloads": -1,
            "filename": "openadr3_client-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "6d01ddcb843309356a77c1a541ca9cbc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.12",
            "size": 36489,
            "upload_time": "2025-08-06T11:27:26",
            "upload_time_iso_8601": "2025-08-06T11:27:26.935778Z",
            "url": "https://files.pythonhosted.org/packages/9e/85/46f901a30d7bbc1864993dcdeea25c2e0157e4fd976dd05b452845a77cb3/openadr3_client-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-06 11:27:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ElaadNL",
    "github_project": "openadr3-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openadr3-client"
}
        
Elapsed time: 0.42335s