catalystwan 0.41.2.dev6__py3-none-any.whl → 0.41.2.dev7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- catalystwan/exceptions.py +4 -4
- catalystwan/integration_tests/feature_profile/test_parcel.py +3 -3
- catalystwan/models/configuration/feature_profile/parcel.py +2 -2
- catalystwan/models/policy/__init__.py +10 -3
- catalystwan/utils/model.py +9 -6
- {catalystwan-0.41.2.dev6.dist-info → catalystwan-0.41.2.dev7.dist-info}/METADATA +1 -1
- {catalystwan-0.41.2.dev6.dist-info → catalystwan-0.41.2.dev7.dist-info}/RECORD +9 -9
- {catalystwan-0.41.2.dev6.dist-info → catalystwan-0.41.2.dev7.dist-info}/LICENSE +0 -0
- {catalystwan-0.41.2.dev6.dist-info → catalystwan-0.41.2.dev7.dist-info}/WHEEL +0 -0
catalystwan/exceptions.py
CHANGED
|
@@ -218,8 +218,8 @@ class CatalystwanDeprecationWarning(DeprecationWarning):
|
|
|
218
218
|
return message
|
|
219
219
|
|
|
220
220
|
|
|
221
|
-
class
|
|
222
|
-
"""Raised when there is no model matching
|
|
221
|
+
class ModelNotFound(CatalystwanException):
|
|
222
|
+
"""Raised when there is no model matching type specifier given as string"""
|
|
223
223
|
|
|
224
|
-
def __init__(self, type_):
|
|
225
|
-
self.message = f"Cannot
|
|
224
|
+
def __init__(self, type_, scope):
|
|
225
|
+
self.message = f"Cannot find model class for {type_} when searching: {scope}"
|
|
@@ -6,7 +6,7 @@ from pydantic import Field
|
|
|
6
6
|
from typing_extensions import Annotated
|
|
7
7
|
|
|
8
8
|
from catalystwan.api.configuration_groups.parcel import _ParcelBase
|
|
9
|
-
from catalystwan.exceptions import
|
|
9
|
+
from catalystwan.exceptions import ModelNotFound
|
|
10
10
|
from catalystwan.models.configuration.feature_profile.parcel import find_type, list_types
|
|
11
11
|
from catalystwan.models.configuration.feature_profile.sdwan.topology import (
|
|
12
12
|
AnyTopologyParcel,
|
|
@@ -27,12 +27,12 @@ def test_find_type():
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def test_find_type_raises_when_no_match():
|
|
30
|
-
with pytest.raises(
|
|
30
|
+
with pytest.raises(ModelNotFound):
|
|
31
31
|
find_type("unknown", AnyTopologyParcel)
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def test_find_type_raises_for_bogus_param():
|
|
35
|
-
with pytest.raises(
|
|
35
|
+
with pytest.raises(ModelNotFound):
|
|
36
36
|
find_type("unknown", None)
|
|
37
37
|
|
|
38
38
|
|
|
@@ -7,7 +7,7 @@ from pydantic import AliasChoices, BaseModel, ConfigDict, Field, model_validator
|
|
|
7
7
|
from typing_extensions import Annotated
|
|
8
8
|
|
|
9
9
|
from catalystwan.api.configuration_groups.parcel import _ParcelBase
|
|
10
|
-
from catalystwan.exceptions import
|
|
10
|
+
from catalystwan.exceptions import ModelNotFound
|
|
11
11
|
from catalystwan.models.configuration.feature_profile.sdwan.application_priority import AnyApplicationPriorityParcel
|
|
12
12
|
from catalystwan.models.configuration.feature_profile.sdwan.cli import AnyCliParcel
|
|
13
13
|
from catalystwan.models.configuration.feature_profile.sdwan.dns_security import AnyDnsSecurityParcel
|
|
@@ -240,5 +240,5 @@ def find_type(name: str, any_union: Type[UT]) -> UT:
|
|
|
240
240
|
try:
|
|
241
241
|
parcel_type = next(t for t in parcel_types if t._get_parcel_type() == name)
|
|
242
242
|
except StopIteration:
|
|
243
|
-
raise
|
|
243
|
+
raise ModelNotFound(name, any_union)
|
|
244
244
|
return cast(UT, parcel_type)
|
|
@@ -7,6 +7,7 @@ from typing import List, Sequence, Type, Union, cast
|
|
|
7
7
|
from pydantic import Field
|
|
8
8
|
from typing_extensions import Annotated
|
|
9
9
|
|
|
10
|
+
from catalystwan.exceptions import ModelNotFound
|
|
10
11
|
from catalystwan.models.policy.definition.app_route import AppRoutePolicy, AppRoutePolicyGetResponse
|
|
11
12
|
from catalystwan.models.policy.definition.dial_peer import DialPeerPolicy, DialPeerPolicyGetResponse
|
|
12
13
|
from catalystwan.models.policy.definition.fxo_port import FxoPortPolicy, FxoPortPolicyGetResponse
|
|
@@ -66,7 +67,7 @@ from catalystwan.models.policy.list.umbrella_data import UmbrellaDataList, Umbre
|
|
|
66
67
|
from catalystwan.models.policy.list.url import URLAllowList, URLAllowListInfo, URLBlockList, URLBlockListInfo
|
|
67
68
|
from catalystwan.models.policy.list.vpn import VPNList, VPNListInfo
|
|
68
69
|
from catalystwan.models.policy.list.zone import ZoneList, ZoneListInfo
|
|
69
|
-
from catalystwan.utils.model import
|
|
70
|
+
from catalystwan.utils.model import get_model_type_literals, resolve_nested_base_model_unions
|
|
70
71
|
|
|
71
72
|
from .centralized import CentralizedPolicy, CentralizedPolicyInfo, TrafficDataDirection
|
|
72
73
|
from .definition.access_control_list import AclPolicy, AclPolicyGetResponse
|
|
@@ -293,7 +294,10 @@ def find_policy_list_model(model_type: str) -> Type[AnyPolicyListInfo]:
|
|
|
293
294
|
Sequence[Type[AnyPolicyListInfo]],
|
|
294
295
|
resolve_nested_base_model_unions(AnyPolicyListInfo),
|
|
295
296
|
)
|
|
296
|
-
|
|
297
|
+
try:
|
|
298
|
+
model = next(t for t in types if model_type in get_model_type_literals(t))
|
|
299
|
+
except StopIteration:
|
|
300
|
+
raise ModelNotFound(model_type, AnyPolicyListInfo)
|
|
297
301
|
return model
|
|
298
302
|
|
|
299
303
|
|
|
@@ -303,7 +307,10 @@ def find_policy_definition_model(model_type: str) -> Type[AnyPolicyDefinitionInf
|
|
|
303
307
|
Sequence[Type[AnyPolicyDefinitionInfo]],
|
|
304
308
|
resolve_nested_base_model_unions(AnyPolicyDefinitionInfo),
|
|
305
309
|
)
|
|
306
|
-
|
|
310
|
+
try:
|
|
311
|
+
model = next(t for t in types if model_type in get_model_type_literals(t))
|
|
312
|
+
except StopIteration:
|
|
313
|
+
raise ModelNotFound(model_type, AnyPolicyDefinitionInfo)
|
|
307
314
|
return model
|
|
308
315
|
|
|
309
316
|
|
catalystwan/utils/model.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright 2024 Cisco Systems, Inc. and its affiliates
|
|
2
2
|
from functools import lru_cache
|
|
3
3
|
from inspect import isclass
|
|
4
|
-
from typing import Any, List,
|
|
4
|
+
from typing import Any, Iterable, List, Literal, Type, Union
|
|
5
5
|
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
from typing_extensions import Annotated, get_args, get_origin
|
|
@@ -38,8 +38,11 @@ def resolve_nested_base_model_unions(
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
@lru_cache
|
|
41
|
-
def
|
|
42
|
-
if type_field := model.model_fields.get(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
def get_model_type_literals(model: Type[BaseModel], field: str = "type") -> Iterable[str]:
|
|
42
|
+
if type_field := model.model_fields.get(field):
|
|
43
|
+
origin = get_origin(type_field.annotation)
|
|
44
|
+
if origin is Literal:
|
|
45
|
+
literal_args = get_args(type_field.annotation)
|
|
46
|
+
if all(isinstance(arg, str) for arg in literal_args):
|
|
47
|
+
return literal_args
|
|
48
|
+
return ()
|
|
@@ -212,7 +212,7 @@ catalystwan/endpoints/tenant_management.py,sha256=c-kIRoS60aVklVPPrmbnW5kaiNgU23
|
|
|
212
212
|
catalystwan/endpoints/tenant_migration.py,sha256=e6eIzRvlrnzUWqamKbWsYjX8drtB-GQKvhrJtX2VDKY,3649
|
|
213
213
|
catalystwan/endpoints/troubleshooting_tools/device_connectivity.py,sha256=JkTZfebTwcambJsgjcJ8qxxBDE5XbUFyYpNqr9681DQ,3661
|
|
214
214
|
catalystwan/endpoints/url_monitoring.py,sha256=ZySOjuCpIAZ4SIsah56yJ-uybYw0W9s6OjQp2FujN0g,802
|
|
215
|
-
catalystwan/exceptions.py,sha256=
|
|
215
|
+
catalystwan/exceptions.py,sha256=fx4TCO1qCYvIilCIjS1PDk-vDW8_s-dS4PtjH1EQCOw,6641
|
|
216
216
|
catalystwan/integration_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
217
217
|
catalystwan/integration_tests/base.py,sha256=0BcKgDZcGjdPH2316C-1Se4FUeAtdrNXdkUVp_aXEZc,2367
|
|
218
218
|
catalystwan/integration_tests/feature_profile/sdwan/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -231,7 +231,7 @@ catalystwan/integration_tests/feature_profile/sdwan/test_system.py,sha256=ab6fG7
|
|
|
231
231
|
catalystwan/integration_tests/feature_profile/sdwan/test_tracker.py,sha256=GnIEHmUoIZObtBK-YvjYYtDsFnGSDpAVwi4rk9-r7XE,5117
|
|
232
232
|
catalystwan/integration_tests/feature_profile/sdwan/test_transport.py,sha256=xRS880JCUD06xL_EaHKNylvaXB9wRHqUYsORhU2MYus,78923
|
|
233
233
|
catalystwan/integration_tests/feature_profile/sdwan/topology/test_topology.py,sha256=2vsAd0pk3wcfo8wFTRttnw4gjSPJi1KFfFCu5lGAiJQ,4340
|
|
234
|
-
catalystwan/integration_tests/feature_profile/test_parcel.py,sha256=
|
|
234
|
+
catalystwan/integration_tests/feature_profile/test_parcel.py,sha256=yIO0Ku2CfsCXxInSJJwRNTvfDw8MI3r1qdvna0yefxk,1499
|
|
235
235
|
catalystwan/integration_tests/profile_builder/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
236
236
|
catalystwan/integration_tests/profile_builder/test_pb_service.py,sha256=WO6VVA7kNXesyGtk67e0lMDZBd4Z8wB7espBh0TzUTA,9420
|
|
237
237
|
catalystwan/integration_tests/profile_builder/test_pb_transport.py,sha256=QQ5f1q6OV9dIyRQy1lb3Wp9beIKaWDaDLnNoGm4XY6A,10376
|
|
@@ -246,7 +246,7 @@ catalystwan/models/configuration/common.py,sha256=2X9gj5awWPKtLPFgWfxhkRrMoX22t1
|
|
|
246
246
|
catalystwan/models/configuration/feature_profile/README.md,sha256=IQMhbnEAbLtotT80aL2emekH-ou8CqR0WSYXhZXilJw,10050
|
|
247
247
|
catalystwan/models/configuration/feature_profile/builder.py,sha256=GDqK7ZxnWHTKWHRw13xvD1aDl60xe6gFsP_B9z5T8a8,663
|
|
248
248
|
catalystwan/models/configuration/feature_profile/common.py,sha256=a5xohaoXzAewtqYYdk2GJy7B-rxxlxYatlP2WZ1eZqY,30423
|
|
249
|
-
catalystwan/models/configuration/feature_profile/parcel.py,sha256=
|
|
249
|
+
catalystwan/models/configuration/feature_profile/parcel.py,sha256=OD7rG4j55M_uAnA_rLGnX_Y0xddcxuEflAOL9-DPXPQ,7582
|
|
250
250
|
catalystwan/models/configuration/feature_profile/sdwan/acl/__init__.py,sha256=-AXvVMLyaAYWUnwzTT_mvar37ZpO2vNRy_ZsUIA5dGo,324
|
|
251
251
|
catalystwan/models/configuration/feature_profile/sdwan/acl/ipv4acl.py,sha256=HpiY0DCZWE9EHCbMbyIJ-iRharSRO3IGcSV3kWbMXjY,12167
|
|
252
252
|
catalystwan/models/configuration/feature_profile/sdwan/acl/ipv6acl.py,sha256=MRtDNb2v1TNNf3yijLFlzL3H1KxHOquPmww1V9ZCacI,12969
|
|
@@ -396,7 +396,7 @@ catalystwan/models/feature_profile_parcel.py,sha256=ddjq8QzqsRv3yBKNDHUf-qgtyeOC
|
|
|
396
396
|
catalystwan/models/misc/application_protocols.py,sha256=DZlBhLEu-HJ4w5cHCtfGWp34I95H4GRsToK1xcJCxK4,785
|
|
397
397
|
catalystwan/models/monitoring/security_policy.py,sha256=WKGu_iHSHOM019dkBKWtyZWSIr9AQ56orQMMthexyB4,346
|
|
398
398
|
catalystwan/models/monitoring/server_info.py,sha256=yToBDkBvuksaiZEaSefZTdh9P6sCVAmglpRYwJDkUWE,405
|
|
399
|
-
catalystwan/models/policy/__init__.py,sha256=
|
|
399
|
+
catalystwan/models/policy/__init__.py,sha256=wtxlHq6TYkII682Him_1796xc6pnyCkn9olE76ls1Ss,14828
|
|
400
400
|
catalystwan/models/policy/centralized.py,sha256=aKwUPxDFr8qzG0w0nVPqyhfDlpKb5dEdsvoeERybT7Y,9151
|
|
401
401
|
catalystwan/models/policy/definition/access_control_list.py,sha256=blcrf2ixd7EJhGq9dPZidBpH3lD5w6BRsOY9AiUQNKA,6397
|
|
402
402
|
catalystwan/models/policy/definition/access_control_list_ipv6.py,sha256=Hxd6CFXiCo3It5hTo9pqAdo191N10uaqbFJKRq_z1FI,6422
|
|
@@ -616,7 +616,7 @@ catalystwan/utils/device_model.py,sha256=IPEQD7yYyhCH91Uw9P-dF34TcIEimYEnImYVaaQ
|
|
|
616
616
|
catalystwan/utils/dict.py,sha256=1IC4pcPFQ7yS39-ZWSFwyCvQKYzfZoxsz3YtJ-S6l7w,2110
|
|
617
617
|
catalystwan/utils/feature_template/choose_model.py,sha256=JoQ7l_TF2PTH8bciOSVAFavevo35n2F4DbusIIvapM8,953
|
|
618
618
|
catalystwan/utils/feature_template/find_template_values.py,sha256=nEi-hFmOaX5cHeS4VBSJmhxIl3jOn42o6mNSkS9Htak,5405
|
|
619
|
-
catalystwan/utils/model.py,sha256=
|
|
619
|
+
catalystwan/utils/model.py,sha256=AbuERvgU_3w16rFaKOA1QM3F-xL7xW13YTB-hFWRIEo,1692
|
|
620
620
|
catalystwan/utils/operation_status.py,sha256=SeT34c_x8F98mwl9x0-klvGTMKbrKSTY_w0zaKyuds8,584
|
|
621
621
|
catalystwan/utils/persona.py,sha256=fZEMM2wgvvSuNaGwsLk-qWJUuZzkhYm1C3YUnRGOqRw,147
|
|
622
622
|
catalystwan/utils/personality.py,sha256=vQ8dKNS6BPAVhRB6IyKRxX2y6a_ukAKBcYnTUuUFgoM,196
|
|
@@ -631,7 +631,7 @@ catalystwan/version.py,sha256=X5yIMPIrWPbdoF9eJfwxfjcvWr7JMfWQF98hQhlGB5I,3032
|
|
|
631
631
|
catalystwan/vmanage_auth.py,sha256=UZ57lTihsLsXw4AdU7Vn8XuY1jo3732Vc9WuFoHSiiQ,10780
|
|
632
632
|
catalystwan/workflows/backup_restore_device_templates.py,sha256=BoR2KlRbpCI6RxIWG7j7tucaLpw5w3ESN20dLhsrZFY,19796
|
|
633
633
|
catalystwan/workflows/tenant_migration.py,sha256=4KLbqUwH4gEegE92PCGfRd226eZd_crCUpaYUWoGXDI,9790
|
|
634
|
-
catalystwan-0.41.2.
|
|
635
|
-
catalystwan-0.41.2.
|
|
636
|
-
catalystwan-0.41.2.
|
|
637
|
-
catalystwan-0.41.2.
|
|
634
|
+
catalystwan-0.41.2.dev7.dist-info/LICENSE,sha256=97ROi91Vxrj_Jio2v8FI9E8-y6x2uYdQRaFlrEbVjkc,11375
|
|
635
|
+
catalystwan-0.41.2.dev7.dist-info/METADATA,sha256=upW34fgE4q1jntiyM33WOUIhkzJJXzO-2yqf9g7w6A4,21275
|
|
636
|
+
catalystwan-0.41.2.dev7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
637
|
+
catalystwan-0.41.2.dev7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|