feature: SecureApp network objects comment field
marioland opened this issue · 4 comments
For importing network objects into SecureApp usinf API the helper classes should support the comment field as it is in the DTO in the API:
NetworkObjectListDTO (Root Element = network_objects ) {
network_object (array[sa_network_object], optional)
}
sa_network_object {
type (string, optional): The type of the network object. Allowable Values: basic, host, range, subnet, group, user, user-group, virtual-server, vm_instance,
comment (string, optional): The comment of the object,
name (string): The name of the object,
}
This is missing in the /pytos/secureapp/helpers.py functions.
Hi.
In version 1.2.0 comment
is supported, but keep in mind it is attached to the network object itself (as the DTO suggests), for example:
pytos/pytos/secureapp/xml_objects/rest.py
Lines 1046 to 1049 in 464a3a8
Hi.
I tried the new pytos version 1.2.0 against API of 18.3 .
When calling Secure_App_Helper create_network_objects_for_app_id I get back API response
'Bad Request' 'ILLEGAL_ARGUMENT_ERROR'
'Invalid prefix: '
Unfortunately I was not able to find the root cause. Does the prefix on a Subnet_Network_Object collide with the netmask attribute?
this source code works with pytos 1.1.0 but not with 1.2.0:
from pytos.secureapp.xml_objects.rest import Subnet_Network_Object
from pytos.secureapp.helpers import Secure_App_Helper
sa_helper = Secure_App_Helper("192.168.23.5", ("api", "ao3omdfepOdowjWO4"))
print(sa_helper.get_app_by_id(138))
subnet = Subnet_Network_Object("XXX_d_name5", False, None, "XXX_name5", Subnet_Network_Object,"10.1.1.0", "255.255.255.0")
print(sa_helper.create_network_objects_for_app_id(138, [subnet]))
Error:
>>> sa_helper.create_network_objects_for_app_id(138, [subnet])
Got the following error while performing request: '400 Client Error: for url: https://192.168.23.5/securechangeworkflow/api/secureapp/repository/applications/138/network_objects'.
Message from API is 'Invalid prefix: '.
Message from API is 'Invalid prefix: '.
Error from API is 'ILLEGAL_ARGUMENT_ERROR'.
Status code for request is '400'.
Request to 'https://192.168.23.5/securechangeworkflow/api/secureapp/repository/applications/138/network_objects' resulted in an error from the server: '
Status code: 400
Status: 'Bad Request'
Expected status code: 201
Message: 'Invalid prefix: '
'.
Sent body: 'b'<network_objects>\n <network_object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="subnetNetworkObjectDTO">\n <application_id/>\n <comment/>\n <display_name>XXX_d_name4</display_name>\n <global>False</global>\n <id/>\n <ip>10.1.1.0</ip>\n <name>XXX_name4</name>\n <netmask>255.255.255.0</netmask>\n <prefix/>\n <type><class \'pytos.secureapp.xml_objects.rest.Subnet_Network_Object\'></type>\n </network_object>\n</network_objects>''.
Received response body: 'b'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><result><code>ILLEGAL_ARGUMENT_ERROR</code><message>Invalid prefix: </message></result>''
It was not able to reproduc it with the test_secure_app_helper_unittest.py
It seems that the API is not expecting the prefix attribute in 18-3
Thanks, fixed in 1.2.1.
Thank you. This is working now.