SendSafely Python API Documentation
Module contents¶
- class sendsafely.Package(sendsafely_instance, package_variables=None)¶
Bases:
object
To be used in conjunction with it’s handler the SendSafely object. Should not be instantiated directly.
- add_recipient(email)¶
Adds a recipient to this package
- Parameters
email – The email to add to this package
- Returns
The response from the server
- delete_file_from_package(file_id)¶
Deletes the file with the specified id from the package with the specified ID.
- download_and_decrypt_file(file_id, directory_id=None, download_directory='.', file_name=None)¶
Downloads & decrypts the specified file to the path specified
- encrypt_and_upload_file(filepath, directory_id=None)¶
Adds the passed file to the package with the specified ID.
If bigger than 2621440 Bytes, split the file by 2621440 Bytes and set parts according to the amount of splits.
- Parameters
filepath – The path of the file we’re uploading
- Returns
The JSON response
- encrypt_and_upload_message(message)¶
Adds a message to this package.
- Parameters
message – the message to add
- Returns
the JSON response
- finalize()¶
Finalizes the package, returns a link, including the keycode.
- Returns
A link the recipient can access it with if successful
- get_file_information(file_id)¶
- Returns
The file information for a specified fileId
- get_info()¶
Get a detailed status of a given package
- Parameters
package_id – The package you desire to inquire about.
- Returns
The detailed status as a JSON response.
- get_package_message()¶
- Returns
The decrypted message.
- get_public_keys()¶
- update_recipient_phone_number(recipient_id, phone, country_code='US')¶
Update a recipient phone number
- Parameters
recipient_id – The id of the recipient
phone – The desired phone number, string in the form “(123) 456-7890”
country_code – The country code
- Returns
The response from the server
- class sendsafely.SendSafely(url, api_key, api_secret)¶
Bases:
object
Class used to setup authentication and interface with the REST API. Acts as a handler for the specific queries one may perform either on packages, or more generally as a user.
- API_KEY = None¶
- API_SECRET = None¶
- API_URL = '/api/v2.0'¶
- BASE_URL = None¶
- KEY_ID = None¶
- KEY_PAIR = None¶
- delete_package(package_id)¶
Deletes a given package.
- Parameters
package_id – the package you desire to delete.
- Returns
the JSON response.
- generate_trusted_device_key_pair(description)¶
Adds a public key to this user.
- Parameters
description – A description of this public key to submit to SendSafely.
- Returns
The response, including key pair.
- get_package_information(package_id)¶
Get a detailed status of a given package.
- Parameters
package_id – The package you desire to inquire about.
- Returns
The detailed status as a JSON response.
- get_package_information_from_link(link)¶
Get a detailed status of a given package given a secure link.
- Parameters
link – The secure link.
- Returns
The detailed status as a JSON response.
- get_package_keycode(package_id, public_key_id, private_key)¶
Gets the decrypted package keycode using trusted device keys.
Trusted device must have been assigned prior to the package being uploaded.
- Parameters
package_id – The package Id
public_key_id – The public key id for the trusted device
private_key – The private trusted device key
- Returns
The decrypted keycode
- get_received_packages(row_index=0, page_size=100)¶
Get all packages received by this user.
- Parameters
row_index – The row to start at (Default = 0).
page_size – The number of pages to fetch at a time (Default = 100).
- Returns
The JSON response as a list of packages
- get_sent_packages(row_index=0, page_size=100)¶
Get all packages sent by this user.
- Parameters
row_index – The row to start at. (Default = 0)
page_size – The number of pages to fetch at a time. (Default = 100)
- Returns
The JSON response as a list of packages
- get_user_information()¶
- load_package(package_id, key_code=None)¶
Builds a Package object from information about that package.
- Parameters
package_id – The Package ID.
key_code – The client secret/keycode for this package (optional).
- Returns
The Package Object.
- load_package_from_link(link)¶
Creates a package object from a secure link. :param link: The link. :returns: The Package associated with that link.
- revoke_trusted_device_key(public_key_id)¶
Removes the public key with public_key_id from this account.
- Parameters
public_key_id – The public key ID.
- Returns
the JSON response.
- sendsafely.make_headers(api_secret, api_key, endpoint, request_body=None)¶
Makes headers used for secure requests against the SendSafely API.
- Parameters
api_secret – Your API secret, from the SendSafely handler.
api_key – Your API_KEY, from the SendSafely handler.
endpoint – Everything after the Fully Qualified Domain Name.
request_body – The request body. If you’re passing in a JSON object, make sure you wrap it in json.dumps()
- Returns
The headers appropriate for the HTTP Request you’re about to make.
Submodules¶
sendsafely.Package module¶
- class sendsafely.Package.Package(sendsafely_instance, package_variables=None)¶
Bases:
object
To be used in conjunction with it’s handler the SendSafely object. Should not be instantiated directly.
- add_recipient(email)¶
Adds a recipient to this package
- Parameters
email – The email to add to this package
- Returns
The response from the server
- delete_file_from_package(file_id)¶
Deletes the file with the specified id from the package with the specified ID.
- download_and_decrypt_file(file_id, directory_id=None, download_directory='.', file_name=None)¶
Downloads & decrypts the specified file to the path specified
- encrypt_and_upload_file(filepath, directory_id=None)¶
Adds the passed file to the package with the specified ID.
If bigger than 2621440 Bytes, split the file by 2621440 Bytes and set parts according to the amount of splits.
- Parameters
filepath – The path of the file we’re uploading
- Returns
The JSON response
- encrypt_and_upload_message(message)¶
Adds a message to this package.
- Parameters
message – the message to add
- Returns
the JSON response
- finalize()¶
Finalizes the package, returns a link, including the keycode.
- Returns
A link the recipient can access it with if successful
- get_file_information(file_id)¶
- Returns
The file information for a specified fileId
- get_info()¶
Get a detailed status of a given package
- Parameters
package_id – The package you desire to inquire about.
- Returns
The detailed status as a JSON response.
- get_package_message()¶
- Returns
The decrypted message.
- get_public_keys()¶
- update_recipient_phone_number(recipient_id, phone, country_code='US')¶
Update a recipient phone number
- Parameters
recipient_id – The id of the recipient
phone – The desired phone number, string in the form “(123) 456-7890”
country_code – The country code
- Returns
The response from the server
sendsafely.SendSafely module¶
- class sendsafely.SendSafely.SendSafely(url, api_key, api_secret)¶
Bases:
object
Class used to setup authentication and interface with the REST API. Acts as a handler for the specific queries one may perform either on packages, or more generally as a user.
- API_KEY = None¶
- API_SECRET = None¶
- API_URL = '/api/v2.0'¶
- BASE_URL = None¶
- KEY_ID = None¶
- KEY_PAIR = None¶
- delete_package(package_id)¶
Deletes a given package.
- Parameters
package_id – the package you desire to delete.
- Returns
the JSON response.
- generate_trusted_device_key_pair(description)¶
Adds a public key to this user.
- Parameters
description – A description of this public key to submit to SendSafely.
- Returns
The response, including key pair.
- get_package_information(package_id)¶
Get a detailed status of a given package.
- Parameters
package_id – The package you desire to inquire about.
- Returns
The detailed status as a JSON response.
- get_package_information_from_link(link)¶
Get a detailed status of a given package given a secure link.
- Parameters
link – The secure link.
- Returns
The detailed status as a JSON response.
- get_package_keycode(package_id, public_key_id, private_key)¶
Gets the decrypted package keycode using trusted device keys.
Trusted device must have been assigned prior to the package being uploaded.
- Parameters
package_id – The package Id
public_key_id – The public key id for the trusted device
private_key – The private trusted device key
- Returns
The decrypted keycode
- get_received_packages(row_index=0, page_size=100)¶
Get all packages received by this user.
- Parameters
row_index – The row to start at (Default = 0).
page_size – The number of pages to fetch at a time (Default = 100).
- Returns
The JSON response as a list of packages
- get_sent_packages(row_index=0, page_size=100)¶
Get all packages sent by this user.
- Parameters
row_index – The row to start at. (Default = 0)
page_size – The number of pages to fetch at a time. (Default = 100)
- Returns
The JSON response as a list of packages
- get_user_information()¶
- load_package(package_id, key_code=None)¶
Builds a Package object from information about that package.
- Parameters
package_id – The Package ID.
key_code – The client secret/keycode for this package (optional).
- Returns
The Package Object.
- load_package_from_link(link)¶
Creates a package object from a secure link. :param link: The link. :returns: The Package associated with that link.
- revoke_trusted_device_key(public_key_id)¶
Removes the public key with public_key_id from this account.
- Parameters
public_key_id – The public key ID.
- Returns
the JSON response.
sendsafely.utilities module¶
- sendsafely.utilities.delete_request(sendsafely, endpoint)¶
- sendsafely.utilities.get_request(sendsafely, endpoint)¶
- sendsafely.utilities.make_headers(api_secret, api_key, endpoint, request_body=None)¶
Makes headers used for secure requests against the SendSafely API.
- Parameters
api_secret – Your API secret, from the SendSafely handler.
api_key – Your API_KEY, from the SendSafely handler.
endpoint – Everything after the Fully Qualified Domain Name.
request_body – The request body. If you’re passing in a JSON object, make sure you wrap it in json.dumps()
- Returns
The headers appropriate for the HTTP Request you’re about to make.
- sendsafely.utilities.patch_request(sendsafely, endpoint, body)¶
- sendsafely.utilities.post_request(sendsafely, endpoint, body)¶
- sendsafely.utilities.put_request(sendsafely, endpoint, body)¶
- sendsafely.utilities.save_key_pair(key_id, key_pair, path_to_save)¶
- sendsafely.utilities.update_progress(process_name, current, total)¶