Patch (risksense_api.__subject.__patch.__patch
)¶
Patch
- class risksense_api.__subject.__patch.__patch.Patch(profile)[source]¶
Bases:
Subject
Class for Patch function defintions.
To utlise Patch function:
- Parameters:
profile (
object
) – Profile Object
- Usage:
self.{risksenseobjectname}.patch.{function}
Examples
To search for patch using
get_model()
function>>> self.{risksenseobject}.patch.search({filter})
- downloadfilterinexport(filename, filters, client_id=None)[source]¶
Exports and Downloads a file based on the filters defined .
- Parameters:
filename (
str
) – Name of the file to export asfilters (
list
) – Patch search filters based on which the export performsclient_id (
typing.Optional
[int
]) – The client id to get the data from. If not supplied, takes default client id
Examples
>>> self.{risksenseobject}.patch.downloadfilterinexport('patchdata',[])
- __init__(profile)[source]¶
Initialization of Patch Object .
- Parameters:
profile (
object
) – Profile Object
- getexporttemplate(client_id=None)[source]¶
Gets configurable export template for patches.
- Parameters:
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.- Return type:
list
- Returns:
The Exportable fields
Example
An example to use getexporttemplate
>>> self.{risksenseobject}.patch.getexporttemplate()
This gets all the export templates for patch
- export(search_filters, file_name, row_count='All', file_type='CSV', client_id=None)[source]¶
Initiates an export job on the platform for patche(s) based on the provided filter(s).
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.file_name (
str
) – The name to be used for the exported file.row_count (
str
) – No of rows to be exported. Available options ExportRowNumbers.ROW_10000, ExportRowNumbers.ROW_25000, ExportRowNumbers.ROW_50000, ExportRowNumbers.ROW_100000, ExportRowNumbers.ROW_ALLfile_type (
str
) – File type to export. ExportFileType.CSV, ExportFileType.JSON, or ExportFileType.XLSXclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
int
- Returns:
The job ID in the platform from is returned.
Example
An example to use export is
>>> self.{risksenseobject}.patch.export([],'testingexport')
You can change the filetype to any of the names above or even the other positional arguments as mentioned
>>> self.{risksenseobject}.patch.export([],'testingexport',file_type=ExportFileType.JSON)
- get_filter(client_id=None)[source]¶
Get a list of supported patch filters.
- Parameters:
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.- Return type:
list
- Returns:
Filter information
Examples
>>> self.{risksenseobject}.patch.get_filter()
- get_single_search_page(search_filters, projection='basic', page_num=0, page_size=150, sort_field='id', sort_dir='ASC', client_id=None)[source]¶
Searches for and returns patch based on the provided filter(s) and other parameters.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.projection (
str
) – Projection to be used in API request. Projection.BASIC or Projection.DETAILpage_num (
int
) – The page number of results to be returned.page_size (
int
) – The number of results per page to be returned.sort_field (
str
) – The field to be used for sorting results returned.sort_dir (
str
) – The direction of sorting to be used. SortDirection.ASC or SortDirection.DESCclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
The JSON response from the platform is returned.
Example
An example to get single search page of patch data
>>> self.{risksenseobject}.patch.get_single_search_page([])
You can also try changing the other arguments to your liking to reflect the data as you suffice such as change page_size or page_num etc.
>>> self.{risksenseobject}.patch.get_single_search_page([],page_num=2,page_size=10)
- search(search_filters, projection='basic', page_size=150, sort_field='id', sort_dir='ASC', csvdump=False, client_id=None)[source]¶
Searches for and returns patch data based on the provided filter(s) and other parameters. Rather than returning paginated results, this function cycles through all pages of results and returns them all in a single list.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.projection (
str
) – Projection to be used in API request. Projection.BASIC or Projection.DETAILpage_size (
int
) – The number of results per page to be returned.sort_field (
str
) – The field to be used for sorting results returned.sort_dir (
str
) – The direction of sorting to be used. SortDirection.ASC or SortDirection.DESCcsvdump (
bool
) – dumps the data in csvclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
list
- Returns:
A list containing all patch returned by the search using the filter provided.
Example
An example to search for patches data is
>>> self.{risksenseobject}.patch.search([])
Note
You can also dump the search based data in a csv by simply providing
csvdump=True
argument>>> self.{risksenseobject}.patch.search([],csvdump=True)
- suggest(search_filter_1, search_filter_2, client_id=None)[source]¶
Suggest values for filter fields.
- Parameters:
search_filter_1 (
list
) – Search Filter 1search_filter_2 (
dict
) – Search Filter 2client_id (
typing.Optional
[int
]) – Client ID
- Return type:
list
- Returns:
suggestions
Example
To use suggest function is
>>> self.{risksenseobject}.patch.suggest([],{})