Skip to content

Commit 0bc4c81

Browse files
committed
Fix definition for alias update/add
The API expects the base alias structure directly instead of nested values.
1 parent 078bbb8 commit 0bc4c81

File tree

9 files changed

+341
-120
lines changed

9 files changed

+341
-120
lines changed

docs/index.html

Lines changed: 13 additions & 5 deletions
Large diffs are not rendered by default.

pfapi_openapi.yml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ paths:
116116
content:
117117
application/json:
118118
schema:
119-
$ref: '#/components/schemas/FWUpdateAliasreq'
119+
$ref: '#/components/schemas/FWUpdateAliasReq'
120120
responses:
121121
'200':
122122
description: ok
@@ -15523,9 +15523,29 @@ components:
1552315523
type: boolean
1552415524
FWAliasReq:
1552515525
type: object
15526+
required: [name]
1552615527
properties:
15527-
alias:
15528-
$ref: '#/components/schemas/FWAlias'
15528+
name:
15529+
type: string
15530+
address:
15531+
type: string
15532+
description: space separated list of addresses
15533+
targets:
15534+
type: array
15535+
items:
15536+
$ref: '#/components/schemas/FWTarget'
15537+
descr:
15538+
type: string
15539+
type:
15540+
type: string
15541+
description: host, network, url, urltable, urltable_ports, port, or url_ports
15542+
enum: ['host', 'network', 'url', 'urltable', 'urltable_ports', 'port', 'url_ports']
15543+
detail:
15544+
type: string
15545+
updatefreq:
15546+
type: string
15547+
truncated:
15548+
type: boolean
1552915549
FWAliases:
1553015550
type: object
1553115551
properties:
@@ -15875,13 +15895,31 @@ components:
1587515895
properties:
1587615896
status:
1587715897
$ref: '#/components/schemas/ToggleRespStatus'
15878-
FWUpdateAliasreq:
15898+
FWUpdateAliasReq:
1587915899
type: object
15900+
required: [name]
1588015901
properties:
15881-
alias:
15882-
$ref: '#/components/schemas/FWAlias'
15883-
id:
15902+
name:
15903+
type: string
15904+
address:
1588415905
type: string
15906+
description: space separated list of addresses
15907+
targets:
15908+
type: array
15909+
items:
15910+
$ref: '#/components/schemas/FWTarget'
15911+
descr:
15912+
type: string
15913+
type:
15914+
type: string
15915+
description: host, network, url, urltable, urltable_ports, port, or url_ports
15916+
enum: ['host', 'network', 'url', 'urltable', 'urltable_ports', 'port', 'url_ports']
15917+
detail:
15918+
type: string
15919+
updatefreq:
15920+
type: string
15921+
truncated:
15922+
type: boolean
1588515923
FWUserTimestamp:
1588615924
type: object
1588715925
properties:

py/pfapi/api/aliases/firewall_update_alias.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from ... import errors
77
from ...client import AuthenticatedClient, Client
88
from ...models.error import Error
9-
from ...models.fw_update_aliasreq import FWUpdateAliasreq
9+
from ...models.fw_update_alias_req import FWUpdateAliasReq
1010
from ...models.pfsense_result import PfsenseResult
1111
from ...types import Response
1212

1313

1414
def _get_kwargs(
1515
id: str,
1616
*,
17-
body: FWUpdateAliasreq,
17+
body: FWUpdateAliasReq,
1818
) -> Dict[str, Any]:
1919
headers: Dict[str, Any] = {}
2020

