traffic_static_ip¶
The following methods allow for interaction with the ZIA Traffic Static IP API endpoints.
Methods are accessible via zia.traffic_static_ip
- class TrafficStaticIPAPI¶
Bases:
APIClientA Client object for the Traffic Forwarding Static IP resources.
- add_static_ip(**kwargs)¶
Adds a new static IP.
- Parameters:
ip_address (str) – The static IP address
- Keyword Arguments:
**comment (str) – Additional information about this static IP address.
**geo_override (bool) – If not set, geographic coordinates and city are automatically determined from the IP address. Otherwise, the latitude and longitude coordinates must be provided.
**routable_ip (bool) – Indicates whether a non-RFC 1918 IP address is publicly routable. This attribute is ignored if there is no ZIA Private Service Edge associated to the organization.
**latitude (float) – Required only if the geoOverride attribute is set. Latitude with 7 digit precision after decimal point, ranges between -90 and 90 degrees.
**longitude (float) – Required only if the geoOverride attribute is set. Longitude with 7 digit precision after decimal point, ranges between -180 and 180 degrees.
- Returns:
The resource record for the newly created static IP.
- Return type:
Examples
Add a new static IP address:
>>> added_static_ip, response, error = client.zia.traffic_static_ip.add_static_ip( ... comment=f"NewStaticIP {random.randint(1000, 10000)}", ... ip_address="200.201.203.204", ... ) ... if err: ... print(f"Error adding static_ip: {err}") ... return ... print(f"static_ip added successfully: {added_static_ip.as_dict()}")
- check_static_ip(ip_address)¶
Validates if a static IP address can be added to the organization.
This method checks if the provided IP address is available for use. The API returns plain text “SUCCESS” (HTTP 200) if the IP is available, or a JSON error (HTTP 409) if the IP already exists.
- Parameters:
ip_address (str) – The static IP address to validate.
- Returns:
- A tuple of (is_valid, response, error) where:
is_valid=True, response=None, error=None: IP is available (not in system)
is_valid=False, response=raw_response, error=error_obj: IP already exists (HTTP 409)
is_valid=False, response=None, error=error_obj: Network or request error
- Return type:
Examples
Check if an IP address is available:
>>> is_valid, _, err = client.zia.traffic_static_ip.check_static_ip('203.0.113.11') >>> if err: ... print(f"Error: {err}") >>> elif is_valid: ... print("IP is available - can be added") >>> else: ... print("IP already exists in the organization")
- delete_static_ip(static_ip_id)¶
Delete the specified static IP.
- Parameters:
static_ip_id (int) – The unique identifier for the static IP.
- Returns:
The response code for the operation.
- Return type:
Examples
>>> zia.traffic.delete_static_ip('972494')
- get_static_ip(static_ip_id)¶
Returns information for the specified static IP.
- Parameters:
static_ip_id (str) – The unique identifier for the static IP.
- Returns:
The resource record for the static IP
- Return type:
Examples
>>> static_ip = zia.traffic.get_static_ip('967134')
- list_static_ips(query_params=None)¶
Returns the list of all configured static IPs.
- Parameters:
{dict} (query_params) –
Map of query parameters for the request.
[query_params.page]{int}: Specifies the page offset.[query_params.page_size]{int}: Page size for pagination.[query_params.available_for_gre_tunnel]{bool}: The type of VPN credential.Must be one of ‘CN’, ‘IP’, ‘UFQDN’, ‘XAUTH’.
[query_params.ip_address]{str}: Include VPN credential only if not associated with any location.- Returns:
A tuple containing (list of the configured static IPs instances, Response, error)
- Return type:
Examples
List static IPs using default settings:
>>> for ip_address in zia.traffic.list_static_ips(): ... print(ip_address)
List static IPs, limiting to a maximum of 10 items:
>>> for ip_address in zia.traffic.list_static_ips(max_items=10): ... print(ip_address)
List static IPs, returning 200 items per page for a maximum of 2 pages:
>>> for ip_address in zia.traffic.list_static_ips(page_size=200, max_pages=2): ... print(ip_address)