Skip to content

Commit

Permalink
add a value argument when creating and renaming an address list
Browse files Browse the repository at this point in the history
  • Loading branch information
rshunim committed Jan 9, 2025
1 parent f028cf4 commit 89fbf72
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
15 changes: 9 additions & 6 deletions Packs/NetQuestOMX/Integrations/NetQuestOMX/NetQuestOMX.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,23 @@ def address_list_optimize_request(self) -> dict:

return response_json

def address_list_create_request(self, name: str):
def address_list_create_request(self, name: str, value: str):
try:
self._http_request(
method="POST", url_suffix="/api/Systems/Filters/ListImport/Config/Install", json_data={"Name": name},
method="POST", url_suffix="/api/Systems/Filters/ListImport/Config/Install",
json_data={"Name": name, "Value": value},
ok_codes=(200,)
)
except Exception as e:
raise DemistoException(
"An error was occurred when creating the list of IPs."
) from e

def address_list_rename_request(self, new_name: str, existing_name: str):
def address_list_rename_request(self, new_name: str, new_value: str, existing_name: str):
try:
self._http_request(
method="PUT", url_suffix=f"/api/Systems/Filters/ListImport/ListName/{existing_name}/Config/Install",
json_data={"Name": new_name},
json_data={"Name": new_name, "Value": new_value},
ok_codes=(200,)
)
except Exception as e:
Expand Down Expand Up @@ -284,8 +285,9 @@ def address_list_create_command(client: Client, args: dict) -> CommandResults:
A CommandResults containing a success indication or a DemistoException.
"""
name = args["name"] # a required argument - The name of the address list to create
value = args["value"] # a required argument - The name of the address list to create
try:
client.address_list_create_request(name)
client.address_list_create_request(name, value)
except Exception as e:
raise DemistoException(
f"An error was occurred when creating an IP list with {name=}."
Expand All @@ -304,10 +306,11 @@ def address_list_rename_command(client: Client, args: dict) -> CommandResults:
A CommandResults containing a success indication or a DemistoException.
"""
new_name = args["new_name"] # a required argument - The new name for an existing address list
new_value = args["new_value"] # a required argument - The new value for an existing address list
existing_name = args["existing_name"] # a required argument - Name of the existing address list that we want to modify

try:
client.address_list_rename_request(new_name, existing_name)
client.address_list_rename_request(new_name, new_value, existing_name)
except Exception as e:
raise DemistoException(
f"An error was occurred when renaming {existing_name} IPs list to {new_name}."
Expand Down
6 changes: 6 additions & 0 deletions Packs/NetQuestOMX/Integrations/NetQuestOMX/NetQuestOMX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ script:
- description: 'What to name the new address list.'
name: name
required: true
- description: 'The value for the new address list.'
name: value
required: true
description: "This replaces the old list entity and overrides it."
name: netquest-address-list-create
- arguments:
- description: 'The new name for an existing address list.'
name: new_name
required: true
- description: 'The new value for an existing address list.'
name: new_value
required: true
- description: 'The existing list name of the address list that we want to modify.'
name: existing_name
required: true
Expand Down
13 changes: 7 additions & 6 deletions Packs/NetQuestOMX/Integrations/NetQuestOMX/NetQuestOMX_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ def test_address_list_create_command(requests_mock, net_quest_omx_client):
"""
Given:
- A mocked client
- A name for the new list
- A name and a value for the new list
When:
- Executing netquest-address-list-create command
Then:
- Ensure command is not failed and the readable_output as expected
"""
name = "TEST"
name, value = "TEST", "0.0.0.0/24"
requests_mock.post(f'{BASE_URL}Systems/Filters/ListImport/Config/Install', json={})
result = address_list_create_command(client=net_quest_omx_client, args={"name": name})
result = address_list_create_command(client=net_quest_omx_client, args={"name": name, "value": value})
assert result.readable_output == f"Successfully created a new instance of {name}"


Expand All @@ -210,15 +210,16 @@ def test_address_list_rename_command(requests_mock, net_quest_omx_client):
Given:
- A mocked client
- The name of the list to rename
- A new name for the list
- A new name and a new value for the list
When:
- Executing netquest-address-list-rename command
Then:
- Ensure command is not failed and the readable_output as expected
"""
new_name, existing_name = "NEW_TEST", "TEST"
new_name, new_value, existing_name = "NEW_TEST", "0.0.0.0/24", "TEST"
requests_mock.put(f'{BASE_URL}Systems/Filters/ListImport/ListName/{existing_name}/Config/Install', json={})
result = address_list_rename_command(client=net_quest_omx_client, args={"new_name": new_name, "existing_name": existing_name})
result = address_list_rename_command(client=net_quest_omx_client,
args={"new_name": new_name, "new_value": new_value, "existing_name": existing_name})
assert result.readable_output == f"Successfully renamed {existing_name} to {new_name}"


Expand Down

0 comments on commit 89fbf72

Please sign in to comment.