Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 317fc3f

Browse files
author
Jaroslav Tóth
authored
FR-144 Introduction of generated UniConfig model patches (#90)
* FR-144 Generate UniConfig models - unmodified * FR-144 Application of patches to generated UniConfig models - Introduction of custom git patches for generated UniConfig models. - Added UniConfig patches: 1. ignore createsubscription ruff errors 2. fix discover address spell error 3. fix generated port constraints in discover model * FR-144 Ignore patch files in spellcheck action * Fix codespell ignore list * Updated RELEASE.md - version 1.1.1
1 parent bddee98 commit 317fc3f

File tree

9 files changed

+190
-11
lines changed

9 files changed

+190
-11
lines changed

.github/workflows/pr-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
ignore_words_list: .codespellignore
2020
check_filenames: true
2121
check_hidden: false
22+
skip: "*.patch"
2223

2324
changes:
2425
runs-on: ubuntu-latest

uniconfig/python/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@
1515
- Fixed generation of arrays with null type
1616
(added --strict-nullable attribute).
1717
- Bumped version of datamodel-code-generator to 0.25.5.
18+
19+
# 1.1.1
20+
- Introduction of custom git patches for generated UniConfig models.
21+
- Added UniConfig patches:
22+
1. ignore createsubscription ruff errors
23+
2. fix discover address spell error
24+
3. fix generated port constraints in discover model

uniconfig/python/RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
| 5.1.13 | 0.1.0 |
77
| 5.1.16 | 0.1.1 |
88
| 6.0.0 | 1.0.0 |
9-
| 6.0.1 | 1.1.0 |
9+
| 6.0.1 | 1.1.0, 1.1.1 |

uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pydantic import BaseModel
88
from pydantic import ConfigDict
99
from pydantic import Field
10+
from pydantic import RootModel
1011

1112

1213
class TcpPortItem(BaseModel):
@@ -66,6 +67,34 @@ class Input(BaseModel):
6667
udp_port: Optional[list[UdpPortItem]] = Field(None, alias='udp-port')
6768

6869

70+
class AvailableUdpPort(RootModel[int]):
71+
model_config = ConfigDict(
72+
populate_by_name=True,
73+
)
74+
root: int = Field(..., ge=0, le=65535)
75+
76+
77+
class UnavailableTcpPort(RootModel[int]):
78+
model_config = ConfigDict(
79+
populate_by_name=True,
80+
)
81+
root: int = Field(..., ge=0, le=65535)
82+
83+
84+
class AvailableTcpPort(RootModel[int]):
85+
model_config = ConfigDict(
86+
populate_by_name=True,
87+
)
88+
root: int = Field(..., ge=0, le=65535)
89+
90+
91+
class UnavailableUdpPort(RootModel[int]):
92+
model_config = ConfigDict(
93+
populate_by_name=True,
94+
)
95+
root: int = Field(..., ge=0, le=65535)
96+
97+
6998
class DeviceItem(BaseModel):
7099
model_config = ConfigDict(
71100
populate_by_name=True,
@@ -74,8 +103,8 @@ class DeviceItem(BaseModel):
74103
"""
75104
If the host is reachable or not using ICMP protocol
76105
"""
77-
available_udp_ports: Optional[list[int]] = Field(
78-
None, alias='available-udp-ports', ge=0, le=65535
106+
available_udp_ports: Optional[list[AvailableUdpPort]] = Field(
107+
None, alias='available-udp-ports'
79108
)
80109
"""
81110
All the available UDP ports
@@ -84,20 +113,20 @@ class DeviceItem(BaseModel):
84113
"""
85114
Host address either in IP (IPv4 or IPv6) format or in domain-name format
86115
"""
87-
unavailable_tcp_ports: Optional[list[int]] = Field(
88-
None, alias='unavailable-tcp-ports', ge=0, le=65535
116+
unavailable_tcp_ports: Optional[list[UnavailableTcpPort]] = Field(
117+
None, alias='unavailable-tcp-ports'
89118
)
90119
"""
91120
TCP ports that are unreachable
92121
"""
93-
available_tcp_ports: Optional[list[int]] = Field(
94-
None, alias='available-tcp-ports', ge=0, le=65535
122+
available_tcp_ports: Optional[list[AvailableTcpPort]] = Field(
123+
None, alias='available-tcp-ports'
95124
)
96125
"""
97126
All the available TCP ports
98127
"""
99-
unavailable_udp_ports: Optional[list[int]] = Field(
100-
None, alias='unavailable-udp-ports', ge=0, le=65535
128+
unavailable_udp_ports: Optional[list[UnavailableUdpPort]] = Field(
129+
None, alias='unavailable-udp-ports'
101130
)
102131
"""
103132
UDP ports that are unreachable

uniconfig/python/generate.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,21 @@ poetry run datamodel-codegen \
3333
# generate rest_api file to map URL, Method and models from datamodel-codegen
3434
poetry run python3 ./generate_rest_api.py --input /swagger/uniconfig.yaml --output ${REST_API_PATH}
3535

36-
# apply patches
36+
# apply REST API patches
3737
cat ./patches/rest_api_patch.txt >> ${REST_API_PATH}
3838

39+
# apply all git patches
40+
set -e
41+
for patch in $(ls "./patches"/*.patch | sort -n)
42+
do
43+
echo "Applying patch: $patch"
44+
# Check if the patch can be applied
45+
git apply --check "$patch"
46+
# Apply the patch
47+
git apply "$patch"
48+
done
49+
set +e
50+
3951
## use default formatting
4052
poetry run ruff --fix . || true
4153

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/uniconfig/python/frinx_api/uniconfig/notifications/createsubscription.py b/uniconfig/python/frinx_api/uniconfig/notifications/createsubscription.py
2+
index 8ec5b19..f99e267 100644
3+
--- a/uniconfig/python/frinx_api/uniconfig/notifications/createsubscription.py
4+
+++ b/uniconfig/python/frinx_api/uniconfig/notifications/createsubscription.py
5+
@@ -21,7 +21,7 @@ class Input(BaseModel):
6+
all events not precluded by other parameters will
7+
be sent.
8+
"""
9+
- stopTime: Optional[str] = None
10+
+ stopTime: Optional[str] = None # noqa: N815
11+
"""
12+
An optional parameter used with the optional replay
13+
feature to indicate the newest notifications of
14+
@@ -29,7 +29,7 @@ class Input(BaseModel):
15+
will continue until the subscription is terminated.
16+
Must be used with startTime.
17+
"""
18+
- startTime: Optional[str] = None
19+
+ startTime: Optional[str] = None # noqa: N815
20+
"""
21+
A parameter used to trigger the replay feature and
22+
indicates that the replay should start at the time
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py b/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py
2+
index a634140..c725a85 100644
3+
--- a/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py
4+
+++ b/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py
5+
@@ -18,7 +18,7 @@ class TcpPortItem(BaseModel):
6+
start_port: Optional[int] = Field(None, alias='start-port', ge=0, le=65535)
7+
8+
9+
-class Addres(BaseModel):
10+
+class Address(BaseModel):
11+
model_config = ConfigDict(
12+
populate_by_name=True,
13+
)
14+
@@ -62,7 +62,7 @@ class Input(BaseModel):
15+
Check whether the host is reachable or not using ICMP protocol
16+
"""
17+
tcp_port: Optional[list[TcpPortItem]] = Field(None, alias='tcp-port')
18+
- address: Optional[list[Addres]] = None
19+
+ address: Optional[list[Address]] = None
20+
udp_port: Optional[list[UdpPortItem]] = Field(None, alias='udp-port')
21+
22+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
diff --git a/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py b/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py
2+
index f7709b5..66b941f 100644
3+
--- a/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py
4+
+++ b/uniconfig/python/frinx_api/uniconfig/device/discovery/discover.py
5+
@@ -4,7 +4,7 @@ from __future__ import annotations
6+
7+
from typing import Optional
8+
9+
-from pydantic import BaseModel, ConfigDict, Field
10+
+from pydantic import BaseModel, ConfigDict, Field, RootModel
11+
12+
13+
class TcpPortItem(BaseModel):
14+
@@ -64,6 +64,34 @@ class Input(BaseModel):
15+
udp_port: Optional[list[UdpPortItem]] = Field(None, alias='udp-port')
16+
17+
18+
+class AvailableUdpPort(RootModel[int]):
19+
+ model_config = ConfigDict(
20+
+ populate_by_name=True,
21+
+ )
22+
+ root: int = Field(..., ge=0, le=65535)
23+
+
24+
+
25+
+class UnavailableTcpPort(RootModel[int]):
26+
+ model_config = ConfigDict(
27+
+ populate_by_name=True,
28+
+ )
29+
+ root: int = Field(..., ge=0, le=65535)
30+
+
31+
+
32+
+class AvailableTcpPort(RootModel[int]):
33+
+ model_config = ConfigDict(
34+
+ populate_by_name=True,
35+
+ )
36+
+ root: int = Field(..., ge=0, le=65535)
37+
+
38+
+
39+
+class UnavailableUdpPort(RootModel[int]):
40+
+ model_config = ConfigDict(
41+
+ populate_by_name=True,
42+
+ )
43+
+ root: int = Field(..., ge=0, le=65535)
44+
+
45+
+
46+
class DeviceItem(BaseModel):
47+
model_config = ConfigDict(
48+
populate_by_name=True,
49+
@@ -72,8 +100,8 @@ class DeviceItem(BaseModel):
50+
"""
51+
If the host is reachable or not using ICMP protocol
52+
"""
53+
- available_udp_ports: Optional[list[int]] = Field(
54+
- None, alias='available-udp-ports', ge=0, le=65535
55+
+ available_udp_ports: Optional[list[AvailableUdpPort]] = Field(
56+
+ None, alias='available-udp-ports'
57+
)
58+
"""
59+
All the available UDP ports
60+
@@ -82,20 +110,20 @@ class DeviceItem(BaseModel):
61+
"""
62+
Host address either in IP (IPv4 or IPv6) format or in domain-name format
63+
"""
64+
- unavailable_tcp_ports: Optional[list[int]] = Field(
65+
- None, alias='unavailable-tcp-ports', ge=0, le=65535
66+
+ unavailable_tcp_ports: Optional[list[UnavailableTcpPort]] = Field(
67+
+ None, alias='unavailable-tcp-ports'
68+
)
69+
"""
70+
TCP ports that are unreachable
71+
"""
72+
- available_tcp_ports: Optional[list[int]] = Field(
73+
- None, alias='available-tcp-ports', ge=0, le=65535
74+
+ available_tcp_ports: Optional[list[AvailableTcpPort]] = Field(
75+
+ None, alias='available-tcp-ports'
76+
)
77+
"""
78+
All the available TCP ports
79+
"""
80+
- unavailable_udp_ports: Optional[list[int]] = Field(
81+
- None, alias='unavailable-udp-ports', ge=0, le=65535
82+
+ unavailable_udp_ports: Optional[list[UnavailableUdpPort]] = Field(
83+
+ None, alias='unavailable-udp-ports'
84+
)
85+
"""
86+
UDP ports that are unreachable

uniconfig/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ packages = [{ include = "frinx_api" }]
1919
name = "frinx-uniconfig-api"
2020
description = "Python SDK for Frinx Machine Workflow Manager"
2121
authors = ["Jozef Volak <[email protected]>"]
22-
version = "1.1.0"
22+
version = "1.1.1"
2323
readme = ["README.md", "CHANGELOG.md", "RELEASE.md"]
2424
keywords = ["frinx-machine", "uniconfig", "conductor"]
2525
license = "Apache 2.0"

0 commit comments

Comments
 (0)