-
Notifications
You must be signed in to change notification settings - Fork 46
WIP: dcnm_vrf - Pydantic integration #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
allenrobel
wants to merge
409
commits into
develop
Choose a base branch
from
dcnm-vrf-pydantic-integration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 168 commits
Commits
Show all changes
409 commits
Select commit
Hold shift + click to select a range
a4a7654
Cleanup debugging detritus
allenrobel 155c27c
Merge vrfTemplateConfig update methods
allenrobel e372184
Experimental: convert to JSON as late as possible
allenrobel 31e1bfe
Remove commented code
allenrobel f2f2604
push_diff_create_update: simplify logic
allenrobel c66ae2a
get_items_to_detach() - move to class scope
allenrobel 182a6f2
Rename/relocate methods
allenrobel 7ed20a5
diff_for_attach_deploy: redundant key delete
allenrobel 4cfc3a3
diff_for_attach_deploy: replace ast.literal_eval
allenrobel c6725f5
Replace ast.literal_eval with json.loads
allenrobel ae4e255
Address Copilot PR review comments
allenrobel 363512b
Address Copilot PR review comment (part 2)
allenrobel f0afdf7
Address Copilot PR review comment (part 3)
allenrobel 468752a
Refactor get_have -> populate_have_create
allenrobel 7e98292
Fix PEP8 sanity issue
allenrobel 13e250f
Cleanup after last commit
allenrobel 961ce0f
get_have: minor simplification
allenrobel 58852f9
get_have refactor -> populate_have_deploy
allenrobel def3196
Cleanup after last commit
allenrobel ebdc16a
get_have refactor -> populate_have_attach
allenrobel 0128cbf
Appease pylint
allenrobel 8be2e08
populate_have_attach: minor changes
allenrobel 1984ff9
Cleanup after last commit
allenrobel c90ad03
get_want: refactor
allenrobel a0e9959
Cleanup after last commit
allenrobel 4bf3092
get_diff_query: refactor
allenrobel f913de9
get_diff_query: refactor
allenrobel 05c4ca7
Remove commented code
allenrobel 84a2416
Rename DataItem to something less generic
allenrobel 9e60d1c
Update docstring
allenrobel a2506f6
VrfPayloadV12: Update docstring
allenrobel 9b95ab4
vrf_model_to_payload: new method
allenrobel 5b7b86e
push_diff_attach: json.dumps(payload)
allenrobel 87c139b
push_diff_delete: json.dumps(payload)
allenrobel a5dbd82
push_diff_deploy: json.dumps(payload)
allenrobel e8631f9
push_diff_detach: json.dumps(payload)
allenrobel f612c09
push_diff_undeploy: json.dumps(payload)
allenrobel 2341aa4
push_diff_create_update: json.dumps(payload)
allenrobel 7677d04
diff_merge_create: leverage send_to_controller
allenrobel 45359a3
push_diff_attach: refactor lan_attach_list update
allenrobel ef02d99
Appease pep8 linter
allenrobel b19c0c5
Remove commented code
allenrobel 2997adf
diff_for_attach_deploy: refactor
allenrobel 2c0e92a
Appease pylint
allenrobel e379625
diff_for_attach_deploy_orig: remove
allenrobel ae5d069
populate_have_create: avoid KeyError
allenrobel 945e66c
populate_have_attach: refactor
allenrobel 753fe17
populate_have_attach_orig: remove
allenrobel 13e78d1
_update_vrf_lite_extension: return updated attach
allenrobel ec6ff78
get_diff_query_for_vrfs_in_want: simplify
allenrobel 9e07100
format_diff: refactor
allenrobel 85948ce
diff_for_attach_deploy: update comments
allenrobel 8b221f2
format_diff_orig: remove
allenrobel 4cd1e54
get_diff_delete: refactor
allenrobel 6bf426c
get_diff_replaced: refactor
allenrobel b0e02e0
Remove original methods
allenrobel 4940751
update_vrf_attach_vrf_lite_extensions: initial refactor
allenrobel c28eb00
update_vrf_attach_vrf_lite_extensions_orig: remove
allenrobel 15e5980
update_lan_attach_list: return pydantic model
allenrobel 794e87c
Remove original methods, update docstrings
allenrobel 199b67e
_update_vrf_lite_extension: use vrf_lite model
allenrobel a6464df
get_vrf_lite_objects_model: update and rename
allenrobel f15fec2
compare_properties: rename to property_values_match
allenrobel 7d59b56
get_vrf_objects -> get_controller_vrf_object_models
allenrobel c0263cc
Update log messages
allenrobel 37c92b6
Remove duplicate line
allenrobel 6daf6a6
get_vrf_lan_attach_list -> get_controller_vrf_attachment_models
allenrobel 06f53e0
Rename vars for readability
allenrobel d73d602
get_diff_replace: rename vars
allenrobel b8af9ea
get_diff_replace: rename vars (part 2)
allenrobel e9beef7
diff_merge_attach: rename vars for readability
allenrobel ca2cc30
diff_for_attach_deploy: rename vars for readability
allenrobel 6e6dadf
Appease pep8 linter
allenrobel 3d12b57
Fix two unit tests, replace dcnm_get_url
allenrobel 796cf8d
Cleanup debug log messages
allenrobel 073101b
Experimental commit
allenrobel 20a005e
Appease pylint
allenrobel 29a9c4d
Appease pep8
allenrobel 3bbf62d
Update sanity/ignore-*.txt
allenrobel 93a2f24
sanity/ignore-*.txt remove duplicate lines
allenrobel 7fde7b4
Fix type hints
allenrobel 8cc66de
Appease pylint
allenrobel 8bbd9fc
DcnmVrfV12: add var self.have_attach_model
allenrobel 0f43f37
HaveLanAttachItem: Accept a null vlan (vlanId)
allenrobel f0bf463
_deployment_status_match: Add debug logs
allenrobel 6948df0
diff_merge_attach: Add debug logs
allenrobel 1accc6a
Modifications for model-based delete state
allenrobel fb68ca1
Update sanity/ignore-*.txt
allenrobel a540003
Add logs to debug integration test failures
allenrobel 8336977
Appease pylint
allenrobel afec3cf
Add logs to debug integration test failures (part 2)
allenrobel 8e2091b
Add logs to debug integration test failures (part 3)
allenrobel 6b8f19c
Appease pylint
allenrobel 113c3da
Fix for integration test errors
allenrobel c195903
Update copyright
allenrobel ed626f4
Rename model file
allenrobel b029d17
Forgot to add dcnm_vrf_v12.py to the last commit
allenrobel 531eef5
IT: Try fix for replaced-state integration test
allenrobel fab3b19
IT: logs to debug replaced-state failure, more…
allenrobel 0e58547
IT: logs to debug replaced-state failure (part 2)
allenrobel ff30165
Appease pylint
allenrobel f4c59e5
Experimental: push_diff_attach_model
allenrobel 12da88f
Appease pylint, update sanity/ignore-*.txt
allenrobel bb8e83e
Forgot to add new model to the last couple commits
allenrobel d936a22
Appease pylint
allenrobel 5d412c3
IT: Potential fix for replaced-state test failure
allenrobel 5b13f7e
Appease pylint
allenrobel 3c13755
update_lan_attach_list: fabricName -> fabric, more
allenrobel f9e7a5e
push_diff_detach: fabricName -> fabric
allenrobel 52a9149
VrfAttachPayloadV12: fix vlan field
allenrobel e4e4d55
get_items_to_detach_model: Modify return value
allenrobel 72a06b6
IT: Cleanup after verifying integration passes
allenrobel 34590ac
Add debugs for self.model_enabled
allenrobel eb7a38f
update_lan_attach_list : Rework legacy code
allenrobel 018544f
Appease pylint
allenrobel baf0733
Appease pep8
allenrobel 87a9f71
update_vrf_lite_extensions_new: fix nbr_dict update
allenrobel 40f985b
Try fix for null vlan in diff_attach.
allenrobel 4a66606
push_diff_attach_model: append directly to payload
allenrobel f4e9e05
push_diff_attach_model: refactor
allenrobel 10d5e69
update_lan_attach_list_vrf_lite: rename vrf_attach
allenrobel 533a0ae
Remove legacy code
allenrobel a95443f
Rename vars/methods to reduce cognitive load
allenrobel 861b3f3
want_create: initial changes to leverage playbook model
allenrobel 62137f9
Remove legacy code, more…
allenrobel 01317a7
Experimental: Move methods to separate class
allenrobel 79e9e44
Appease pep8
allenrobel d9b11d5
Update tests/sanity-*.txt with new files
allenrobel 08f1448
SerialNumberToVrfLite: rename method
allenrobel 3e8ccf3
get_diff_override: Convert to model-based, more…
allenrobel 6d30e22
Fix log message
allenrobel 6c02d3c
update_attach_params: Rename method for clarity
allenrobel bb09900
Utility classes for fabric_inventory conversions
allenrobel 3e9bb40
push_diff_detach: divert to push_diff_detach_model
allenrobel fb6e2a7
IT: Potential fix for overridden-state failure
allenrobel fbf2198
update_have_attach_lan_detach_list: remove
allenrobel cc410a5
get_diff_override_model: remove intermediate vars
allenrobel 6761e39
get_diff_override_model: reverse logic and dedent
allenrobel 7ace6bf
get_diff_replace: simplification (part 1)
allenrobel 42737ed
Use send_to_controller in more methods
allenrobel 830d182
Appease pep8
allenrobel 1d1d7be
Fix args to send_to_controller
allenrobel ab793c2
New models
allenrobel 3d6831b
Appease Ansible sanity import tests
allenrobel 976e316
Fix SendToController(action=) in two methods
allenrobel a99f15b
send_to_controller: use an optional response model
allenrobel 5edd5fa
Retain UPPER_CASE fields for controller responses
allenrobel 98b1ec1
Appease pep8
allenrobel d13aca6
Fix model alias
allenrobel bcab423
Standardize controller response model filenames
allenrobel 680dc65
Controller response model cleanup (part 1)
allenrobel a0ea059
Appease linters
allenrobel 10fdf75
Add temporary debug message
allenrobel 79aff90
Appease linters
allenrobel 3cc296e
Add REQUEST_PATH to controller response models, more…
allenrobel 461b86b
UT: Use older fixtures for DCNMv11 unit tests
allenrobel 96ed598
Standardize var names
allenrobel 940d406
VrfTemplateConfigV12: bgp_passwd_encrypt validator
allenrobel 4a89619
Revert last commit
allenrobel 2a516d2
want_create: model-based handling, initial commit
allenrobel cb766ef
want_create -> want_create_models (part 2)
allenrobel 4e727fb
want_create -> want_create_models (part 3)
allenrobel a4bf5f9
want_create -> want_create_models (part 4)
allenrobel 1b94f4e
get_diff_query_for_vrfs_in_want: fix lookup
allenrobel 47d96ac
want_create -> want_create_models (part 5)
allenrobel 602d4eb
VrfPayloadV12: add field vrf_extension_template
allenrobel 0f54f61
Rename methods/vars for clarity
allenrobel 382c454
Add type hints and debug messages
allenrobel 189a2a4
populate_have_deploy: return value directly
allenrobel 42ab817
Appease pep8
allenrobel cc530f0
Consistent list var naming
allenrobel 9763ce8
Rename method populate_have_attach_model
allenrobel 51eef7b
Appease pep8
allenrobel 9f93ded
get_diff_replace: leverage self.have_attach_models
allenrobel 357e589
diff_merge_attach: leverage self.have_attach_models
allenrobel 2e15089
diff_for_attach_deploy: leverage self.have_attach_models
allenrobel 09de74a
PayloadVrfsAttachments: attachment payload validation
allenrobel 0f2f8de
Appease sanity test
allenrobel 2ace871
Revert relative import
allenrobel 425723a
Standardize model filenames and class names
allenrobel bab9913
Appease sanity import and pep8 errors
allenrobel 4e6287b
Update method to leverage model
allenrobel 3ce6c8f
Run dcnm_vrf_v12.py through isort
allenrobel e69fed5
Appease pylint
allenrobel 981c1f6
Fix update_attach_params_extension_values
allenrobel ff84ce1
Appease pep8
allenrobel b157183
Move dot1q validation to model
allenrobel 5c24258
UT: model_playbook_vrf_v12.py
allenrobel 9d6f59e
Appease pep8, more…
allenrobel 11140d7
UT: PlaybookVrfLiteModel..dot1q validation
allenrobel baba33b
UT: vrf_lite.ipv4_addr validation
allenrobel ab6b939
UT: vrf_lite.ipv6_addr validation
allenrobel eb734ac
UT: vrf_lite.interface validation
allenrobel 00d1d04
UT and model updates
allenrobel 75713fe
UT: More unit tests for playbook models
allenrobel fc17d81
PlaybookVrfModelV12: Remove aliases
allenrobel 133f550
UT: refactor vrf playbook tests
allenrobel 6b7a6ee
Appease pylint
allenrobel f90f8ba
Appease pylint inappropriate error
allenrobel 88359cc
Appease pylint by removing broken directive
allenrobel 5bcca46
Appease import sanity test
allenrobel be8dcc5
UT: vrf model: rp_loopback_id
allenrobel 83332cd
UT: vrf model: service_vrf_template
allenrobel 7ecb14e
UT: vrf model: source
allenrobel dad0917
UT: vrf model: static_default_route
allenrobel 386cae1
UT: vrf model: trm cases
allenrobel 4d61df3
UT: multicast group tests
allenrobel 4713ab5
UT: ip_address refactor
allenrobel 1fc15b7
UT: vlan_id, vrf_description
allenrobel a028388
Fix vlan_id field_validator
allenrobel ef6eba6
UT: vrf_extension_template
allenrobel 77d57d5
UT: Finish unit tests for VRF playbook
allenrobel 56683b2
UT: vrf_name, update tests
allenrobel a72a8a6
Cherry-pick .github/workflows/main.yml from develop
allenrobel 35fd575
Fix sorting of vrf names, and initial UT
allenrobel d56ac92
Align sanity/ignore-*.txt with develop branch
allenrobel 58bb160
Appease linters
allenrobel 90f7835
Remove ndfc_pc_members_validate.py
allenrobel deabe60
Appease sanity
allenrobel 87c0405
Appease sanity
allenrobel 10b5e48
UT: Refactor load_fixture.py
allenrobel 24306cb
Appease pep8
allenrobel 1ca638c
UT: PayloadVrfsAttachments, initial unit tests
allenrobel cb90746
UT: Fix definition of vrf_name_tests
allenrobel 9a467de
1. tests/unit/module_utils/vrf/test_model_payload_vrfs_attachments.py
allenrobel 92433fd
New model for instanceValues payload
allenrobel c4de1c6
Fix unit test, appease linters
allenrobel 3a92bb2
DiffAttachToControllerPayload.commit() refactor
allenrobel 8cc7336
UT: Rename v12 unit test fixture file to match v11
allenrobel 33e7750
PayloadVrfsAttachments: validate extensionValues
allenrobel dac42aa
Experimental fix for 500 controller response
allenrobel 85a1259
push_diff_attach_model: run payload thru json.dumps()
allenrobel 409d4aa
PayloadVrfsAttachments: Fix serialization
allenrobel 401e7aa
DiffAttachToControllerPayload: Modify payload assignment
allenrobel 3745a46
ControllerResponseVrfsSwitchesSwitchDetails: optional fields
allenrobel 984c575
Fix for attachment payload via model, more…
allenrobel 8f77e83
IT: Log test titles to dcnm.log
allenrobel d045523
SerialNumberToVrfLite: Update docstrings
allenrobel 50796ba
Initial controller response model and unit tests for Easy_Fabric
allenrobel da41147
Appease pep8 linter
allenrobel b1ce88a
Update tests/sanity/ignore-*.txt
allenrobel 7525682
UT: Initial AI-generated test cases for NvPairs
allenrobel 444999b
UT: Remove unused fixtures
allenrobel 19c8e21
Update with detailed description of Ansible states
allenrobel 3581cb1
Add license boilerplate and module docstring
allenrobel 6c71b73
Restore original dcnm_vrf module, rename new vrf module to dcnm_vrf_v2
allenrobel f86ea21
Appease linters
allenrobel 2d91591
Appease pep8 linter, update AnsibleStates enum
allenrobel b700357
Re-enable unit tests for dcnm_vrf_v2
allenrobel 228cee3
PayloadVrfsDeployments: Fix typo in class name and update unit tests
allenrobel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
106 changes: 106 additions & 0 deletions
106
plugins/module_utils/common/api/v1/lan_fabric/rest/top_down/fabrics/fabrics.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Empty file.
219 changes: 219 additions & 0 deletions
219
plugins/module_utils/common/api/v1/lan_fabric/rest/top_down/fabrics/vrfs/vrfs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
# 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 ..fabrics import Fabrics | ||
from .........common.enums.http_requests import RequestVerb | ||
|
||
|
||
class Vrfs(Fabrics): | ||
""" | ||
## api.v1.lan-fabric.rest.top-down.fabrics.Vrfs() | ||
|
||
### Description | ||
Common methods and properties for top-down.fabrics.Vrfs() subclasses. | ||
|
||
### Path | ||
- ``/api/v1/lan-fabric/rest/top-down/fabrics/{fabric_name}/vrfs`` | ||
""" | ||
|
||
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.vrfs.{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 | ||
|
||
|
||
class EpVrfGet(Fabrics): | ||
""" | ||
## V1 API - Vrfs().EpVrfGet() | ||
|
||
### Description | ||
Return endpoint information. | ||
|
||
### Raises | ||
- ``ValueError``: If fabric_name is not set. | ||
- ``ValueError``: If fabric_name is invalid. | ||
|
||
### Path | ||
- ``/rest/top-down/fabrics/{fabric_name}/vrfs`` | ||
|
||
### Verb | ||
- GET | ||
|
||
### Parameters | ||
- fabric_name: string | ||
- set the ``fabric_name`` to be used in the path | ||
- required | ||
- path: retrieve the path for the endpoint | ||
- verb: retrieve the verb for the endpoint | ||
|
||
### Usage | ||
```python | ||
instance = EpVrfGet() | ||
instance.fabric_name = "MyFabric" | ||
path = instance.path | ||
verb = instance.verb | ||
``` | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.class_name = self.__class__.__name__ | ||
self.log = logging.getLogger(f"dcnm.{self.class_name}") | ||
self.required_properties.add("fabric_name") | ||
self._build_properties() | ||
msg = "ENTERED api.v1.lan_fabric.rest.top_down.fabrics.vrfs." | ||
msg += f"Vrfs.{self.class_name}" | ||
self.log.debug(msg) | ||
|
||
def _build_properties(self): | ||
super()._build_properties() | ||
self.properties["verb"] = RequestVerb.GET | ||
|
||
@property | ||
def path(self): | ||
""" | ||
- Endpoint for VRF GET request. | ||
- Raise ``ValueError`` if fabric_name is not set. | ||
""" | ||
return f"{self.path_fabric_name}/vrfs" | ||
|
||
|
||
class EpVrfPost(Fabrics): | ||
""" | ||
## V1 API - Vrfs().EpVrfPost() | ||
|
||
### Description | ||
Return endpoint information. | ||
|
||
### Raises | ||
- ``ValueError``: If fabric_name is not set. | ||
- ``ValueError``: If fabric_name is invalid. | ||
|
||
### Path | ||
- ``/rest/top-down/fabrics/{fabric_name}/vrfs`` | ||
|
||
### Verb | ||
- POST | ||
|
||
### Parameters | ||
- fabric_name: string | ||
- set the ``fabric_name`` to be used in the path | ||
- required | ||
- path: retrieve the path for the endpoint | ||
- verb: retrieve the verb for the endpoint | ||
|
||
### Usage | ||
```python | ||
instance = EpVrfPost() | ||
instance.fabric_name = "MyFabric" | ||
path = instance.path | ||
verb = instance.verb | ||
``` | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.class_name = self.__class__.__name__ | ||
self.log = logging.getLogger(f"dcnm.{self.class_name}") | ||
self.required_properties.add("fabric_name") | ||
self._build_properties() | ||
msg = "ENTERED api.v1.lan_fabric.rest.top_down.fabrics.vrfs." | ||
msg += f"Vrfs.{self.class_name}" | ||
self.log.debug(msg) | ||
|
||
def _build_properties(self): | ||
super()._build_properties() | ||
self.properties["verb"] = RequestVerb.POST | ||
|
||
@property | ||
def path(self): | ||
""" | ||
- Endpoint for VRF POST request. | ||
- Raise ``ValueError`` if fabric_name is not set. | ||
""" | ||
return f"{self.path_fabric_name}/vrfs" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.