Skip to content

Commit 5e748b6

Browse files
authored
Feature/update documentation (#6)
- Update automation schedule and Python version in workflows - Add some example code to the documentation - Ditch Python version 3.9
1 parent 51cb33e commit 5e748b6

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

.github/workflows/auto-update.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Auto Update from OpenAPI Spec
22

33
on:
44
schedule:
5-
- cron: "0 4 * * *" # 04:00 UTC daily
5+
- cron: "0 4,10,12,14 * * MON-FRI" # Every two hours 4-14 UTC Monday to Friday
66
workflow_dispatch:
77

88
permissions:
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up Python
3030
uses: actions/setup-python@v5
3131
with:
32-
python-version: '3.11'
32+
python-version: '3.13'
3333

3434
- name: Install generator
3535
run: |
@@ -92,9 +92,9 @@ jobs:
9292
if: steps.download.outputs.changed == 'true'
9393
uses: peter-evans/create-pull-request@v6
9494
with:
95-
commit-message: "chore: update OpenAPI spec to version ${{ steps.regenerate.outputs.updated_version }}"
95+
commit-message: "Update OpenAPI spec to version ${{ steps.regenerate.outputs.updated_version }}"
9696
branch: chore/openapi-spec-v${{ steps.regenerate.outputs.updated_version }}
97-
title: "chore: update OpenAPI spec to version ${{ steps.regenerate.outputs.updated_version }}"
97+
title: "Update OpenAPI spec to version ${{ steps.regenerate.outputs.updated_version }}"
9898
body: |
9999
Automated update for OpenAPI spec version `${{ steps.regenerate.outputs.updated_version }}`.
100100
@@ -104,7 +104,7 @@ jobs:
104104
- Bumped package version in pyproject.toml
105105
106106
After merging this PR, create a GitHub Release (tag `v${{ steps.regenerate.outputs.updated_version }}`) to trigger the publish workflow.
107-
labels: automated, openapi, chore
107+
labels: automated, openapi
108108
signoff: false
109109
draft: false
110110
delete-branch: false

MAINTAINERS_GUIDE.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Maintainers Guide
22

3+
This procedure is not automated and run regularly in github. If the source OpenAPI file has changed, a PR is created.
4+
You only need to create a new release in GitHub to publish the new version to PyPi.
5+
36
See the [Makefile](./Makefile) if you need to install and test locally. Just type `make` to get the help.
47

58
Or just follow these steps:
69

710
## For new API version
811

9-
1. Copy and rename the openapi.yaml the `openapi_specification/nadag-innmelding.yaml`
10-
2. Update the version number in the `config.yaml` file
11-
3. Run the following command to generate the client code:
12+
1. Copy and rename the source openapi file the `openapi_specification/nadag-innmelding.yaml`
13+
2. Run the following command to generate the client code:
1214
```bash
1315
uvx openapi-python-client generate --path openapi_specification/nadag-innmelding.yaml --overwrite --custom-template-path=templates --config config.yaml
1416
```
15-
4. Check in the changes to the repository (files updated, added, or removed).
16-
5. In the GitHub project, create a new release and the package should be published to PyPi.
17+
3. Check in the changes to the repository (files updated, added, or removed).
18+
4. In the GitHub project, create a new release and the package should be published to PyPi.

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,32 @@ pip install nadag-innmelding-python-client
1818
## Usage
1919

2020
```python
21-
21+
from nadag_innmelding_python_client import AuthenticatedClient
22+
from nadag_innmelding_python_client.api.default import get_nadag_innmelding_v_1_geoteknisk_unders as get_geoteknisk_unders
23+
from nadag_innmelding_python_client.models import GeotekniskUnders
24+
from nadag_innmelding_python_client.types import Response
25+
26+
secret_token = nadag_authenticate() # This you need to implement this yourself
27+
28+
client = AuthenticatedClient(
29+
base_url="https://test.ngu.no/api/",
30+
token=secret_token,
31+
)
32+
33+
response: Response[GeotekniskUnders] = get_geoteknisk_unders.sync_detailed(
34+
client=client,
35+
ekstern_id=str(project_id),
36+
ekstern_navnerom="Your Namespace",
37+
)
38+
39+
match response.status_code:
40+
case HTTPStatus.OK:
41+
geoteknisk_unders: GeotekniskUnders = response.parsed
42+
case HTTPStatus.NOT_FOUND:
43+
# Create a new project in NADAG
44+
case _:
45+
# Handle other status codes
46+
raise Exception(f"Got unexpected status code {response.status_code} for project ")
2247
```
2348

2449
## Automation: keeping the client in sync with upstream OpenAPI

templates/pyproject.toml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description = "{{ package_description }}"
1010
authors = ["Jiyang Ye <jiyang[email protected]>"]
1111
maintainers = ["Jiyang Ye <jiyang[email protected]>", "Jostein Leira <jostein[email protected]>"]
1212
readme = "README.md"
13-
{% if pdm %}requires-python = ">=3.9,<4.0"{% endif %}
13+
{% if pdm %}requires-python = ">=3.10,<4.0"{% endif %}
1414
{% if poetry %}
1515
packages = [
1616
{include = "{{ package_name }}"},
@@ -31,7 +31,7 @@ distribution = true
3131
{% if poetry %}
3232

3333
[tool.poetry.dependencies]
34-
python = "^3.9"
34+
python = "^3.13"
3535
httpx = ">=0.20.0,<0.29.0"
3636
attrs = ">=22.2.0"
3737
python-dateutil = "^2.8.0"

0 commit comments

Comments
 (0)