Skip to content
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

[minor_change] Add nd_rest as a new generic ND REST API module. (DCNE-242) #109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gmicol
Copy link
Collaborator

@gmicol gmicol commented Dec 12, 2024

Fixes #107

Addition of a new module nd_rest to handle generic ND REST API requests.

@gmicol gmicol added enhancement New feature or request jira-sync Sync this issue to Jira labels Dec 12, 2024
@gmicol gmicol self-assigned this Dec 12, 2024
@github-actions github-actions bot changed the title [minor_change] Add nd_rest as a new generic ND REST API module. (DNCE-242) [minor_change] Add nd_rest as a new generic ND REST API module. (DNCE-242) (DCNE-242) Dec 12, 2024
@gmicol gmicol changed the title [minor_change] Add nd_rest as a new generic ND REST API module. (DNCE-242) (DCNE-242) [minor_change] Add nd_rest as a new generic ND REST API module. (DCNE-242) Dec 12, 2024
@gmicol gmicol force-pushed the nd_rest branch 2 times, most recently from b5a4cdf to 1af8cb5 Compare December 16, 2024 17:35
plugins/modules/nd_rest.py Outdated Show resolved Hide resolved
plugins/modules/nd_rest.py Show resolved Hide resolved
plugins/modules/nd_rest.py Outdated Show resolved Hide resolved
plugins/modules/nd_rest.py Show resolved Hide resolved
plugins/modules/nd_rest.py Show resolved Hide resolved
tests/integration/inventory.networking Outdated Show resolved Hide resolved
tests/integration/inventory.networking Outdated Show resolved Hide resolved
- cisco.nd.modules

notes:
- Some payloads are known not to be idempotent, so be careful when constructing payloads.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add link reference to nd api docs and or swagger reference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean here fo example?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a reference that points to api documentation of ND like: https://developer.cisco.com/docs/nexus-dashboard/latest/api-reference/

plugins/modules/nd_rest.py Outdated Show resolved Hide resolved
plugins/modules/nd_rest.py Show resolved Hide resolved
plugins/modules/nd_rest.py Outdated Show resolved Hide resolved
plugins/modules/nd_rest.py Outdated Show resolved Hide resolved
plugins/modules/nd_rest.py Show resolved Hide resolved
…and file as input for the module. Add new tests.
@gmicol gmicol requested review from samiib and akinross January 10, 2025 18:46
@@ -56,6 +56,33 @@ def sanitize_list(list_to_sanitize, keys=None, values=None, list_recursive=True,
return result


def sanitize(obj_to_sanitize, keys=None, values=None, recursive=True, remove_none_values=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to copy the code in this function instead of wrapping the existing functions into this function?

payload=content,
)

method = nd.params.get("method").upper()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also allow for upper inputs?

# Append previous state of the object
if method in ("PUT", "DELETE", "PATCH"):
nd.existing = nd.previous = sanitize(nd.query_obj(path, ignore_not_found_error=True), keys_to_sanitize)
if method != "GET":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do we set for previous GET combination, just empty dict? or should we set the current value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jira-sync Sync this issue to Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic ND REST API Module (DCNE-242)
3 participants