transloadit package¶
Submodules¶
transloadit.client module¶
-
class
transloadit.client.
Transloadit
(auth_key, auth_secret, service='https://api2.transloadit.com', duration=300)[source]¶ Bases:
object
This class serves as a client interface to the Transloadit API.
Attributes: - auth_key (str): Transloadit auth key.
- auth_secret (str): Transloadit auth secret.
- service (Optional[str]): URL of the Transloadit API.
- duration (int): How long in seconds for which a Transloadit request should be valid.
- request (transloadit.request.Request): An instance of the Transloadit HTTP Request object.
Constructor Args: - auth_key (str): Transloadit auth key.
- auth_secret (str): Transloadit aut secret.
- service (Optional[str]):
- Url of the Transloadit API. Defaults to ‘https://api2.transloadit.com’ if not specified.
- duration (Optional[int]):
- How long in seconds for which a Transloadit request should be valid. Defaults to 300 if not specified.
-
cancel_assembly
(assembly_id=None, assembly_url=None)[source]¶ Cancel the assembly specified by the ‘assembly_id’ or the ‘assembly_url’ Either the assembly_id or the assembly_url must be specified
Args: - assembly_id (Optional[str])
- assembly_url (Optional[str])
Return an instance of <transloadit.response.Response>
-
delete_template
(template_id)[source]¶ Delete the template specified by the ‘template_id’.
Args: - template_id (str)
Return an instance of <transloadit.response.Response>
-
get_assembly
(assembly_id=None, assembly_url=None)[source]¶ Get the assembly specified by the ‘assembly_id’ or the ‘assembly_url’ Either the assembly_id or the assembly_url must be specified
Args: - assembly_id (Optional[str])
- assembly_url (Optional[str])
Return an instance of <transloadit.response.Response>
-
get_bill
(month, year)[source]¶ Get the bill for the specified month and year.
Args: - month (int): e.g 1 for January
- year (int)
Return an instance of <transloadit.response.Response>
-
get_template
(template_id)[source]¶ Get the template specified by the ‘template_id’.
Args: - template_id (str)
Return an instance of <transloadit.response.Response>
-
list_assemblies
(params=None)[source]¶ Get the list of assemblies.
Args: - options (Optional[dict]):
- params to send along with the request. Please see https://transloadit.com/docs/api-docs/#25-retrieve-assembly-list for available options.
Return an instance of <transloadit.response.Response>
-
list_templates
(params=None)[source]¶ Get the list of templates.
Args: - options (Optional[dict]):
- params to send along with the request. Please see https://transloadit.com/docs/api-docs/#45-retrieve-template-list for available options.
Return an instance of <transloadit.response.Response>
-
new_assembly
(params=None)[source]¶ Return an instance of <transloadit.assembly.Assembly> which would be used to create a new assembly.
transloadit.assembly module¶
-
class
transloadit.assembly.
Assembly
(transloadit, files=None, options=None)[source]¶ Bases:
transloadit.optionbuilder.OptionBuilder
Object representation of a new Assembly to be created.
Attributes: - transloadit (<transloadit.client.Transloadit>):
- An instance of the Transloadit class.
- files (dict):
- Storage of files to be uploaded. Each file is stored with a key corresponding to its field name when it is being uploaded.
Constructor Args: - transloadit (<transloadit.client.Transloadit>)
- files (Optional[dict]):
- Key, value pair of the file’s field name and the file stream respectively.
- options (Optional[dict]):
- Params to send along with the assembly. Please see https://transloadit.com/docs/api-docs/#21-create-a-new-assembly for available options.
-
add_file
(file_stream, field_name=None)[source]¶ Add a file to be uploaded along with the Assembly.
Args: - file_stream (file): File stream object of the file to upload.
- field_name (Optional[str]): The field name assigned to the file.
- If not specified, a field name is auto-generated.
-
create
(wait=False, resumable=True, retries=3)[source]¶ Save/Submit the assembly for processing.
Args: - wait (Optional[bool]): If set to True, the method will wait till the assembly
- processing is complete before returning a response.
- resumable (Optional[bool]): A flag indicating if the upload should be resumable.
- This is good for cases of network failures. Defaults to True if not specified.
- retries (Optional[int]): In the event of an upload failure, this specifies how many
- more times the upload should be retried before crying for help. This option is only available if ‘resumable’ is set to ‘True’. Defaults to 3 if not specified.
transloadit.template module¶
-
class
transloadit.template.
Template
(transloadit, name, options=None)[source]¶ Bases:
transloadit.optionbuilder.OptionBuilder
Object representation of a new Template to be created.
Attributes: - transloadit (<translaodit.client.Transloadit>):
- An instance of the Transloadit class.
- name (str):
- The name of the template to be created.
Constructor Args: - transloadit (<translaodit.client.Transloadit>)
- name (str): The name of the template.
- options (Optional[dict]):
- Params to send along with the template. Please see https://transloadit.com/docs/api-docs/#4-templates for available options.
transloadit.optionbuilder module¶
-
class
transloadit.optionbuilder.
OptionBuilder
(options=None)[source]¶ Bases:
object
Object representation of a new Assembly to be created.
Attributes: - transloadit (<transloadit.client.Transloadit>):
- An instance of the Transloadit class.
- files (dict):
- storage of files to be uploaded. Each file is stored with a key corresponding to its field name when it is being uploaded.
Constructor Args: - options (Optional[dict]):
- params to send along with the assembly. Please see https://transloadit.com/docs/api-docs/#21-create-a-new-assembly for available options.
transloadit.request module¶
-
class
transloadit.request.
Request
(transloadit)[source]¶ Bases:
object
Transloadit tailored HTTP Request object.
Attributes: - transloadit (<translaodit.client.Transloadit>):
- An instance of the Transloadit class.
Constructor Args: - transloadit (<transloadit.client.Transloadit>)
-
HEADERS
= {'User-Agent': 'Transloadit Python SDK'}¶
-
delete
(path, data=None)[source]¶ Makes a HTTP DELETE request.
Args: - path (str): URL path to which the request should be made.
- data (Optional[dict]): The body of the request.
Return an instance of <transloadit.response.Response>
-
get
(path, params=None)[source]¶ Makes a HTTP GET request.
Args: - path (str): URL path to which the request should be made.
- params (Optional[dict]): Optional params to send along with the request.
Return an instance of <transloadit.response.Response>
-
post
(path, data=None, extra_data=None, files=None)[source]¶ Makes a HTTP POST request.
Args: - path (str): URL path to which the request should be made.
- data (Optional[dict]): The body of the request. This would be stored under the ‘params’ field.
- extra_data (Optional[dict]): This is also added to the body of the request but not under the
- ‘params’ field.
- files (Optional[dict]): Files to upload with the request. This should be a key, value pair of
- field name and file stream respectively.
Return an instance of <transloadit.response.Response>
transloadit.response module¶
-
class
transloadit.response.
Response
(response)[source]¶ Bases:
object
Transloadit http Response Object
Attributes: - data (dict):
- Dictionary representation of the returned JSON data.
- status_code (int):
- HTTP response status code
- headers (dict):
- Dictionary representation of the headers returned from the server.
Constructor Args: - response (<requests.Response>): The bare response object from the requests library.
-
headers
¶ Return the response headers.
-
status_code
¶ Return the http status code of the request.