location_management¶
The following methods allow for interaction with the ZTW Location Management API endpoints.
Methods are accessible via ztw.location_management
Copyright (c) 2023, Zscaler Inc.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- class LocationManagementAPI¶
Bases:
APIClientA Client object for the Admin and Role resource.
- get_location(location_id)¶
Returns information for the specified location based on the location id or location name.
- Parameters:
location_id (int) – The unique identifier for the location.
- Returns:
A tuple containing (Location instance, Response, error).
- Return type:
Examples
>>> fetched_location, _, err = client.ztw.locations.get_location('5458745') ... if err: ... print(f"Error fetching location by ID: {err}") ... return ... print(f"Fetched location by ID: {fetched_location.as_dict()}")
- list_locations(query_params=None)¶
Returns a list of locations.
- Keyword Arguments:
{dict} (query_params) –
Optional query parameters.
[query_params.page]{int}: Specifies the page offset.[query_params.page_size]{int}: Specifies the page size. The defaultsize is 100, but the maximum size is 1000.
[query_params.state]{str}: Filter based on geographical state fora location.
[query_params.xff_enabled]{bool}: Filter based on whether EnforceXFF Forwarding is enabled for a location.
[query_params.auth_required]{bool}: Filter based on whether EnforceAuthentication is enabled for a location.
[query_params.bw_enforced]{bool}: Filter based on whether BandwithControl is enforced for a location.
[query_params.partner_id]{bool}: Not applicable to Cloud &Branch Connector.
[query_params.enforce_aup]{bool}: Filter based on whetherAcceptable Use Policy (AUP) is enforced for a location.
[query_params.enable_firewall]{bool}: Filter based on whether firewall is enabled for a location.[query_params.location_type]{bool}: Filter based on type of location.Supported values: NONE, CORPORATE, SERVER, GUESTWIFI, IOT, WORKLOAD
- Returns:
List of configured locations.
- Return type:
Tuple
Examples
List all Locations:
>>> location_list, response, error = ztw.location_management.list_locations(): ... if error: ... print(f"Error listing Locations: {error}") ... return ... print(f"Total locations found: {len(location_list)}") ... for loc in location_list: ... print(loc.as_dict())
Gets a list of all Locations.
>>> location_list, response, error = ztw.location_management.list_locations( query_params={'search': 'Location01', 'enable_firewall': True}): ... if error: ... print(f"Error listing Locations: {error}") ... return ... print(f"Total locations found: {len(location_list)}") ... for loc in location_list: ... print(loc.as_dict())
- list_locations_lite(query_params=None)¶
Returns only the name and ID of all configured locations.
- Keyword Arguments:
{dict} (query_params) –
Optional query parameters.
[query_params.page]{int}: Specifies the page offset.[query_params.page_size]{int}: Specifies the page size. The defaultsize is 100, but the maximum size is 1000.
[query_params.search]{str}: The search string used to partially matchagainst the location name and port attributes.
[query_params.group_id]{int}: Filter based on location group ID fora location.
[query_params.partner_id]{int}: Not applicable to Cloud &Branch Connector.
[query_params.version]{int}: Not applicable to Cloud &Branch Connector.
[query_params.include_sub_locations]{bool}: If set to true,sub-locations are included in the response.
[query_params.include_parent_locations]{bool}: If set to true,parent locations (i.e., locations with sub-locations) are included in the response.
[query_params.include_default_location]{bool}: If set to true,default location is included in response.
- Returns:
A list of configured locations.
- Return type:
Tuple
Examples
List all Locations:
>>> location_list, response, error = ztw.location_management.list_locations_lite(): ... if error: ... print(f"Error listing Locations: {error}") ... return ... print(f"Total locations found: {len(location_list)}") ... for loc in location_list: ... print(loc.as_dict())
Gets a list of all Locations.
>>> location_list, response, error = ( ... ztw.location_management.list_locations_lite( ... query_params={"search": 'Group01'} ... ) ... ): ... if error: ... print(f"Error listing Locations: {error}") ... return ... print(f"Total locations found: {len(location_list)}") ... for loc in location_list: ... print(loc.as_dict())