Skip to content

Commit

Permalink
fix parent_id issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-mazurkiewicz committed May 17, 2024
1 parent 92028bb commit 049ac76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions nac_collector/cisco_client_ise.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_from_endpoints(self, endpoints_yaml_file):
)
# Check if response is empty list
elif data.get("response") == []:
endpoint_dict[endpoint["name"]]["items"] = data["response"]
endpoint_dict[endpoint["name"]].append({"data": {}, "endpoint": endpoint["endpoint"]})

# Save results to dictionary
final_dict.update(endpoint_dict)
Expand All @@ -154,15 +154,17 @@ def get_from_endpoints(self, endpoints_yaml_file):
# Iterate over the dictionary
for _, value in final_dict.items():
index = 0
# Iterate over the items in final_dict[parent_endpoint]['items']
# Iterate over the items in final_dict[parent_endpoint]
for item in value:
if parent_endpoint == "/".join(item.get("endpoint").split("/")[:-1]):
# Initialize an empty list for parent endpoint ids
parent_endpoint_ids = []

# Add the item's id to the list
parent_endpoint_ids.append(item["data"]["id"])

try:
parent_endpoint_ids.append(item["data"]["id"])
except KeyError:
continue
# Iterate over the parent endpoint ids
for id_ in parent_endpoint_ids:
# Replace '%v' in the endpoint with the id
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 049ac76

Please sign in to comment.