Skip to content

Commit 201f6b9

Browse files
Update OpenAPI spec to version 2025.10.10 (#14)
Co-authored-by: josteinl <[email protected]>
1 parent 7476293 commit 201f6b9

File tree

5 files changed

+304
-77
lines changed

5 files changed

+304
-77
lines changed

nadag-innmelding-python-client/README.md

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,62 @@ A client library for accessing Nadag innmelding API
55
First, create a client:
66

77
```python
8-
from nadag_innmelding_python_client import AuthenticatedClient
8+
from nadag_innmelding_python_client import Client
99

10-
secret_token = nadag_authenticate() # This you need to implement this yourself
10+
client = Client(base_url="https://api.example.com")
11+
```
1112

12-
client = AuthenticatedClient(
13-
base_url="https://test.ngu.no/api/",
14-
token=secret_token,
15-
)
13+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
1614

15+
```python
16+
from nadag_innmelding_python_client import AuthenticatedClient
17+
18+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
1719
```
1820

1921
Now call your endpoint and use your models:
2022

2123
```python
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.models import MyDataModel
25+
from nadag_innmelding_python_client.api.my_tag import get_my_data_model
2426
from nadag_innmelding_python_client.types import Response
2527

2628
with client as client:
27-
response: Response[GeotekniskUnders] = get_geoteknisk_unders.sync_detailed(
28-
client=client,
29-
ekstern_id=str(project_id),
30-
ekstern_navnerom="Your Namespace",
31-
)
32-
33-
match response.status_code:
34-
case HTTPStatus.OK:
35-
geoteknisk_unders: GeotekniskUnders = response.parsed
36-
case HTTPStatus.NOT_FOUND:
37-
# Create a new project in NADAG
38-
case _:
39-
# Handle other status codes
40-
raise Exception(f"Got unexpected status code {response.status_code} for project ")
29+
my_data: MyDataModel = get_my_data_model.sync(client=client)
30+
# or if you need more info (e.g. status_code)
31+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
32+
```
33+
34+
Or do the same thing with an async version:
35+
36+
```python
37+
from nadag_innmelding_python_client.models import MyDataModel
38+
from nadag_innmelding_python_client.api.my_tag import get_my_data_model
39+
from nadag_innmelding_python_client.types import Response
4140

41+
async with client as client:
42+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
43+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
44+
```
45+
46+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
47+
48+
```python
49+
client = AuthenticatedClient(
50+
base_url="https://internal_api.example.com",
51+
token="SuperSecretToken",
52+
verify_ssl="/path/to/certificate_bundle.pem",
53+
)
54+
```
55+
56+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
57+
58+
```python
59+
client = AuthenticatedClient(
60+
base_url="https://internal_api.example.com",
61+
token="SuperSecretToken",
62+
verify_ssl=False
63+
)
4264
```
4365

4466
Things to know:

nadag-innmelding-python-client/nadag_innmelding_python_client/api/default/post_nadag_innmelding_v_1_geoteknisk_borehull.py renamed to nadag-innmelding-python-client/nadag_innmelding_python_client/api/default/get_nadag_innmelding_v_1_kodeliste_code_list_name.py

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,29 @@
55

66
from ... import errors
77
from ...client import AuthenticatedClient, Client
8-
from ...models.ekstern_identifikasjon import EksternIdentifikasjon
9-
from ...models.geoteknisk_borehull import GeotekniskBorehull
8+
from ...models.geoteknisk_unders import GeotekniskUnders
109
from ...types import Response
1110

1211

1312
def _get_kwargs(
14-
*,
15-
body: EksternIdentifikasjon,
13+
code_list_name: str,
1614
) -> dict[str, Any]:
17-
headers: dict[str, Any] = {}
18-
1915
_kwargs: dict[str, Any] = {
20-
"method": "post",
21-
"url": "/nadag/innmelding/v1/GeotekniskBorehull",
16+
"method": "get",
17+
"url": f"/nadag/innmelding/v1/kodeliste/{code_list_name}",
2218
}
2319

24-
_kwargs["json"] = body.to_dict()
25-
26-
headers["Content-Type"] = "application/json"
27-
28-
_kwargs["headers"] = headers
2920
return _kwargs
3021

3122

3223
def _parse_response(
3324
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
34-
) -> Optional[Union[Any, GeotekniskBorehull]]:
25+
) -> Optional[Union[Any, GeotekniskUnders]]:
3526
if response.status_code == 200:
36-
response_200 = GeotekniskBorehull.from_dict(response.json())
27+
response_200 = GeotekniskUnders.from_dict(response.json())
3728

3829
return response_200
3930

