time_intervals¶
The following methods allow for interaction with the ZIA Time Intervals API endpoints.
Methods are accessible via zia.time_intervals
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 TimeIntervalsAPI¶
Bases:
APIClientA Client object for the Time Intervals resource.
- add_time_intervals(**kwargs)¶
Creates a new ZIA Time Interval.
- Parameters:
name (str) – Name to identify the time interval
**kwargs – Optional keyword args.
- Keyword Arguments:
- Returns:
A tuple containing the newly added Time Interval, response, and error.
- Return type:
Examples
Add a new Time Interval
>>> added_interval, _, error = client.zia.time_intervals.add_time_intervals( ... name=f"NewTimeInterval01_{random.randint(1000, 10000)}", ... start_time='0', ... end_time='1439', ... days_of_week=["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"], ... ) >>> if error: ... print(f"Error adding Time Interval: {error}") ... return ... print(f"Time Interval added successfully: {added_interval.as_dict()}")
- delete_time_intervals(interval_id)¶
Deletes the specified Time Interval.
- Parameters:
interval_id (str) – The unique identifier of the Time Interval.
- Returns:
A tuple containing the response object and error (if any).
- Return type:
Examples
Delete Time Interval:
>>> _, _, error = client.zia.time_intervals.delete_time_intervals('73459') >>> if error: ... print(f"Error deleting Time Interval: {error}") ... return ... print(f"Time Interval with ID {'73459' deleted successfully.")
- get_time_intervals(interval_id)¶
Fetches a specific Time Intervals by ID.
- Parameters:
interval_id (int) – The unique identifier for the Time Interval.
- Returns:
A tuple containing (Time Interval instance, Response, error).
- Return type:
Examples
Retrieve a specific time interval:
>>> fetched_interval, _, error = client.zia.time_intervals.get_time_intervals('125245') >>> if error: ... print(f"Error fetching time interval by ID: {error}") ... return ... print(f"Fetched time interval by ID: {fetched_interval.as_dict()}")
- list_time_intervals(query_params=None)¶
Retrieves a list of all configured time intervals.
- 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 Time Intervals instances, Response, error)
- Return type:
Examples
List Time Intervals using default settings:
>>> interval_list, _, error = client.zia.time_intervals.list_time_intervals( query_params={'search': Off-Work}) >>> if error: ... print(f"Error listing intervals: {error}") ... return ... print(f"Total intervals found: {len(interval_list)}") ... for interval in interval_list: ... print(interval.as_dict())
- update_time_intervals(interval_id, **kwargs)¶
Updates information for the specified ZIA Time Interval.
- Parameters:
interval_id (int) – The unique ID for the Time Interval.
- Returns:
A tuple containing the updated Time Interval, response, and error.
- Return type:
Examples
Update a Time Interval
>>> added_interval, _, error = client.zia.time_intervals.update_time_intervals( interval_id='15455' ... name=f"UpdateTimeInterval01_{random.randint(1000, 10000)}", ... start_time='0', ... end_time='1439', ... days_of_week=["SUN", "MON", "TUE", "WED", "THU"], ... ) >>> if error: ... print(f"Error updating Time Interval: {error}") ... return ... print(f"Time Interval updated successfully: {added_interval.as_dict()}")