account_groups¶
The following methods allow for interaction with the ZTW Account Groups API endpoints.
Methods are accessible via ztw.account_groups
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 AccountGroupsAPI¶
Bases:
APIClient- add_account_group(**kwargs)¶
Creates an AWS account group. You can create a maximum of 128 groups in each organization.
See the Partner Integrations API reference (accountGroups-post): for further detail on payload structure.
- Keyword Arguments:
- Returns:
A tuple containing (AccountGroups instance, Response, error)
- Return type:
Examples
Add a new Account Group:
>>> new_account_group, response, error = ztw.account_groups.add_account_group( ... name="Account Group 01", ... description="This is an account group for demonstration" ... ) ... if error: ... print(f"Error adding account group: {error}") ... return ... print(f"Created public cloud info: {new_cloud_info.as_dict()}")
- delete_account_group(account_group_id)¶
Removes a specific AWS account group based on the provided ID.
- Parameters:
account_group_id (int) – The unique ID of the AWS account group.
- Returns:
A tuple containing (None, Response, error). The API returns 204 No Content on success.
- Return type:
Examples
>>> _, _, error = client.ztw.account_groups.delete_account_group(545845) ... if error: ... print(f"Error deleting account group: {error}") ... return ... print("Account group deleted successfully")
- get_account_group(account_group_id)¶
Retrieves the existing AWS account group based on the provided ID.
- Parameters:
account_group_id (int) – The ID of the AWS account group.
- Returns:
A tuple containing (AccountGroups instance, Response, error)
- Return type:
Examples
>>> fetched_public_cloud_info, response, error = ( ... client.ztw.account_groups.get_account_group(18382907) ... ) ... if error: ... print(f"Error fetching account group by ID: {error}") ... return ... print(f"Fetched account group by ID: {fetched_account_group.as_dict()}")
- get_account_group_count()¶
Retrieves the total number of AWS account groups.
- Returns:
A tuple containing a list of dictionaries with configuration count information, the response object, and error if any.
- Return type:
Tuple
Examples
>>> count, _, error = client.ztw.account_groups.get_account_group_count() ... if error: ... print(f"Error getting account group count: {error}") ... return ... print(f"Total account groups found: {count}")
Examples
>>> count, _, error = client.ztw.account_groups.get_account_group_count() ... if error: ... print(f"Error getting account group count: {error}") ... return ... print(f"Total account groups found: {count}")
- list_account_groups(query_params=None)¶
Retrieves the details of AWS account groups with metadata.
See the Partner Integrations API reference (accountGroups-get): for further detail on payload structure.
- 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 default size is 250.- Returns:
A tuple containing (list of AccountGroups instances, Response, error)
- Return type:
Examples
Gets a list of all account groups.
>>> account_groups_list, response, error = ztw.account_groups.list_account_groups() ... if error: ... print(f"Error listing account groups: {error}") ... return ... print(f"Total account groups found: {len(account_groups_list)}") ... for account_group in account_groups_list: ... print(account_group.as_dict())
- list_account_groups_lite()¶
Retrieves the ID and name of all the AWS account groups.
This endpoint returns a lightweight version of account groups containing only the essential information (ID and name) for all account groups.
- Returns:
A tuple containing (list of AccountGroups instances, Response, error)
- Return type:
Examples
Get a list of all account groups (lite version):
>>> account_groups_list, _, error = client.ztw.account_groups.list_account_groups_lite() ... if error: ... print(f"Error listing account groups: {error}") ... return ... print(f"Total account groups found: {len(account_groups_list)}") ... for account_group in account_groups_list: ... print(account_group.as_dict())
- update_account_group(account_group_id, **kwargs)¶
Updates the existing AWS account group details based on the provided ID.
- Parameters:
account_group_id (int) – The unique ID of the AWS account group.
- Keyword Arguments:
- Returns:
A tuple containing (AccountGroups instance, Response, error)
- Return type:
Examples
Update account group:
>>> updated_account_group, _, error = client.ztw.account_groups.update_account_group( ... account_group_id=452125, ... name="Updated Account Group", ... ) ... if error: ... print(f"Error updating account group: {error}") ... return ... print(f"Account group updated: {updated_account_group.as_dict()}")