Closed zetan503 closed 1 year ago
@zetan503
You can always use the built in helper to find out what parameters are required.
a.add_application_segment?
Having said that try using the Following:
resp= client.add_application_segment(name='TEST', healthReporting=None, domainNames=["abc.in.test.com", "a.test.com"], segmentGroupId= 288257894007177366, serverGroups=[{'id': '288257894007177332'}], tcpPortRanges=["443","443"], udpPortRanges=[13, 13], description='Test App Description'). Please note: print(resp)
Please note
Please let me know if the example provided works and whether you need additional parameters to be added so we can speed up the release.
happy coding!
Thanks, the problem was with my udp/tcp port encoding using the from/to syntax. In this example:
tcpPortRanges=["443","443"], udpPortRanges=[13, 13],
Should the port be an int or a string?
How do I express a single port, multiple discrete ports, and a range of ports? 443 22,80,443 1-13
@zetan503
Single ports 80 and 443 [80,80, 443,443] ranges 2 to 52 and 54 to 100 : [2,52, 54,100]
The payload comes from:
To your point, we will update this method to use new parameters added in ZPA endpoint list of dictionaries containing { "from": 0, "to": 0 }
Please let me know if you need further information
Resolved, thanks!
@zetan503 new version has been pushed. bshingadia146 added additional options
Need help creating app segments.
I constructed params to add_application_segment as follows
client.add_application_segment( name=data['shortName'], healthReporting="NONE", domainNames=fqdns, segmentGroupId=id, serverGroups=[{"id": serverGroupId}], tcpPortRanges=zscaler_tcp_ports, udpPortRanges=zscaler_udp_ports, description=data['description'], enabled=True, ipAnchored=False, doubleEncrypt=False, bypassType="NEVER", isCnameEnabled=True, cnameConfig='NOFLATTEN')
requests debugging shows the following being posted
send: b'{"name": "TEST", "description": "Test App Description", "enabled": true, "healthReporting": "NONE", "ipAnchored": false, "doubleEncrypt": false, "bypassType": "NEVER", "isCnameEnabled": true, "tcpPortRanges": [{"from": "22", "to": "22"}, {"from": "443", "to": "443"}], "udpPortRanges": [{"from": "13", "to": "13"}], "domainNames": ["abc.in.test.com", "a.test.com"], "segmentGroupId": "288257894007177366", "serverGroups": [{"id": "288257894007177332"}], "cnameConfig": "NOFLATTEN"}'
but I get a 400 bad request back
POST /mgmtconfig/v1/admin/customers/mycustomerid/application
where mycustomerid has the correct value
b'{\n "id" : "read.message.failed",\n "reason" : "Failed to read http message, Please check the input/format of the message"\n}' Unexpected HTTP response code: 400 reply: 'HTTP/1.1 400 Bad Request\r\n'
What's wrong with my parameters? Thanks