Uploads (risksense_api.__subject.__uploads.__uploads
)¶
Upload module defined for different upload related api endpoints.
- class risksense_api.__subject.__uploads.__uploads.Uploads(profile)[source]¶
Bases:
Subject
Class for upload function definitions.
- Parameters:
profile (
object
) – Profile Object
To utlise upload function:
- Usage:
self.{risksenseobjectname}.uploads.{function}
Examples
Create an upload using
create()
function>>> self.{risksenseobjectname}.uploads.create(args)
- __init__(profile)[source]¶
Initialization of Uploads object.
- Parameters:
profile (
object
) – Profile Object
- get_uploads(assessment_id, page_num=0, page_size=150, client_id=None)[source]¶
Get uploads associated with an assessment.
- Parameters:
assessment_id (
int
) – The assessment ID.page_num (
int
) – The page number of results to return.page_size (
int
) – The number of results per page to return.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 response from the platform is returned.
Examples
>>> apiobj = self.{risksenseobject}.uploads.get_uploads(1234,page_num=1,page_size=100)
- create(name, assessment_id, network_id, client_id=None)[source]¶
Create a new upload.
- Parameters:
name (
str
) – The name to be associated with the upload.assessment_id (
int
) – The assessment ID.network_id (
int
) – The network ID.client_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 Upload ID
Examples
>>> apiobj = self.{risksenseobject}.uploads.create('test',123,123,client_id=123)
- check_state(upload_id, client_id=None)[source]¶
Check the state of an upload.
- Parameters:
upload_id (
int
) – The upload ID.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
str
- Returns:
The current state of the upload is returned.
Examples
>>> apiobj = self.{risksenseobject}.uploads.check_state(1234)
- update(upload_id, name, network_id, assessment_id, client_id=None)[source]¶
Update an upload. Uploads can only be updated before they have been processed.
- Parameters:
upload_id (
int
) – The upload ID.name (
str
) – File namenetwork_id (
int
) – Network ID.assessment_id (
int
) – Assessment IDclient_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 upload ID is returned.
Examples
>>> apiobj = self.{risksenseobject}.uploads.update(1234,'test',123,123,client_id=123)
- delete(upload_id, client_id=None)[source]¶
Delete an Upload.
- Parameters:
upload_id (
int
) – The upload IDclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
bool
- Returns:
True/False reflecting whether or not the operation was successful.
Examples
>>> apiobj = self.{risksenseobject}.uploads.delete(1234)
- list_files(upload_id, page_num=0, page_size=150, client_id=None)[source]¶
List files in an upload.
- Parameters:
upload_id (
int
) – The upload IDpage_num (
int
) – The page number to be returned.page_size (
int
) – The number of results to return per page.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:
A paginated JSON response from the platform.
Examples
>>> apiobj = self.{risksenseobject}.uploads.list_files(1234,page_num=1,page_size=100)
- add_file(upload_id, file_name, path_to_file, client_id=None)[source]¶
Add a file to an upload.
- Parameters:
upload_id (
int
) – Upload IDfile_name (
str
) – The name to be used for the uploaded file.path_to_file (
str
) – Full path to the file to be uploaded.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 file ID along with jsonified response is returned.
Examples
>>> apiobj = self.{risksenseobject}.uploads.add_file(1234,'test','D:\test\test.nessus')
- update_file(upload_id, file_id, client_id=None, **kwargs)[source]¶
Update an uploaded file. Will only work if the file has not yet been processed.
- Parameters:
upload_id (
int
) – The upload ID.file_id (
int
) – The file ID.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Keyword Arguments:
assessment_id (
int
) – The assessment ID the upload should be associated with. Integer.network_id (
int
) – The network ID the upload should be associated with. Integer.application_id (
int
) – The application ID the upload should be associated with. Integer.
- Return type:
int
- Returns:
The upload ID is returned
Examples
>>> apiobj = self.{risksenseobject}.uploads.update_file(1234,123,assessment_id=123,network_id=123,application_id=123)
- delete_file(upload_id, file_id, client_id=None)[source]¶
Delete an uploaded file.
- Parameters:
upload_id (
int
) – The upload ID.file_id (
int
) – The file ID.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
bool
- Returns:
True/False reflecting whether or not the operation was successfully submitted.
Examples
>>> apiobj = self.{risksenseobject}.uploads.delete_file(1234,123)
- download_file(upload_id, file_name, client_id=None)[source]¶
Download a previously uploaded file.
- Parameters:
upload_id (
int
) – The upload IDfile_name (
str
) – The filenameclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
bool
- Returns:
True/False reflecting whether or not the operation was successful.
Examples
>>> apiobj = self.{risksenseobject}.uploads.download_file(1234,'test')
- fetch_file_by_uuid(upload_id, file_uuid, file_destination, client_id=None)[source]¶
Download a file by UUID.
- Parameters:
upload_id (
int
) – The upload IDfile_uuid (
str
) – The file UUIDfile_destination (
str
) – The local destination for the downloaded file.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
bool
- Returns:
True/False reflecting whether or not the operation was successful.
Examples
>>> apiobj = self.{risksenseobject}.uploads.fetch_file_by_uuid(1234,'123-456','D:\test\test.xml')
- start_processing(upload_id, auto_urba=False, client_id=None)[source]¶
Initiate processing of an upload.
- Parameters:
upload_id (
int
) – The upload IDauto_urba (
bool
) – Indicator for whether or not auto-URBA should be run after upload is processed.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
bool
- Returns:
True/False reflecting whether or not the operation was successfully submitted.
Examples
>>> apiobj = self.{risksenseobject}.uploads.start_processing(1234,True)