servers

The following methods allow for interaction with the ZPA Application Servers API endpoints.

Methods are accessible via zpa.servers

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 AppServersAPI

Bases: APIClient

A Client object for the Application Server resource.

add_server(**kwargs)

Add a new application server.

Parameters:
  • **name (str) – The name of the server.

  • **description (str) – The name of the server.

  • **address (str) – The IP address of the server.

  • **enabled (bool) – Enable the server. Defaults to True.

  • **app_server_group_ids (list) – The list of unique identifiers for the Server Group.

  • **config_space (str) – The configuration space. Accepted values are DEFAULT or SIEM.

  • **microtenant_id (str) – The unique identifier of the Microtenant for the ZPA tenant.

Returns:

AppServers: The newly created portal object.

Return type:

Tuple

Examples

>>> new_server, _, err = client.zpa.servers.add_server(
...     name="NewAppServer",
...     description="NewAppServer",
...     enabled=True,
...     app_server_group_ids=['99999'],
... )
... if err:
...     print(f"Error creating app server: {err}")
...     return
... print(f"app server created successfully: {new_portal.as_dict()}")
delete_server(server_id, microtenant_id=None)

Delete the specified server.

Parameters:
  • server_id (str) – The unique identifier for the server to be deleted.

  • microtenant_id (str) – The unique identifier of the Microtenant for the ZPA tenant.

Returns:

Status code of the delete operation.

Return type:

int

Examples

>>> _, _, err = client.zpa.servers.delete_server(
...     server_id='999999'
... )
... if err:
...     print(f"Error deleting application server: {err}")
...     return
... print(f"application server with ID {'999999'} deleted successfully.")
get_server(server_id, query_params=None)

Gets information on the specified server.

Parameters:

server_id (str) – The unique identifier of the server.

Returns:

AppServers: The corresponding server object.

Return type:

Tuple

Examples

>>> fetched_server, _, err = client.zpa.servers.get_server('999999')
... if err:
...     print(f"Error fetching app server by ID: {err}")
...     return
... print(f"Fetched app server by ID: {fetched_server.as_dict()}")
list_servers(query_params=None)

Enumerates application servers in your organization with pagination. A subset of application servers can be returned that match a supported filter expression or query.

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.page] {str}: Specifies the page number.

[query_params.page_size] {int}: Specifies the page size.

If not provided, the default page size is 20. The max page size is 500.

[query_params.search] {str}: The search string used to support search by features and fields for the API.

[query_params.microtenant_id] {str}: The unique identifier of the microtenant of ZPA tenant.

Returns:

A tuple containing (list of ApplicationServer instances, Response, error)

Return type:

Tuple

Examples

>>> server_list, _, err = client.zpa.servers.list_servers(
... query_params={'search': 'Server01', 'page': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing application servers: {err}")
...     return
... print(f"Total application servers found: {len(server_list)}")
... for server in server_list:
...     print(server.as_dict())
list_servers_summary(query_params=None)

Retrieves all configured application servers Name and IDs

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.page] {str}: Specifies the page number.

[query_params.page_size] {int}: Specifies the page size.

If not provided, the default page size is 20. The max page size is 500.

[query_params.search] {str}: The search string used to support search by features and fields for the API.

[query_params.microtenant_id] {str}: The unique identifier of the microtenant of ZPA tenant.

Returns:

A tuple containing (list of ApplicationServer instances, Response, error)

Return type:

Tuple

Examples

>>> server_list, _, err = client.zpa.servers.list_servers_summary(
... query_params={'search': 'Server01', 'page': '1', 'page_size': '100'})
... if err:
...     print(f"Error listing application servers: {err}")
...     return
... print(f"Total application servers found: {len(server_list)}")
... for server in server_list:
...     print(server.as_dict())
update_server(server_id, **kwargs)

Updates the specified server.

Parameters:
  • server_id (str) – The unique identifier for the server being updated.

  • microtenant_id (str) – The unique identifier of the Microtenant for the ZPA tenant.

Returns:

AppServers: The updated application server object.

Return type:

Tuple

Examples

>>> update_server, _, err = client.zpa.servers.update_server(
...     server_id="999999",
...     name="UdpateApplicationServer",
...     description="UdpateApplicationServer",
...     enabled=True,
... )
... if err:
...     print(f"Error creating application servers: {err}")
...     return
... print(f"application servers created successfully: {new_portal.as_dict()}")