-
Notifications
You must be signed in to change notification settings - Fork 18
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
add location by sending more Model attributes as a body json/dict #200
Comments
I've been looking into this one and I think I'll take three actions here:
@fabiano-lima what do you think of the 3rd option, do you think you'd find that useful? sorry for the late reply, I haven't had a lot of time lately but there are a lot of updates coming today hopefully 😃 |
Okay it's been a while since I've looked at the zia.locations module. The code is pretty simple here: payload = {
"name": name,
}
# Add optional parameters to payload
for key, value in kwargs.items():
payload[snake_to_camel(key)] = value
return self._post("locations", json=payload) We start the payload with the only required argument to create a location, which is zia.locations.add_location(name='My Location', up_bandwidth=30000, dn_bandwidth=30000, country='FIJI') I'll update the docstrings so it's a bit clearer and I'll still consider the raw json option, but most of the methods will let you add an arbitrary number of kwargs over and above what I've actually documented. Will that fit your use-case @fabiano-lima for now? |
Thank you @mitchos , appreciate you taking the time to check this issue. Also the pyZscaler is helping a lot on my project. Have tested the line you suggested, but not working as expected, following some tests:
I am using pyZscaler for GET locations and other functions, but for Add/Post using another methods as Postman where I am able to send all the parameters, including the location name on the Body as a Json (as the payload example on the tests) |
Hi @fabiano-lima so it just comes down to the vpn_credentials parameter, which needs to be a list as you can add multiple credentials to a single location. This worked for me: zia.locations.add_location(
name="My Location",
up_bandwidth=30000,
dn_bandwidth=30000,
country="FIJI",
vpn_credentials=[{"id": "<id>", "type": "UFQDN"}],
) which results in: {
"id": "<id>",
"name": "My Location",
"non_editable": False,
"parent_id": 0,
"up_bandwidth": 30000,
"dn_bandwidth": 30000,
"country": "FIJI",
"language": "NONE",
"tz": "GMT",
"geo_override": False,
"latitude": 0.0,
"longitude": 0.0,
"vpn_credentials": [{"id": "<id>", "type": "UFQDN", "fqdn": "<fqdn>"}],
"auth_required": False,
"ssl_scan_enabled": False,
"zapp_ssl_scan_enabled": False,
"xff_forward_enabled": False,
"other_sub_location": False,
"ec_location": False,
"surrogate_ip": False,
"idle_time_in_minutes": 0,
"surrogate_ip_enforced_for_known_browsers": False,
"surrogate_refresh_time_in_minutes": 0,
"kerberos_auth": False,
"digest_auth_enabled": False,
"ofw_enabled": False,
"ips_control": False,
"aup_enabled": False,
"caution_enabled": False,
"aup_block_internet_until_accepted": False,
"aup_force_ssl_inspection": False,
"iot_discovery_enabled": False,
"aup_timeout_in_days": 0,
"child_count": 0,
"match_in_child": False,
"static_location_groups": [],
"dynamiclocation_groups": [{"id": "<id>", "name": "Server Traffic Group"}],
"exclude_from_dynamic_groups": False,
"exclude_from_manual_groups": False,
"profile": "SERVER",
} I'll update the documentation and add an example as this is a pretty common usage. Let me know how you get on with that? |
…fy params Signed-off-by: mkelly <me@mkelly.dev>
have not being able to add location by passing more zscaler location model attributes as such as: upBandwidth, country, sslScanEnabled, etc....
it is possible do send as json body all these location model settings using Postman to create a location. Is there an way to do the same using pyzscaler add_location function ?
The text was updated successfully, but these errors were encountered: