Networks (risksense_api.__subject.__networks.__networks
)¶
Network module defined for different network related api endpoints.
- class risksense_api.__subject.__networks.__networks.Networks(profile)[source]¶
Bases:
Subject
Class for network function definitions.
- Parameters:
profile (
object
) – Profile Object
To utlise network function:
- Usage:
self.{risksenseobjectname}.networks.{function}
Examples
To create a network using
create()
function>>> self.{risksenseobjectname}.networks.create(args)
- __init__(profile)[source]¶
Initialization of Networks object.
- Parameters:
profile (
object
) – Profile Object
- list_network_filter_fields(client_id=None)[source]¶
List filter endpoints.
- Parameters:
client_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 output from the platform is returned, listing the available filters.
Examples
>>> apiobj = self.{risksenseobject}.networks.list_network_filter_fields(client_id=124)
- create(name, client_id=None, csvdump=False)[source]¶
Create a new network.
- Parameters:
name (
str
) – The name for the new network.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
int
- Returns:
The new network job ID.
Examples
>>> apiobj = self.{risksenseobject}.networks.create('test_aug', 'IP')
Note
You can also dump the data of the network job id in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.networks.create('test_aug', 'IP',csvdump=True)
- update(network_id, name, client_id=None, csvdump=False)[source]¶
Update an existing network.
- Parameters:
network_id (
int
) – The network ID.name (
str
) – A new name for the network.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
int
- Returns:
Network job id
Examples
>>> apiobj = self.{risksenseobject}.networks.update(291935, 'test_aug1')
Note
You can also dump the data of the network job id in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.networks.update(291935, 'test_aug1',csvdump=True)
- delete(network_id, client_id=None, csvdump=False)[source]¶
Deletes a network.
- Parameters:
network_id (
int
) – The network ID to be deleted.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
int
- Returns:
True/False indicating whether or not the operation was successful.
Examples
>>> apiobj = self.{risksenseobject}.networks.delete(1234,client_id=123)
Note
You can also dump the data of the network tht will be deleted in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.networks.delete(1234,client_id=123,csvdump=True)
- get_single_search_page(search_filters, page_num=0, page_size=150, sort_field='id', sort_dir='ASC', client_id=None)[source]¶
Searches for and returns networks based on the provided filter(s) and other parameters.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.page_num (
int
) – Page number of results to be returned.page_size (
int
) – Number of results to be returned per page.sort_field (
str
) – Name of field to sort results on.sort_dir (
str
) – Direction to sort. 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:
A paginated JSON response from the platform is returned.
Examples
>>> apiobj = self.{risksenseobject}.networks.get_single_search_page([{"field":"name","exclusive":False,"operator":"IN","orWithPrevious":False,"implicitFilters":[],"value":"test"}])
- search(search_filters, page_size=150, sort_field='id', sort_dir='ASC', client_id=None, csvdump=False)[source]¶
Searches for and returns networks 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.page_size (
int
) – The number of results per page to be returned.sort_field (
str
) – Name of field to sort results on.sort_dir (
str
) – Direction to sort. 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.csvdump (
bool
) – Whether retrieved search details to be dumped in a csv file or not
- Return type:
list
- Returns:
A list containing all networks returned by the search using the filter provided.
Examples
>>> apiobj = self.{risksenseobject}.networks.search([{"field":"name","exclusive":False,"operator":"IN","orWithPrevious":False,"implicitFilters":[],"value":"test"}])
Note
You can also dump the data of the network search in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.networks.search([{"field":"name","exclusive":False,"operator":"IN","orWithPrevious":False,"implicitFilters":[],"value":"test"}],csvdump=True)
- get_model(client_id=None)[source]¶
Get available projections and models for Networks.
- Parameters:
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.- Return type:
dict
- Returns:
Networks projections and models are returned.
Examples
>>> apiobj = self.{risksenseobject}.networks.get_model()
- suggest(search_filters, suggest_filter, client_id=None)[source]¶
Suggest values for filter fields.
- Parameters:
search_filters (
list
) – Active Filters inputsuggest_filter (
dict
) – Suggest Filter inputclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Value suggestions
Examples
>>> apiobj = self.{risksenseobject}.networks.suggest([],{"field":"name","exclusive":False,"operator":"WILDCARD","value":"tes*","implicitFilters":[]})