Skip to content
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
460 commits
Select commit Hold shift + click to select a range
85948ce
diff_for_attach_deploy: update comments
allenrobel May 27, 2025
8b221f2
format_diff_orig: remove
allenrobel May 27, 2025
4cd1e54
get_diff_delete: refactor
allenrobel May 27, 2025
6bf426c
get_diff_replaced: refactor
allenrobel May 27, 2025
b0e02e0
Remove original methods
allenrobel May 28, 2025
4940751
update_vrf_attach_vrf_lite_extensions: initial refactor
allenrobel May 28, 2025
c28eb00
update_vrf_attach_vrf_lite_extensions_orig: remove
allenrobel May 28, 2025
15e5980
update_lan_attach_list: return pydantic model
allenrobel May 28, 2025
794e87c
Remove original methods, update docstrings
allenrobel May 29, 2025
199b67e
_update_vrf_lite_extension: use vrf_lite model
allenrobel May 29, 2025
a6464df
get_vrf_lite_objects_model: update and rename
allenrobel May 29, 2025
f15fec2
compare_properties: rename to property_values_match
allenrobel May 29, 2025
7d59b56
get_vrf_objects -> get_controller_vrf_object_models
allenrobel May 29, 2025
c0263cc
Update log messages
allenrobel May 29, 2025
37c92b6
Remove duplicate line
allenrobel May 29, 2025
6daf6a6
get_vrf_lan_attach_list -> get_controller_vrf_attachment_models
allenrobel May 29, 2025
06f53e0
Rename vars for readability
allenrobel May 29, 2025
d73d602
get_diff_replace: rename vars
allenrobel May 29, 2025
b8af9ea
get_diff_replace: rename vars (part 2)
allenrobel May 29, 2025
e9beef7
diff_merge_attach: rename vars for readability
allenrobel May 29, 2025
ca2cc30
diff_for_attach_deploy: rename vars for readability
allenrobel May 29, 2025
6e6dadf
Appease pep8 linter
allenrobel May 29, 2025
3d12b57
Fix two unit tests, replace dcnm_get_url
allenrobel May 30, 2025
796cf8d
Cleanup debug log messages
allenrobel May 30, 2025
073101b
Experimental commit
allenrobel May 31, 2025
20a005e
Appease pylint
allenrobel May 31, 2025
29a9c4d
Appease pep8
allenrobel May 31, 2025
3bbf62d
Update sanity/ignore-*.txt
allenrobel May 31, 2025
93a2f24
sanity/ignore-*.txt remove duplicate lines
allenrobel May 31, 2025
7fde7b4
Fix type hints
allenrobel May 31, 2025
8cc66de
Appease pylint
allenrobel May 31, 2025
8bbd9fc
DcnmVrfV12: add var self.have_attach_model
allenrobel May 31, 2025
0f43f37
HaveLanAttachItem: Accept a null vlan (vlanId)
allenrobel May 31, 2025
f0bf463
_deployment_status_match: Add debug logs
allenrobel May 31, 2025
6948df0
diff_merge_attach: Add debug logs
allenrobel May 31, 2025
1accc6a
Modifications for model-based delete state
allenrobel Jun 1, 2025
fb68ca1
Update sanity/ignore-*.txt
allenrobel Jun 1, 2025
a540003
Add logs to debug integration test failures
allenrobel Jun 1, 2025
8336977
Appease pylint
allenrobel Jun 1, 2025
afec3cf
Add logs to debug integration test failures (part 2)
allenrobel Jun 1, 2025
8e2091b
Add logs to debug integration test failures (part 3)
allenrobel Jun 2, 2025
6b8f19c
Appease pylint
allenrobel Jun 2, 2025
113c3da
Fix for integration test errors
allenrobel Jun 2, 2025
c195903
Update copyright
allenrobel Jun 2, 2025
ed626f4
Rename model file
allenrobel Jun 2, 2025
b029d17
Forgot to add dcnm_vrf_v12.py to the last commit
allenrobel Jun 2, 2025
531eef5
IT: Try fix for replaced-state integration test
allenrobel Jun 2, 2025
fab3b19
IT: logs to debug replaced-state failure, more…
allenrobel Jun 2, 2025
0e58547
IT: logs to debug replaced-state failure (part 2)
allenrobel Jun 2, 2025
ff30165
Appease pylint
allenrobel Jun 2, 2025
f4c59e5
Experimental: push_diff_attach_model
allenrobel Jun 2, 2025
12da88f
Appease pylint, update sanity/ignore-*.txt
allenrobel Jun 2, 2025
bb8e83e
Forgot to add new model to the last couple commits
allenrobel Jun 2, 2025
d936a22
Appease pylint
allenrobel Jun 2, 2025
5d412c3
IT: Potential fix for replaced-state test failure
allenrobel Jun 2, 2025
5b13f7e
Appease pylint
allenrobel Jun 2, 2025
3c13755
update_lan_attach_list: fabricName -> fabric, more
allenrobel Jun 2, 2025
f9e7a5e
push_diff_detach: fabricName -> fabric
allenrobel Jun 2, 2025
52a9149
VrfAttachPayloadV12: fix vlan field
allenrobel Jun 2, 2025
e4e4d55
get_items_to_detach_model: Modify return value
allenrobel Jun 2, 2025
72a06b6
IT: Cleanup after verifying integration passes
allenrobel Jun 3, 2025
34590ac
Add debugs for self.model_enabled
allenrobel Jun 3, 2025
eb7a38f
update_lan_attach_list : Rework legacy code
allenrobel Jun 4, 2025
018544f
Appease pylint
allenrobel Jun 4, 2025
baf0733
Appease pep8
allenrobel Jun 4, 2025
87a9f71
update_vrf_lite_extensions_new: fix nbr_dict update
allenrobel Jun 4, 2025
40f985b
Try fix for null vlan in diff_attach.
allenrobel Jun 4, 2025
4a66606
push_diff_attach_model: append directly to payload
allenrobel Jun 4, 2025
f4e9e05
push_diff_attach_model: refactor
allenrobel Jun 4, 2025
10d5e69
update_lan_attach_list_vrf_lite: rename vrf_attach
allenrobel Jun 4, 2025
533a0ae
Remove legacy code
allenrobel Jun 4, 2025
a95443f
Rename vars/methods to reduce cognitive load
allenrobel Jun 4, 2025
861b3f3
want_create: initial changes to leverage playbook model
allenrobel Jun 5, 2025
62137f9
Remove legacy code, more…
allenrobel Jun 5, 2025
01317a7
Experimental: Move methods to separate class
allenrobel Jun 6, 2025
79e9e44
Appease pep8
allenrobel Jun 6, 2025
d9b11d5
Update tests/sanity-*.txt with new files
allenrobel Jun 6, 2025
08f1448
SerialNumberToVrfLite: rename method
allenrobel Jun 6, 2025
3e8ccf3
get_diff_override: Convert to model-based, more…
allenrobel Jun 6, 2025
6d30e22
Fix log message
allenrobel Jun 6, 2025
6c02d3c
update_attach_params: Rename method for clarity
allenrobel Jun 6, 2025
bb09900
Utility classes for fabric_inventory conversions
allenrobel Jun 7, 2025
3e9bb40
push_diff_detach: divert to push_diff_detach_model
allenrobel Jun 7, 2025
fb6e2a7
IT: Potential fix for overridden-state failure
allenrobel Jun 7, 2025
fbf2198
update_have_attach_lan_detach_list: remove
allenrobel Jun 7, 2025
cc410a5
get_diff_override_model: remove intermediate vars
allenrobel Jun 7, 2025
6761e39
get_diff_override_model: reverse logic and dedent
allenrobel Jun 7, 2025
7ace6bf
get_diff_replace: simplification (part 1)
allenrobel Jun 7, 2025
42737ed
Use send_to_controller in more methods
allenrobel Jun 8, 2025
830d182
Appease pep8
allenrobel Jun 8, 2025
1d1d7be
Fix args to send_to_controller
allenrobel Jun 8, 2025
ab793c2
New models
allenrobel Jun 8, 2025
3d6831b
Appease Ansible sanity import tests
allenrobel Jun 8, 2025
976e316
Fix SendToController(action=) in two methods
allenrobel Jun 8, 2025
a99f15b
send_to_controller: use an optional response model
allenrobel Jun 8, 2025
5edd5fa
Retain UPPER_CASE fields for controller responses
allenrobel Jun 8, 2025
98b1ec1
Appease pep8
allenrobel Jun 8, 2025
d13aca6
Fix model alias
allenrobel Jun 8, 2025
bcab423
Standardize controller response model filenames
allenrobel Jun 9, 2025
680dc65
Controller response model cleanup (part 1)
allenrobel Jun 9, 2025
a0ea059
Appease linters
allenrobel Jun 9, 2025
10fdf75
Add temporary debug message
allenrobel Jun 9, 2025
79aff90
Appease linters
allenrobel Jun 9, 2025
3cc296e
Add REQUEST_PATH to controller response models, more…
allenrobel Jun 10, 2025
461b86b
UT: Use older fixtures for DCNMv11 unit tests
allenrobel Jun 10, 2025
96ed598
Standardize var names
allenrobel Jun 10, 2025
940d406
VrfTemplateConfigV12: bgp_passwd_encrypt validator
allenrobel Jun 10, 2025
4a89619
Revert last commit
allenrobel Jun 10, 2025
2a516d2
want_create: model-based handling, initial commit
allenrobel Jun 10, 2025
cb766ef
want_create -> want_create_models (part 2)
allenrobel Jun 10, 2025
4e727fb
want_create -> want_create_models (part 3)
allenrobel Jun 11, 2025
a4bf5f9
want_create -> want_create_models (part 4)
allenrobel Jun 11, 2025
1b94f4e
get_diff_query_for_vrfs_in_want: fix lookup
allenrobel Jun 11, 2025
47d96ac
want_create -> want_create_models (part 5)
allenrobel Jun 11, 2025
602d4eb
VrfPayloadV12: add field vrf_extension_template
allenrobel Jun 11, 2025
0f54f61
Rename methods/vars for clarity
allenrobel Jun 11, 2025
382c454
Add type hints and debug messages
allenrobel Jun 11, 2025
189a2a4
populate_have_deploy: return value directly
allenrobel Jun 12, 2025
42ab817
Appease pep8
allenrobel Jun 12, 2025
cc530f0
Consistent list var naming
allenrobel Jun 12, 2025
9763ce8
Rename method populate_have_attach_model
allenrobel Jun 12, 2025
51eef7b
Appease pep8
allenrobel Jun 12, 2025
9f93ded
get_diff_replace: leverage self.have_attach_models
allenrobel Jun 12, 2025
357e589
diff_merge_attach: leverage self.have_attach_models
allenrobel Jun 12, 2025
2e15089
diff_for_attach_deploy: leverage self.have_attach_models
allenrobel Jun 12, 2025
09de74a
PayloadVrfsAttachments: attachment payload validation
allenrobel Jun 13, 2025
0f2f8de
Appease sanity test
allenrobel Jun 13, 2025
2ace871
Revert relative import
allenrobel Jun 13, 2025
425723a
Standardize model filenames and class names
allenrobel Jun 13, 2025
bab9913
Appease sanity import and pep8 errors
allenrobel Jun 13, 2025
4e6287b
Update method to leverage model
allenrobel Jun 14, 2025
3ce6c8f
Run dcnm_vrf_v12.py through isort
allenrobel Jun 14, 2025
e69fed5
Appease pylint
allenrobel Jun 14, 2025
981c1f6
Fix update_attach_params_extension_values
allenrobel Jun 14, 2025
ff84ce1
Appease pep8
allenrobel Jun 14, 2025
b157183
Move dot1q validation to model
allenrobel Jun 14, 2025
5c24258
UT: model_playbook_vrf_v12.py
allenrobel Jun 14, 2025
9d6f59e
Appease pep8, more…
allenrobel Jun 14, 2025
11140d7
UT: PlaybookVrfLiteModel..dot1q validation
allenrobel Jun 14, 2025
baba33b
UT: vrf_lite.ipv4_addr validation
allenrobel Jun 15, 2025
ab6b939
UT: vrf_lite.ipv6_addr validation
allenrobel Jun 15, 2025
eb734ac
UT: vrf_lite.interface validation
allenrobel Jun 15, 2025
00d1d04
UT and model updates
allenrobel Jun 15, 2025
75713fe
UT: More unit tests for playbook models
allenrobel Jun 16, 2025
fc17d81
PlaybookVrfModelV12: Remove aliases
allenrobel Jun 17, 2025
133f550
UT: refactor vrf playbook tests
allenrobel Jun 17, 2025
6b7a6ee
Appease pylint
allenrobel Jun 17, 2025
f90f8ba
Appease pylint inappropriate error
allenrobel Jun 17, 2025
88359cc
Appease pylint by removing broken directive
allenrobel Jun 17, 2025
5bcca46
Appease import sanity test
allenrobel Jun 17, 2025
be8dcc5
UT: vrf model: rp_loopback_id
allenrobel Jun 18, 2025
83332cd
UT: vrf model: service_vrf_template
allenrobel Jun 18, 2025
7ecb14e
UT: vrf model: source
allenrobel Jun 18, 2025
dad0917
UT: vrf model: static_default_route
allenrobel Jun 18, 2025
386cae1
UT: vrf model: trm cases
allenrobel Jun 18, 2025
4d61df3
UT: multicast group tests
allenrobel Jun 18, 2025
4713ab5
UT: ip_address refactor
allenrobel Jun 18, 2025
1fc15b7
UT: vlan_id, vrf_description
allenrobel Jun 18, 2025
a028388
Fix vlan_id field_validator
allenrobel Jun 18, 2025
ef6eba6
UT: vrf_extension_template
allenrobel Jun 18, 2025
77d57d5
UT: Finish unit tests for VRF playbook
allenrobel Jun 18, 2025
56683b2
UT: vrf_name, update tests
allenrobel Jun 19, 2025
a72a8a6
Cherry-pick .github/workflows/main.yml from develop
allenrobel Jun 20, 2025
35fd575
Fix sorting of vrf names, and initial UT
allenrobel Jun 20, 2025
d56ac92
Align sanity/ignore-*.txt with develop branch
allenrobel Jun 20, 2025
58bb160
Appease linters
allenrobel Jun 20, 2025
90f7835
Remove ndfc_pc_members_validate.py
allenrobel Jun 20, 2025
deabe60
Appease sanity
allenrobel Jun 20, 2025
87c0405
Appease sanity
allenrobel Jun 20, 2025
10b5e48
UT: Refactor load_fixture.py
allenrobel Jun 20, 2025
24306cb
Appease pep8
allenrobel Jun 20, 2025
1ca638c
UT: PayloadVrfsAttachments, initial unit tests
allenrobel Jun 21, 2025
cb90746
UT: Fix definition of vrf_name_tests
allenrobel Jun 21, 2025
9a467de
1. tests/unit/module_utils/vrf/test_model_payload_vrfs_attachments.py
allenrobel Jun 21, 2025
92433fd
New model for instanceValues payload
allenrobel Jun 23, 2025
c4de1c6
Fix unit test, appease linters
allenrobel Jun 23, 2025
3a92bb2
DiffAttachToControllerPayload.commit() refactor
allenrobel Jun 23, 2025
8cc7336
UT: Rename v12 unit test fixture file to match v11
allenrobel Jun 24, 2025
33e7750
PayloadVrfsAttachments: validate extensionValues
allenrobel Jun 24, 2025
dac42aa
Experimental fix for 500 controller response
allenrobel Jun 24, 2025
85a1259
push_diff_attach_model: run payload thru json.dumps()
allenrobel Jun 24, 2025
409d4aa
PayloadVrfsAttachments: Fix serialization
allenrobel Jun 27, 2025
401e7aa
DiffAttachToControllerPayload: Modify payload assignment
allenrobel Jun 27, 2025
3745a46
ControllerResponseVrfsSwitchesSwitchDetails: optional fields
allenrobel Jun 28, 2025
984c575
Fix for attachment payload via model, more…
allenrobel Jun 29, 2025
8f77e83
IT: Log test titles to dcnm.log
allenrobel Jun 29, 2025
d045523
SerialNumberToVrfLite: Update docstrings
allenrobel Jun 29, 2025
50796ba
Initial controller response model and unit tests for Easy_Fabric
allenrobel Jun 29, 2025
da41147
Appease pep8 linter
allenrobel Jun 29, 2025
b1ce88a
Update tests/sanity/ignore-*.txt
allenrobel Jun 29, 2025
7525682
UT: Initial AI-generated test cases for NvPairs
allenrobel Jun 29, 2025
444999b
UT: Remove unused fixtures
allenrobel Jun 30, 2025
19c8e21
Update with detailed description of Ansible states
allenrobel Jul 10, 2025
3581cb1
Add license boilerplate and module docstring
allenrobel Jul 10, 2025
6c71b73
Restore original dcnm_vrf module, rename new vrf module to dcnm_vrf_v2
allenrobel Jul 11, 2025
f86ea21
Appease linters
allenrobel Jul 11, 2025
2d91591
Appease pep8 linter, update AnsibleStates enum
allenrobel Jul 11, 2025
b700357
Re-enable unit tests for dcnm_vrf_v2
allenrobel Jul 11, 2025
228cee3
PayloadVrfsDeployments: Fix typo in class name and update unit tests
allenrobel Jul 11, 2025
7ae8496
Replace dcnm_vrf.py with develop version and add feature porting plan
allenrobel Nov 12, 2025
954ce99
Implement L3VNI without VLAN feature for dcnm_vrf_v2
allenrobel Nov 12, 2025
b2f7ad4
Update FEATURE_PORTING_PLAN.md: Mark L3VNI without VLAN feature as co…
allenrobel Nov 12, 2025
5cf8e40
Implement deploy flag handling fix for dcnm_vrf_v2
allenrobel Nov 12, 2025
cf6e46e
Update FEATURE_PORTING_PLAN.md: Mark deploy flag handling as completed
allenrobel Nov 12, 2025
ef52212
Add VRF Lite DOT1Q auto-allocation support
allenrobel Nov 12, 2025
9d6b682
Update FEATURE_PORTING_PLAN.md: Mark Feature #3 as completed
allenrobel Nov 12, 2025
c75ee14
Add IPv6 redistribute route-map support
allenrobel Nov 12, 2025
c81467e
Update FEATURE_PORTING_PLAN.md: Mark Feature #4 as completed
allenrobel Nov 12, 2025
4141f8a
Fix empty instanceValues handling
allenrobel Nov 12, 2025
d46a781
Update FEATURE_PORTING_PLAN.md: Mark Feature #5 as completed
allenrobel Nov 12, 2025
40aa7bf
Add network attachment check during VRF deletion
allenrobel Nov 12, 2025
e94c780
Update FEATURE_PORTING_PLAN.md: Mark Feature #6 as completed
allenrobel Nov 12, 2025
5f0eba0
Enhance orphaned resources cleanup for multiple VRFs and pools
allenrobel Nov 12, 2025
61e590f
Update FEATURE_PORTING_PLAN.md: Mark Feature #7 as completed
allenrobel Nov 12, 2025
d4b5c4f
Refine attach state determination logic
allenrobel Nov 13, 2025
7b99d6b
Update FEATURE_PORTING_PLAN.md: Mark Feature #8 (Attach State Logic R…
allenrobel Nov 13, 2025
7689a1c
Update FEATURE_PORTING_PLAN.md: Mark Feature #9 as completed
allenrobel Nov 13, 2025
3647b9c
Feature #10: Add response DATA "Fail" message handling
allenrobel Nov 13, 2025
6992fe5
Update FEATURE_PORTING_PLAN.md: Mark Feature #10 as completed
allenrobel Nov 13, 2025
0dbee53
Update FEATURE_PORTING_PLAN.md: All 11 features completed! 🎉
allenrobel Nov 13, 2025
62edec5
Fix unit tests for Feature #6 network attachment checks
allenrobel Nov 13, 2025
f0a92ba
Fix test_dcnm_vrf_v2_12_lite_override_with_deletions test
allenrobel Nov 13, 2025
56eddde
Remove duplicate tests
allenrobel Nov 13, 2025
5fe3d3a
Merge branch 'develop' into dcnm-vrf-pydantic-integration-3
allenrobel Nov 13, 2025
3459824
UT: Fix test_dcnm_vrf_v2_12_merged_new
allenrobel Nov 13, 2025
eea47ac
Sanity: ignore-2.18.txt, remove duplicate line
allenrobel Nov 13, 2025
ebc6a2c
Fix typo in class name.
allenrobel Nov 13, 2025
c96c254
IT: merged.yaml missing &conf4 alias
allenrobel Nov 13, 2025
c9e451d
Sanity: ignore-2.15.txt, remove duplicate lines
allenrobel Nov 13, 2025
7f73523
Sanity: ignore-2.16-16.txt, remove duplicate lines
allenrobel Nov 13, 2025
941f199
Sanity: ignore-2.16.txt fix errors
allenrobel Nov 13, 2025
675f14b
Squashed commit of the following:
allenrobel Nov 20, 2025
ca3c35a
ignore license check for dcnm_vrf_v2.py
allenrobel Nov 20, 2025
fa0d522
Merge branch 'develop' into dcnm-vrf-pydantic-integration-3
allenrobel Nov 20, 2025
796bc60
Add pydantic import guards for all VRF classes
allenrobel Nov 20, 2025
158cce6
Appease pylint
allenrobel Nov 20, 2025
848fd1c
from __future__ import annotations
allenrobel Nov 20, 2025
8866b83
Merge branch 'develop' into dcnm-vrf-pydantic-integration-3
allenrobel Nov 21, 2025
0f4fda6
dcnm_vrf_v2.py: Add ignore license check
allenrobel Nov 21, 2025
97956a1
Leverage central pydantic import guards, more…
allenrobel Nov 21, 2025
a1308e8
Use centralized Pydantic import guards, more…
allenrobel Nov 21, 2025
5d09c5f
ansible-test sanity complains about _ var name
allenrobel Nov 22, 2025
8d0bf46
Add ‘from __future__ import annotations’ where needed
allenrobel Nov 22, 2025
c582422
Address Copilot review comments
allenrobel Dec 7, 2025
eb3029f
Test commenting out pydantic import
allenrobel Dec 7, 2025
8d02527
Comment out 3rd-party import tracking vars
allenrobel Dec 7, 2025
d606188
Address Copilot review comments
allenrobel Dec 7, 2025
62cc8eb
Address Copilot review comments.
allenrobel Dec 7, 2025
b05b071
Address Copilot review comments
allenrobel Dec 7, 2025
9edd177
Address Copilot review comments
allenrobel Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
522 changes: 522 additions & 0 deletions FEATURE_PORTING_PLAN.md