40-
if response.status_code == 401:
41-
response_401 = cast(Any, None)
42-
return response_401
43-
4431
if response.status_code == 404:
4532
response_404 = cast(Any, None)
4633
return response_404
@@ -53,7 +40,7 @@ def _parse_response(
5340

5441
def _build_response(
5542
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
56-
) -> Response[Union[Any, GeotekniskBorehull]]:
43+
) -> Response[Union[Any, GeotekniskUnders]]:
5744
return Response(
5845
status_code=HTTPStatus(response.status_code),
5946
content=response.content,
@@ -63,28 +50,27 @@ def _build_response(
6350

6451

6552
def sync_detailed(
53+
code_list_name: str,
6654
*,
6755
client: Union[AuthenticatedClient, Client],
68-
body: EksternIdentifikasjon,
69-
) -> Response[Union[Any, GeotekniskBorehull]]:
70-
"""Fetches a GeotekniskBorehull by external id.
56+
) -> Response[Union[Any, GeotekniskUnders]]:
57+
"""Retrieves a list of codes and their labels.
7158
72-
Fetches a GeotekniskBorehull by external id. Returns the most recent one.
59+
Fetches a list of codes and their labels.
7360
7461
Args:
75-
body (EksternIdentifikasjon): Identifikasjon av et objekt, ivaretatt av den ansvarlige
76-
leverandør inn til NADAG.
62+
code_list_name (str):
7763
7864
Raises:
7965
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
8066
httpx.TimeoutException: If the request takes longer than Client.timeout.
8167
8268
Returns:
83-
Response[Union[Any, GeotekniskBorehull]]
69+
Response[Union[Any, GeotekniskUnders]]
8470
"""
8571

8672
kwargs = _get_kwargs(
87-
body=body,
73+
code_list_name=code_list_name,
8874
)
8975

9076
response = client.get_httpx_client().request(
@@ -95,55 +81,53 @@ def sync_detailed(
9581

9682

9783
def sync(
84+
code_list_name: str,
9885
*,
9986
client: Union[AuthenticatedClient, Client],
100-
body: EksternIdentifikasjon,
101-
) -> Optional[Union[Any, GeotekniskBorehull]]:
102-
"""Fetches a GeotekniskBorehull by external id.
87+
) -> Optional[Union[Any, GeotekniskUnders]]:
88+
"""Retrieves a list of codes and their labels.
10389
104-
Fetches a GeotekniskBorehull by external id. Returns the most recent one.
90+
Fetches a list of codes and their labels.
10591
10692
Args:
107-
body (EksternIdentifikasjon): Identifikasjon av et objekt, ivaretatt av den ansvarlige
108-
leverandør inn til NADAG.
93+
code_list_name (str):
10994
11095
Raises:
11196
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
11297
httpx.TimeoutException: If the request takes longer than Client.timeout.
11398
11499
Returns:
115-
Union[Any, GeotekniskBorehull]
100+
Union[Any, GeotekniskUnders]
116101
"""
117102

118103
return sync_detailed(
104+
code_list_name=code_list_name,
119105
client=client,
120-
body=body,
121106
).parsed
122107

123108

124109
async def asyncio_detailed(
110+
code_list_name: str,
125111
*,
126112
client: Union[AuthenticatedClient, Client],
127-
body: EksternIdentifikasjon,
128-
) -> Response[Union[Any, GeotekniskBorehull]]:
129-
"""Fetches a GeotekniskBorehull by external id.
113+
) -> Response[Union[Any, GeotekniskUnders]]:
114+
"""Retrieves a list of codes and their labels.
130115
131-
Fetches a GeotekniskBorehull by external id. Returns the most recent one.
116+
Fetches a list of codes and their labels.
132117
133118
Args:
134-
body (EksternIdentifikasjon): Identifikasjon av et objekt, ivaretatt av den ansvarlige
135-
leverandør inn til NADAG.
119+
code_list_name (str):
136120
137121
Raises:
138122
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
139123
httpx.TimeoutException: If the request takes longer than Client.timeout.
140124
141125
Returns:
142-
Response[Union[Any, GeotekniskBorehull]]
126+
Response[Union[Any, GeotekniskUnders]]
143127
"""
144128

145129
kwargs = _get_kwargs(
146-
body=body,
130+
code_list_name=code_list_name,
147131
)
148132

149133
response = await client.get_async_httpx_client().request(**kwargs)
@@ -152,29 +136,28 @@ async def asyncio_detailed(
152136

153137

154138
async def asyncio(
139+
code_list_name: str,
155140
*,
156141
client: Union[AuthenticatedClient, Client],
157-
body: EksternIdentifikasjon,
158-
) -> Optional[Union[Any, GeotekniskBorehull]]:
159-
"""Fetches a GeotekniskBorehull by external id.
142+
) -> Optional[Union[Any, GeotekniskUnders]]:
143+
"""Retrieves a list of codes and their labels.
160144
161-
Fetches a GeotekniskBorehull by external id. Returns the most recent one.
145+
Fetches a list of codes and their labels.
162146
163147
Args:
164-
body (EksternIdentifikasjon): Identifikasjon av et objekt, ivaretatt av den ansvarlige
165-
leverandør inn til NADAG.
148+
code_list_name (str):
166149
167150
Raises:
168151
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
169152
httpx.TimeoutException: If the request takes longer than Client.timeout.
170153
171154
Returns:
172-
Union[Any, GeotekniskBorehull]
155+
Union[Any, GeotekniskUnders]
173156
"""
174157

175158
return (
176159
await asyncio_detailed(
160+
code_list_name=code_list_name,
177161
client=client,
178-
body=body,
179162
)
180163
).parsed

0 commit comments

Comments
 (0)