Attachments (risksense_api.__subject.__attachments.__attachments
)¶
Attachments module defined for different attachments related api endpoints.
- class risksense_api.__subject.__attachments.__attachments.Attachments(profile)[source]¶
Bases:
Subject
Class for Attachments function defintions.
To utlise Attachments function:
- Parameters:
profile (
object
) – Profile Object
- Usage:
self.{risksenseobjectname}.attachments.{function}
Examples
To list attachments attached to a tag using
list_attachments()
function>>> self.{risksenseobject}.attachments.list_attachments({tag_id})
- __init__(profile)[source]¶
Initialization of Attachments object.
- Parameters:
profile (
object
) – Profile Object
- upload(tag_id, file_name, client_id=None)[source]¶
Upload a new attachment for a tag.
- Parameters:
tag_id (
int
) – The tag ID.file_name (
str
) – 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:
str
- Returns:
The UUID of the uploaded file is returned.
Example
To upload an attachment to a tag 123
>>> self.{risksenseobject}.attachments.upload(123,'test.csv')
- list_attachments(tag_id, client_id=None)[source]¶
List the attachment(s) associated with a tag.
- Parameters:
tag_id (
int
) – The tag ID.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 attachments information from the platform is returned.
Example
To list attachments for tag id 123
>>> self.rs.attachments.list_attachments(123)
- get_attachment(tag_id, attachment_uuid, file_destination, client_id=None)[source]¶
Get an attachment associated with a tag.
- Parameters:
tag_id (
int
) – Integer. The tag ID.attachment_uuid (
str
) – String. The UUID for the attachment to be downloaded.file_destination (
str
) – String. The location to save the attachment locally.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:
A True/False is returned reflecting whether or not the operation was successful.
Example
>>> self.rs.attachments.get_attachment(123,"attachmentuuid","path.csv")
- delete(tag_id, attachment_uuid, client_id=None)[source]¶
Delete an attachment associated with a tag.
- Parameters:
tag_id (
int
) – The tag ID.attachment_uuid (
str
) – The UUID for the attachment to be deleted.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 job ID is returned
Example
To delete attachment in a tag
>>> self.{risksenseobject}.attachments.delete(123,'attachmentuuid123')
- get_metadata(tag_id, attachment_uuid, client_id=None)[source]¶
Get the metadata associated with an attachment.
- Parameters:
tag_id (
int
) – The tag ID.attachment_uuid (
str
) – The UUID for the attachment to be deleted.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 containing the metadata is returned.
Example
Get attachment metadata
>>> self.{risksenseobject}.attachment.get_metada(123,"attachmentuuid123")