Typed Python client for the SmartDok REST API (RUE incidents, quality deviations, projects, users)
Project description
pysmartdok
A Python library for the SmartDok API.
Installation
To use in a project, add this to dependencies in pyproject.toml:
"pysmartdok @ git+https://github.com/asterisk-digital/pysmartdok.git@main"
Usage
Uses the SmartDok REST API. Requires an API token.
import pysmartdok
client = pysmartdok.ApiClient(
api_token="your_api_token",
user_agent="myapp(you@example.com)", # optional, defaults to "pysmartdok"
)
# Quality Deviations
qd_reports = client.qd.get_qd_reports(
project_id=123, # optional
qd_status="Open", # optional: Open, Close, Unprocessed, Discarded
)
qd_pdf = client.qd.get_qd_pdf(qd_id=789, include_details=True)
# Projects
projects = client.projects.get_projects(include_inactive=False, include_orders=False)
project = client.projects.get_project(project_id=123)
subprojects = client.projects.get_subprojects(project_id=123)
next_number = client.projects.get_next_project_number()
# RUE summaries (paginates internally, returns all matching reports)
summaries = client.rue.get_rue_summaries(
project_id=123, # optional
rue_status="Open", # optional: Open, Close, Unprocessed, Discarded
last_updated_since="2024-01-01T00:00:00Z", # optional
)
# Single RUE report (full detail)
report = client.rue.get_rue_report(rue_id=456)
# All full RUE reports — fetches summaries then fans out concurrently
reports = client.rue.get_rue_reports(threads=8)
# RUE event log (audit trail)
events = client.rue.get_rue_eventlog(rue_id=456)
# RUE messages/comments
messages = client.rue.get_rue_messages(rue_id=456)
# RUE PDF metadata
pdf_info = client.rue.get_rue_pdf(rue_id=456, include_details=True)
# Users
users = client.users.get_users(include_inactive=False)
me = client.users.get_current_user()
user = client.users.get_user(user_id="...")
license_info = client.users.get_license_info()
Development
Set up the environment with uv:
uv sync
Before pushing, run lint, format, and tests — CI runs the same on Python 3.11, 3.12, 3.13, and 3.14:
uv run ruff check .
uv run ruff format .
uv run tox
Tests use responses to mock the SmartDok API; no token is needed. To smoke-test against the real API, drop a .env at the repo root with SMARTDOK_API_KEY=... and run one of the scripts in scripts/:
uv run python scripts/get_rue_summaries.py
Change conventions
- All changes must conform to the SmartDok OpenAPI spec, which is vendored at
docs/swagger.json. Refresh it from upstream when SmartDok updates the API; commit the diff so spec changes are visible in git history:curl https://api.smartdok.no/docs/v1 -o docs/swagger.json
- New endpoints: add a Pydantic model in
rue_models.py(or a new module) with Norwegian field descriptions matching the SmartDok web UI; add the method to the relevant subclient (Rue,Users, orApiClient); add a mocked test intests/test_basic.py. - Public methods get short docstrings; field descriptions live on the Pydantic model.
- Runtime deps go in
[project.dependencies]with>=bounds; dev deps go in[dependency-groups.dev]with exact pins. - Update
README.mdandCHANGELOG.mdfor any user-visible change.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysmartdok-0.1.0a2.tar.gz.
File metadata
- Download URL: pysmartdok-0.1.0a2.tar.gz
- Upload date:
- Size: 52.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
374f3dab9ee3b40f4c450da4a447ea539ec446f7c18ee83bbb43170046257aaf
|
|
| MD5 |
79af600509b895bc23718a921437b6a9
|
|
| BLAKE2b-256 |
0cf718fa1801d04ddd60523fad2bd903cbdb3c132d2ff49b9b2ad7998d8f9e45
|
Provenance
The following attestation bundles were made for pysmartdok-0.1.0a2.tar.gz:
Publisher:
release.yml on asterisk-digital/pysmartdok
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysmartdok-0.1.0a2.tar.gz -
Subject digest:
374f3dab9ee3b40f4c450da4a447ea539ec446f7c18ee83bbb43170046257aaf - Sigstore transparency entry: 1508202008
- Sigstore integration time:
-
Permalink:
asterisk-digital/pysmartdok@8756a5e29d5691e0cf1af89e7177c6dc07e6968e -
Branch / Tag:
refs/tags/v0.1.0a2 - Owner: https://github.com/asterisk-digital
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8756a5e29d5691e0cf1af89e7177c6dc07e6968e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pysmartdok-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: pysmartdok-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56c8fa96dfb3984ffda71dda0e376b2bfe5a336b3bc358463b9e3e7179963e73
|
|
| MD5 |
2be898eced90d22d2943d260400cb5a3
|
|
| BLAKE2b-256 |
335a7458c9f6a431fde2dde9604dfbca54cd3bd5baf3c3aed86b386cf2adca9e
|
Provenance
The following attestation bundles were made for pysmartdok-0.1.0a2-py3-none-any.whl:
Publisher:
release.yml on asterisk-digital/pysmartdok
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pysmartdok-0.1.0a2-py3-none-any.whl -
Subject digest:
56c8fa96dfb3984ffda71dda0e376b2bfe5a336b3bc358463b9e3e7179963e73 - Sigstore transparency entry: 1508202068
- Sigstore integration time:
-
Permalink:
asterisk-digital/pysmartdok@8756a5e29d5691e0cf1af89e7177c6dc07e6968e -
Branch / Tag:
refs/tags/v0.1.0a2 - Owner: https://github.com/asterisk-digital
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8756a5e29d5691e0cf1af89e7177c6dc07e6968e -
Trigger Event:
push
-
Statement type: