Metadata-Version: 2.3
Name: pepr-client
Version: 1.1.1
Summary: A simple python client for reading PEPR actions.
Author: Åsmund Våge Fannemel
Author-email: Åsmund Våge Fannemel <34712686+asmfstatoil@users.noreply.github.com>
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: requests>=2.34.2,<3
Requires-Dist: msal-bearer>=1.6.1
Requires-Python: >=3.10, <4
Description-Content-Type: text/markdown

# pepr-python-client
A simple python client for reading PEPR actions, their subtasks, losses and facilities from the public client api at https://api.gateway.equinor.com/pepr

# Try it out
See [demo.py](examples/demo.py) and [demo_subtasks.py](examples/demo_subtasks.py)

## Installing

Install package from pypi using `pip install pepr_client`

## Reading subtasks

A PEPR action can be split into subtasks. Fetch the subtasks of an action either
directly or lazily through the `Action` object:

```python
from pepr_client import Action, get_action_subtasks

# Directly from an action id.
for subtask in get_action_subtasks(80231887):
    print(subtask.id, subtask.title, subtask.status, subtask.url)

# Or lazily via the Action (fetched on first access, then cached).
action = Action(80231887)
print(f"{len(action.subtasks)} subtask(s)")
```

A subtask exposes the same style of properties as an action (`id`, `title`,
`status`, `description`, `due_date`, `priority`, `sap_code`, `keywords`,
`tag_numbers`, `sap_work_orders`, `service_now_references`, `attachments`,
`comments`, `url`, ...). `subtask.action` lazily loads the parent `Action`.

> Subtask attachments cannot be downloaded through the API &mdash; there is no
> subtask-attachment endpoint, and subtask attachments share the action
> attachment id space. Use `subtask.url` to open the subtask in PEPR instead.
> Calling `subtask.download_attachment(...)` raises `NotImplementedError`.


## Generic flag catalogue

Fetch the available flag definitions without loading individual actions:

```python
from pepr_client import GenericFlag

for flag in GenericFlag.get_generic_flags():
    print(flag.id, flag.key, flag.name, flag.description)
```

## Developing / testing

Uv is preferred for developers. Clone and install with required packages for testing and coverage:  
`uv sync`

For testing with coverage run:  
`uv run pytest --cov --cov-report=html`
