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:

Return an instance of <transloadit.response.Response>

list_templates(params=None)[source]

Get the list of templates.

Args:

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.

new_template(name, params=None)[source]

Return an instance of <transloadit.template.Template> which would be used to create a new template.

Args:
  • name (str): Name of the template.
update_template(template_id, data)[source]

Update the template specified by the ‘template_id’.

Args:
  • template_id (str)
  • data (dict): key, value pair of fields and their new values.

Return an instance of <transloadit.response.Response>

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:
 
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.
remove_file(field_name)[source]

Remove the file with the specified field name from the set of files to be submitted.

Args:
  • field_name (str): The field name assigned to the file when it was added.

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:
 
create()[source]

Save/Submit the template to the Transloadit server.

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:
 
add_step(name, robot, options)[source]

Add a step to the Assembly/Template

Args:
  • name (str): The name of the step.
  • robot (str): The name of the robot for the step
  • options (dict): The options to apply to the step
get_options()[source]

Return the Assembly/Template options in Transloadit, ready format.

remove_step(name)[source]

Remove the step specified by the given name.abs

Args:
  • name (str): The name of the step to remove.

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>

put(path, data=None)[source]

Makes a HTTP PUT 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>

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.

transloadit.response.as_response(func)[source]

Decorator function that converts the output of a function into an instance of the <transloadit.response.Response> class.