@@ -64,13 +64,13 @@ def sync_detailed(
6464
id: str,
6565
*,
6666
client: Union[AuthenticatedClient, Client],
67-
body: FWUpdateAliasreq,
67+
body: FWUpdateAliasReq,
6868
) -> Response[Union[Error, PfsenseResult]]:
6969
"""Update firewall alias
7070
7171
Args:
7272
id (str):
73-
body (FWUpdateAliasreq):
73+
body (FWUpdateAliasReq):
7474
7575
Raises:
7676
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -96,13 +96,13 @@ def sync(
9696
id: str,
9797
*,
9898
client: Union[AuthenticatedClient, Client],
99-
body: FWUpdateAliasreq,
99+
body: FWUpdateAliasReq,
100100
) -> Optional[Union[Error, PfsenseResult]]:
101101
"""Update firewall alias
102102
103103
Args:
104104
id (str):
105-
body (FWUpdateAliasreq):
105+
body (FWUpdateAliasReq):
106106
107107
Raises:
108108
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -123,13 +123,13 @@ async def asyncio_detailed(
123123
id: str,
124124
*,
125125
client: Union[AuthenticatedClient, Client],
126-
body: FWUpdateAliasreq,
126+
body: FWUpdateAliasReq,
127127
) -> Response[Union[Error, PfsenseResult]]:
128128
"""Update firewall alias
129129
130130
Args:
131131
id (str):
132-
body (FWUpdateAliasreq):
132+
body (FWUpdateAliasReq):
133133
134134
Raises:
135135
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -153,13 +153,13 @@ async def asyncio(
153153
id: str,
154154
*,
155155
client: Union[AuthenticatedClient, Client],
156-
body: FWUpdateAliasreq,
156+
body: FWUpdateAliasReq,
157157
) -> Optional[Union[Error, PfsenseResult]]:
158158
"""Update firewall alias
159159
160160
Args:
161161
id (str):
162-
body (FWUpdateAliasreq):
162+
body (FWUpdateAliasReq):
163163
164164
Raises:
165165
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.

py/pfapi/models/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248
from .fw_addr_port import FWAddrPort
249249
from .fw_alias import FWAlias
250250
from .fw_alias_req import FWAliasReq
251+
from .fw_alias_req_type import FWAliasReqType
251252
from .fw_alias_type import FWAliasType
252253
from .fw_aliases import FWAliases
253254
from .fw_bogon_rule import FWBogonRule
@@ -275,7 +276,8 @@
275276
from .fw_system_alias import FWSystemAlias
276277
from .fw_target import FWTarget
277278
from .fw_toggle_result import FWToggleResult
278-
from .fw_update_aliasreq import FWUpdateAliasreq
279+
from .fw_update_alias_req import FWUpdateAliasReq
280+
from .fw_update_alias_req_type import FWUpdateAliasReqType
279281
from .fw_user_timestamp import FWUserTimestamp
280282
from .gateway import Gateway
281283
from .gateway_defaults import GatewayDefaults
@@ -925,6 +927,7 @@
925927
"FWAlias",
926928
"FWAliases",
927929
"FWAliasReq",
930+
"FWAliasReqType",
928931
"FWAliasType",
929932
"FWBogonRule",
930933
"FWBogonState",
@@ -951,7 +954,8 @@
951954
"FWSystemAlias",
952955
"FWTarget",
953956
"FWToggleResult",
954-
"FWUpdateAliasreq",
957+
"FWUpdateAliasReq",
958+
"FWUpdateAliasReqType",
955959
"FWUserTimestamp",
956960
"Gateway",
957961
"GatewayDefaults",

py/pfapi/models/fw_alias_req.py

Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
from attrs import define as _attrs_define
44
from attrs import field as _attrs_field
55

6+
from ..models.fw_alias_req_type import FWAliasReqType
67
from ..types import UNSET, Unset
78

89
if TYPE_CHECKING:
9-
from ..models.fw_alias import FWAlias
10+
from ..models.fw_target import FWTarget
1011

1112

1213
T = TypeVar("T", bound="FWAliasReq")
@@ -16,39 +17,114 @@
1617
class FWAliasReq:
1718
"""
1819
Attributes:
19-
alias (Union[Unset, FWAlias]):
20+
name (str):
21+
address (Union[Unset, str]): space separated list of addresses
22+
targets (Union[Unset, List['FWTarget']]):
23+
descr (Union[Unset, str]):
24+
type (Union[Unset, FWAliasReqType]): host, network, url, urltable, urltable_ports, port, or url_ports
25+
detail (Union[Unset, str]):
26+
updatefreq (Union[Unset, str]):
27+
truncated (Union[Unset, bool]):
2028
"""
2129