Large diffs are not rendered by default.

25 changes: 4 additions & 21 deletions plugins/module_utils/common/api/onemanage/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,20 @@
are all set using the same consistent interface.
"""

from __future__ import absolute_import, division, print_function
from __future__ import absolute_import, annotations, division, print_function

__metaclass__ = type # pylint: disable=invalid-name
__author__ = "Allen Robel"

import traceback
from typing import Literal, Optional, Union
from typing import Literal, Optional

try:
from pydantic import BaseModel, Field
except ImportError:
HAS_PYDANTIC = False
PYDANTIC_IMPORT_ERROR: Union[str, None] = traceback.format_exc() # pylint: disable=invalid-name

# Fallback: object base class
BaseModel = object # type: ignore[assignment,misc]

# Fallback: Field that does nothing
def Field(**kwargs): # type: ignore[no-redef] # pylint: disable=unused-argument,invalid-name
"""Pydantic Field fallback when pydantic is not available."""
return None

# Fallback: field_validator decorator that does nothing
def field_validator(*args, **kwargs): # pylint: disable=unused-argument,invalid-name
"""Pydantic field_validator fallback when pydantic is not available."""

def decorator(func):
return func

return decorator

PYDANTIC_IMPORT_ERROR: str | None = traceback.format_exc() # pylint: disable=invalid-name
from ...third_party.pydantic import BaseModel, Field
else:
HAS_PYDANTIC = True
PYDANTIC_IMPORT_ERROR = None # pylint: disable=invalid-name
Expand Down
29 changes: 6 additions & 23 deletions plugins/module_utils/common/api/query_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,21 @@
filtering with type safety via Pydantic.
"""

from __future__ import absolute_import, division, print_function
from __future__ import absolute_import, annotations, division, print_function

__metaclass__ = type # pylint: disable=invalid-name
__author__ = "Allen Robel"

import traceback
from abc import ABC, abstractmethod
from typing import Optional, Union
from typing import Optional

try:
from pydantic import BaseModel, Field, field_validator
except ImportError:
HAS_PYDANTIC = False
PYDANTIC_IMPORT_ERROR: Union[str, None] = traceback.format_exc() # pylint: disable=invalid-name

# Fallback: object base class
BaseModel = object # type: ignore[assignment,misc]

# Fallback: Field that does nothing
def Field(**kwargs): # type: ignore[no-redef] # pylint: disable=unused-argument,invalid-name
"""Pydantic Field fallback when pydantic is not available."""
return None

# Fallback: field_validator decorator that does nothing
def field_validator(*args, **kwargs): # type: ignore[no-redef] # pylint: disable=unused-argument,invalid-name
"""Pydantic field_validator fallback when pydantic is not available."""

def decorator(func):
return func

return decorator

PYDANTIC_IMPORT_ERROR: str | None = traceback.format_exc() # pylint: disable=invalid-name
from ...common.third_party.pydantic import BaseModel, Field, field_validator
else:
HAS_PYDANTIC = True
PYDANTIC_IMPORT_ERROR = None # pylint: disable=invalid-name
Expand Down Expand Up @@ -246,9 +229,9 @@ class CompositeQueryParams:
"""

def __init__(self) -> None:
self._param_groups: list[Union[EndpointQueryParams, LuceneQueryParams]] = []
self._param_groups: list[EndpointQueryParams | LuceneQueryParams] = []

def add(self, params: Union[EndpointQueryParams, LuceneQueryParams]) -> "CompositeQueryParams":
def add(self, params: EndpointQueryParams | LuceneQueryParams) -> "CompositeQueryParams":
"""
Add a query parameter group to the composite.

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=line-too-long
from __future__ import absolute_import, division, print_function

__metaclass__ = type
__author__ = "Allen Robel"

import inspect
import logging

from ..top_down import TopDown


class Fabrics(TopDown):
"""
## api.v1.lan-fabric.rest.top-down.fabrics.Fabrics()

### Description
Common methods and properties for top-down.fabrics.Fabrics() subclasses.

### Path
- ``/api/v1/lan-fabric/rest/top_down/fabrics``
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.fabrics = f"{self.top_down}/fabrics"
msg = f"ENTERED api.v1.lan_fabric.rest.top_down.fabrics.{self.class_name}"
self.log.debug(msg)
self._build_properties()

def _build_properties(self):
"""
- Set the fabric_name property.
"""
self.properties["fabric_name"] = None
self.properties["ticket_id"] = None

@property
def fabric_name(self):
"""
- getter: Return the fabric_name.
- setter: Set the fabric_name.
- setter: Raise ``ValueError`` if fabric_name is not valid.
"""
return self.properties["fabric_name"]

@fabric_name.setter
def fabric_name(self, value):
method_name = inspect.stack()[0][3]
try:
self.conversion.validate_fabric_name(value)
except (TypeError, ValueError) as error:
msg = f"{self.class_name}.{method_name}: "
msg += f"{error}"
raise ValueError(msg) from error
self.properties["fabric_name"] = value

@property
def path_fabric_name(self):
"""
- Endpoint path property, including fabric_name.
- Raise ``ValueError`` if fabric_name is not set and
``self.required_properties`` contains "fabric_name".
"""
method_name = inspect.stack()[0][3]
if self.fabric_name is None and "fabric_name" in self.required_properties:
msg = f"{self.class_name}.{method_name}: "
msg += "fabric_name must be set prior to accessing path."
raise ValueError(msg)
return f"{self.fabrics}/{self.fabric_name}"

@property
def ticket_id(self):
"""
- getter: Return the ticket_id.
- setter: Set the ticket_id.
- setter: Raise ``ValueError`` if ticket_id is not a string.
- Default: None
- Note: ticket_id is optional unless Change Control is enabled.
"""
return self.properties["ticket_id"]

@ticket_id.setter
def ticket_id(self, value):
method_name = inspect.stack()[0][3]
if not isinstance(value, str):
msg = f"{self.class_name}.{method_name}: "
msg += f"Expected string for {method_name}. "
msg += f"Got {value} with type {type(value).__name__}."
raise ValueError(msg)
self.properties["ticket_id"] = value
Loading