email_profiles¶
The following methods allow for interaction with the ZIA Email Profiles API endpoints.
Methods are accessible via zia.email_profiles
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 EmailProfilesAPI¶
Bases:
APIClientA Client object for the Email profiles resource.
- add_email_profile(**kwargs)¶
Creates a new ZIA Email Profile.
- Parameters:
name (str) – The name of the email profile.
**kwargs – Optional keyword args.
- Keyword Arguments:
description (str) – Additional notes or information
- Returns:
A tuple containing the newly added Email Profile, response, and error.
- Return type:
Examples
Add a new Email Profile :
>>> added_profile, _, error = client.zia.email_profiles.add_email_profile( ... name=f"NewProfile_{random.randint(1000, 10000)}", ... description=f"NewProfile_{random.randint(1000, 10000)}", ... emails=['john.doe@example.com', 'mary.jane@example.com'] ... ) >>> if error: ... print(f"Error adding email profile: {error}") ... return ... print(f"Email Profile added successfully: {added_profile.as_dict()}")
- delete_email_profile(profile_id)¶
Deletes the specified Email Profile.
- Parameters:
profile_id (str) – The unique identifier of the Email Profile.
- Returns:
A tuple containing the response object and error (if any).
- Return type:
Examples
Delete an Email Profile:
>>> _, _, error = client.zia.email_profiles.delete_email_profile('73459') >>> if error: ... print(f"Error deleting Email Profile: {error}") ... return ... print(f"Email Profile with ID {'73459'} deleted successfully.")
- get_email_profile(profile_id)¶
Fetches a specific email profile by ID.
- Parameters:
profile_id (int) – The unique identifier for the email profile.
- Returns:
A tuple containing (Email Profile instance, Response, error).
- Return type:
Examples
Print a specific Email Profile
>>> fetched_profile, _, error = client.zia.email_profiles.get_email_profile( '1254654') >>> if error: ... print(f"Error fetching Email Profile by ID: {error}") ... return ... print(f"Fetched Email Profile by ID: {fetched_profile.as_dict()}")
- list_email_profiles(query_params=None)¶
Lists email profiles in your organization with pagination. A subset of email profiles 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]{int}: Specifies the page offset.[query_params.page_size]{int}: Page size for pagination.[query_params.search]{str}: Search string for filtering results.- Returns:
A tuple containing (list of Email Profiles instances, Response, error)
- Return type:
Examples
List Email Profiles using default settings:
>>> profile_list, _, error = client.zia.email_profiles.list_email_profiles( query_params={'search': updated_profile.name}) >>> if error: ... print(f"Error listing email profiles: {error}") ... return ... print(f"Total email profiles found: {len(profile_list)}") ... for profile in profile_list: ... print(profile.as_dict())
Client-side filtering with JMESPath:
The response object supports client-side filtering and projection via
resp.search(expression). See the JMESPath documentation for expression syntax.
- update_email_profile(profile_id, **kwargs)¶
Updates information for the specified ZIA Email Profile.
- Parameters:
profile_id (int) – The unique ID for the Email Profile.
- Returns:
A tuple containing the updated Email Profile, response, and error.
- Return type:
Examples
Update an existing Email Profile :
>>> updated_profile, _, error = client.zia.email_profiles.update_email_profile( profile_id='1524566' ... name=f"UpdatedEmailProfile_{random.randint(1000, 10000)}", ... description=f"UpdatedEmailProfile_{random.randint(1000, 10000)}", ... ) >>> if error: ... print(f"Error updating Email Profile: {error}") ... return ... print(f"Email Profile updated successfully: {updated_profile.as_dict()}")