22-
alias: Union[Unset, "FWAlias"] = UNSET
30+
name: str
31+
address: Union[Unset, str] = UNSET
32+
targets: Union[Unset, List["FWTarget"]] = UNSET
33+
descr: Union[Unset, str] = UNSET
34+
type: Union[Unset, FWAliasReqType] = UNSET
35+
detail: Union[Unset, str] = UNSET
36+
updatefreq: Union[Unset, str] = UNSET
37+
truncated: Union[Unset, bool] = UNSET
2338
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
2439

2540
def to_dict(self) -> Dict[str, Any]:
26-
alias: Union[Unset, Dict[str, Any]] = UNSET
27-
if not isinstance(self.alias, Unset):
28-
alias = self.alias.to_dict()
41+
name = self.name
42+
43+
address = self.address
44+
45+
targets: Union[Unset, List[Dict[str, Any]]] = UNSET
46+
if not isinstance(self.targets, Unset):
47+
targets = []
48+
for targets_item_data in self.targets:
49+
targets_item = targets_item_data.to_dict()
50+
targets.append(targets_item)
51+
52+
descr = self.descr
53+
54+
type: Union[Unset, str] = UNSET
55+
if not isinstance(self.type, Unset):
56+
type = self.type.value
57+
58+
detail = self.detail
59+
60+
updatefreq = self.updatefreq
61+
62+
truncated = self.truncated
2963

3064
field_dict: Dict[str, Any] = {}
3165
field_dict.update(self.additional_properties)
32-
field_dict.update({})
33-
if alias is not UNSET:
34-
field_dict["alias"] = alias
66+
field_dict.update(
67+
{
68+
"name": name,
69+
}
70+
)
71+
if address is not UNSET:
72+
field_dict["address"] = address
73+
if targets is not UNSET:
74+
field_dict["targets"] = targets
75+
if descr is not UNSET:
76+
field_dict["descr"] = descr
77+
if type is not UNSET:
78+
field_dict["type"] = type
79+
if detail is not UNSET:
80+
field_dict["detail"] = detail
81+
if updatefreq is not UNSET:
82+
field_dict["updatefreq"] = updatefreq
83+
if truncated is not UNSET:
84+
field_dict["truncated"] = truncated
3585

3686
return field_dict
3787

3888
@classmethod
3989
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
40-
from ..models.fw_alias import FWAlias
90+
from ..models.fw_target import FWTarget
4191

4292
d = src_dict.copy()
43-
_alias = d.pop("alias", UNSET)
44-
alias: Union[Unset, FWAlias]
45-
if isinstance(_alias, Unset):
46-
alias = UNSET
93+
name = d.pop("name")
94+
95+
address = d.pop("address", UNSET)
96+
97+
targets = []
98+
_targets = d.pop("targets", UNSET)
99+
for targets_item_data in _targets or []:
100+
targets_item = FWTarget.from_dict(targets_item_data)
101+
102+
targets.append(targets_item)
103+
104+
descr = d.pop("descr", UNSET)
105+
106+
_type = d.pop("type", UNSET)
107+
type: Union[Unset, FWAliasReqType]
108+
if isinstance(_type, Unset):
109+
type = UNSET
47110
else:
48-
alias = FWAlias.from_dict(_alias)
111+
type = FWAliasReqType(_type)
112+
113+
detail = d.pop("detail", UNSET)
114+
115+
updatefreq = d.pop("updatefreq", UNSET)
116+
117+
truncated = d.pop("truncated", UNSET)
49118

50119
fw_alias_req = cls(
51-
alias=alias,
120+
name=name,
121+
address=address,
122+
targets=targets,
123+
descr=descr,
124+
type=type,
125+
detail=detail,
126+
updatefreq=updatefreq,
127+
truncated=truncated,
52128
)
53129

54130
fw_alias_req.additional_properties = d
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from enum import Enum
2+
3+
4+
class FWAliasReqType(str, Enum):
5+
HOST = "host"
6+
NETWORK = "network"
7+
PORT = "port"
8+
URL = "url"
9+
URLTABLE = "urltable"
10+
URLTABLE_PORTS = "urltable_ports"
11+
URL_PORTS = "url_ports"
12+
13+
def __str__(self) -> str:
14+
return str(self.value)

0 commit comments

Comments
 (0)