custom_file_types¶
The following methods allow for interaction with the ZIA Custom File Types API endpoints.
Methods are accessible via zia.custom_file_types
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 CustomFileTypesAPI¶
Bases:
APIClient- add_custom_file_type(**kwargs)¶
Adds a new custom file type.
- Parameters:
name (str) – Custom file type name
- Keyword Arguments:
name (str) – Custom file type name
description (str) – Additional information about the custom file type, if any.
extension (str) – Specifies the file type extension. The maximum extension length is 10 characters. Existing Zscaler extensions cannot be added to custom file types.
file_type_id (int) – File type ID. This ID is assigned and maintained for all file types including predefined and custom file types and this value is different from the custom file type ID.
- Returns:
new custom file type resource record.
- Return type:
Example
add an a new custom file type:
>>> zia.custom_file_types.add_custom_file_type( ... name='FileType02', ... description='FileType02', ... extension='tf' ... )
- delete_custom_file_type(file_id)¶
Deletes a custom file type based on the specified ID
- Parameters:
file_id (int) – The unique identifier for the custom file types
- Returns:
The status code for the operation.
- Return type:
Examples
>>> zia.custom_file_types.delete_custom_file_type('278454')
- get_custom_file_type_count()¶
Retrieves the count of custom file types available. The API returns a scalar (e.g. 1); this method returns it as an int.
- Returns:
A tuple containing (count of custom file types as int, Response, error).
- Return type:
Examples
Retrieve the custom file type count (returns int):
>>> count, response, error = zia.custom_file_types.get_custom_file_type_count() >>> if not error: ... print(f"Custom file types count: {count}")
- get_custom_file_tytpe(file_id)¶
Retrieves information about a custom file type based on the specified ID
- Parameters:
file_id (str) – The unique identifier for the custom file types filter.
- Returns:
A tuple containing (custom file types instance, Response, error).
- Return type:
Example
Retrieve a custom file types by its ID:
>>> file, response, error = zia.custom_file_types.get_custom_file_tytpe(file_id=123456) >>> if not error: ... print(file.as_dict())
- list_custom_file_types(query_params=None)¶
Retrieves the list of Custom file types can be configured as rule conditions in different ZIA policies.
- Parameters:
{dict} (query_params) –
Map of query parameters for the request.
[query_params.search]{str}: Search string for filtering results.[query_params.page]{int}: Specifies the page offset[query_params.page_size]{int}: Specifies the page size. Default value: 250- Returns:
A tuple containing (list of custom file types instances, Response, error).
- Return type:
Example
List all custom file types with a specific page size:
>>> files_list, response, error = zia.custom_file_types.list_custom_file_types( ... query_params={"page_size": 50} ... ) >>> for file in files_list: ... print(file.as_dict())
- update_custom_file_type(file_id, **kwargs)¶
Updates information for a custom file type based on the specified ID
- Parameters:
file_id (int) – The unique ID for the custom file type that is being updated.
**kwargs – Optional keyword args.
- Keyword Arguments:
name (str) – Custom file type name
description (str) – Additional information about the custom file type, if any.
extension (str) – Specifies the file type extension. The maximum extension length is 10 characters. Existing Zscaler extensions cannot be added to custom file types.
file_type_id (int) – File type ID. This ID is assigned and maintained for all file types including predefined and custom file types and this value is different from the custom file type ID.
- Returns:
update an existing custom file type resource record.
- Return type:
Example
Update an existing custom file type to change its name and action:
>>> zia.custom_file_types.update_custom_file_type( ... file_id=123456, ... name='FileType02', ... description='FileType02', ... extension='tf' ... )