app_segments_ba¶
The following methods allow for interaction with the ZPA Browser Access Application Segment API endpoints.
Methods are accessible via zpa.app_segments_ba
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 ApplicationSegmentBAAPI¶
Bases:
APIClient- add_segment_ba(**kwargs)¶
Create a new browser access application segment.
See the Adding a Application Segment Using API reference: for further detail on optional keyword parameter structures.
- Parameters:
name (str) – Required. Name of the application segment (user-defined).
domain_names (list of str) – Required. Domain names or IP addresses for the segment.
segment_group_id (str) – Required. Unique identifier for the segment group.
server_group_ids (list of str) – Required. List of server group IDs this segment belongs to.
tcp_port_ranges (list of str, optional) – Legacy format. TCP port range pairs (e.g., [‘22’, ‘22’]).
udp_port_ranges (list of str, optional) – Legacy format. UDP port range pairs (e.g., [‘35000’, ‘35000’]).
tcp_port_range (list of dict, optional) – New format. TCP port range pairs [{“from”: “8081”, “to”: “8081”}].
udp_port_range (list of dict, optional) – New format. UDP port range pairs [{“from”: “8081”, “to”: “8081”}].
- Keyword Arguments:
bypass_type (str) – Bypass type for the segment. Values: ALWAYS, NEVER, ON_NET.
clientless_app_ids (list) – IDs for associated clientless apps.
description (str) – Additional information about the segment.
double_encrypt (bool) – If true, enables double encryption.
enabled (bool) – If true, enables the application segment.
health_check_type (str) – Health Check Type. Values: DEFAULT, NONE.
health_reporting (str) – Health Reporting mode. Values: NONE, ON_ACCESS, CONTINUOUS.
ip_anchored (bool) – If true, enables IP Anchoring.
is_cname_enabled (bool) – If true, enables CNAMEs for the segment.
passive_health_enabled (bool) – If true, enables Passive Health Checks.
icmp_access_type (str) – Sets ICMP access type for ZPA clients.
microtenant_id (str, optional) – ID of the microtenant, if applicable.
- Returns:
A tuple containing the ApplicationSegment instance, response object, and error if any.
- Return type:
Tuple
Examples
Create an application segment using legacy TCP port format (tcp_port_ranges):
>>> added_segment, _, err = client.zpa.application_segment.add_segment( ... name=f"NewAppSegment_{random.randint(1000, 10000)}", ... description=f"NewAppSegment_{random.randint(1000, 10000)}", ... enabled=True, ... domain_names=["test.example.com", "test1.example.com"], ... segment_group_id="72058304855089379", ... server_group_ids=["72058304855090128"], ... tcp_port_ranges=["8081", "8081"], ... ) ... if err: ... print(f"Error creating segment: {err}") ... return ... print(f"segment created successfully: {added_segment.as_dict()}")
Create an application segment using new TCP port format (tcp_port_range):
>>> added_segment, _, err = client.zpa.application_segment.add_segment( ... name=f"NewAppSegment_{random.randint(1000, 10000)}", ... description=f"NewAppSegment_{random.randint(1000, 10000)}", ... enabled=True, ... domain_names=["test.example.com", "test1.example.com"], ... segment_group_id="72058304855089379", ... server_group_ids=["72058304855090128"], ... tcp_port_range=[{"from": "8081", "to": "8081"}], # Single port range using 'from' and 'to' ... ) ... if err: ... print(f"Error creating segment: {err}") ... return ... print(f"segment created successfully: {added_segment.as_dict()}")
Create an Browser Access application segment:
>>> added_segment, _, err = client.zpa.application_segment.add_segment( ... name=f"NewAppSegment_{random.randint(1000, 10000)}", ... description=f"NewAppSegment_{random.randint(1000, 10000)}", ... enabled=True, ... domain_names=["test.example.com", "test1.example.com"], ... segment_group_id="72058304855089379", ... server_group_ids=["72058304855090128"], ... tcp_port_range=[{"from": "8081", "to": "8081"}], ... clientless_app_ids=[ ... { ... "name": "jenkins.securitygeek.io", ... "enabled": True, ... "certificate_id": "72058304855021564", ... "application_port": "4443", ... "application_protocol": "HTTPS", ... "domain": "jenkins.securitygeek.io", ... } ... ] ... ) ... if err: ... print(f"Error creating segment: {err}") ... return ... print(f"segment created successfully: {added_segment.as_dict()}")
- delete_segment_ba(segment_id, force_delete=False, microtenant_id=None)¶
Deletes the specified Application Segment from ZPA.
See the Deleting a Application Segment Using API reference: for further detail on optional keyword parameter structures.
- Parameters:
- Returns:
A tuple containing the response and error (if any).
- Return type:
Examples
>>> _, _, err = client.zpa.application_segment.delete_segment( ... segment_id='999999' ... ) ... if err: ... print(f"Error deleting application segment: {err}") ... return ... print(f"Application segment with ID {'999999'} deleted successfully.")
- get_segment_ba(segment_id, query_params=None)¶
Retrieve an browser access application segment by its ID.
See the Retrieving a Application Segment Using API reference: for further detail on optional keyword parameter structures.
- Parameters:
segment_id (str) – The unique identifier of the application segment.
- Keyword Arguments:
microtenant_id (str, optional) – ID of the microtenant, if applicable.
- Returns:
A tuple containing the ApplicationSegment instance, response object, and error if any.
- Return type:
Tuple
Examples
>>> fetched_segment, _, err = client.zpa.application_segment.get_segment('999999') ... if err: ... print(f"Error fetching segment by ID: {err}") ... return ... print(f"Fetched segment by ID: {fetched_segment.as_dict()}")
- list_segments_ba(query_params=None)¶
Enumerates BA application segments in your organization with pagination. A subset of application segments can be returned that match a supported filter expression or query.
See the Retrieving a list of Application Segments Using API reference: for further detail on optional keyword parameter structures.
- Parameters:
{dict} (query_params) –
Map of query parameters for the request.
[query_params.page]{str}: Specifies the page number.[query_params.page_size]{str}: Specifies the page size.If not provided, the default page size is 20. The max page size is 500.
[query_params.search]{str}: Search string for filtering results.[query_params.microtenant_id]{str}: The unique identifier of the microtenant of ZPA tenant.- Returns:
A tuple containing (list of ApplicationSegment instances, Response, error)
- Return type:
Tuple
Examples
>>> segment_list, _, err = client.zpa.application_segment.list_segments( ... query_params={'search': 'AppSegment01', 'page': '1', 'page_size': '100'}) ... if err: ... print(f"Error listing application segments: {err}") ... return ... print(f"Total application segments found: {len(segment_list)}") ... for app in segments: ... print(app.as_dict())
- reformat_params = [('clientless_app_ids', 'clientlessApps'), ('server_group_ids', 'serverGroups')]¶
A client object for the Application Segments resource.
- update_segment_ba(segment_id, **kwargs)¶
Update an existing browser access application segment.
See the Updating Application Segments Using API reference: for further detail on optional keyword parameter structures.
- Parameters:
segment_id (str) – The unique identifier of the application segment.
- Keyword Arguments:
microtenant_id (str, optional) – ID of the microtenant, if applicable.
- Returns:
A tuple containing the updated ApplicationSegment instance, response object, and error if any.
- Return type:
Tuple
Examples
Update an application segment using legacy TCP port format (tcp_port_ranges):
>>> update_segment, _, err = client.zpa.application_segment.update_segment( ... segment_id='56687421', ... name=f"UpdateAppSegment_{random.randint(1000, 10000)}", ... description=f"UpdateAppSegment_{random.randint(1000, 10000)}", ... enabled=True, ... domain_names=["test.example.com", "test1.example.com"], ... segment_group_id="72058304855089379", ... server_group_ids=["72058304855090128"], ... tcp_port_ranges=["8081", "8081"], ... ) ... if err: ... print(f"Error updating segment: {err}") ... return ... print(f"segment updated successfully: {update_segment.as_dict()}")
Update an application segment using new TCP port format (tcp_port_range):
>>> update_segment, _, err = client.zpa.application_segment.update_segment( ... segment_id='56687421', ... name=f"UpdateAppSegment_{random.randint(1000, 10000)}", ... description=f"UpdateAppSegment_{random.randint(1000, 10000)}", ... enabled=True, ... domain_names=["test.example.com", "test1.example.com"], ... segment_group_id="72058304855089379", ... server_group_ids=["72058304855090128"], ... tcp_port_range=[{"from": "8081", "to": "8081"}], ... ) ... if err: ... print(f"Error updating segment: {err}") ... return ... print(f"segment updated successfully: {update_segment.as_dict()}")
Update an Browser Access application segment
>>> update_segment, _, err = client.zpa.application_segment.update_segment( ... segment_id='99999', ... name=f"UpdateAppSegment_{random.randint(1000, 10000)}", ... description=f"UpdateAppSegment_{random.randint(1000, 10000)}", ... enabled=True, ... domain_names=["test.example.com", "test1.example.com"], ... segment_group_id="72058304855089379", ... server_group_ids=["72058304855090128"], ... tcp_port_range=[{"from": "8081", "to": "8081"}], ... clientless_app_ids=[ { "name": "jenkins.securitygeek.io", "enabled": True, "certificate_id": "72058304855021564", "application_port": "4443", "application_protocol": "HTTPS", "domain": "jenkins.securitygeek.io", } ] ... ) ... if err: ... print(f"Error updating segment: {err}") ... return ... print(f"segment updated successfully: {update_segment.as_dict()}")