Documentation ¶
Index ¶
- Variables
- type Assembly
- type AssemblyInfo
- type AssemblyList
- type AssemblyListItem
- type AssemblyReplay
- type AssemblyWatcher
- type Client
- func (client *Client) CancelAssembly(assemblyUrl string) (Response, error)
- func (client *Client) CreateAssembly() *Assembly
- func (client *Client) CreateTemplate(template *Template) (string, error)
- func (client *Client) DeleteTemplate(templateId string) error
- func (client *Client) EditTemplate(templateId string, newTemplate *Template) error
- func (client *Client) GetAssembly(assemblyUrl string) (*AssemblyInfo, error)
- func (client *Client) GetTemplate(templateId string) (*Template, error)
- func (client *Client) ListAssemblies(options *ListOptions) (*AssemblyList, error)
- func (client *Client) ListNotifications(options *ListOptions) (*NotificationList, error)
- func (client *Client) ListTemplates(options *ListOptions) (*TemplateList, error)
- func (client *Client) ReplayAssembly(assemblyId string) *AssemblyReplay
- func (client *Client) ReplayNotification(assemblyId string, notifyUrl string) (Response, error)
- func (client *Client) WaitForAssembly(assemblyUrl string) *AssemblyWatcher
- func (client *Client) Watch(options *WatchOptions) *Watcher
- type Config
- type FileInfo
- type ListOptions
- type NotificationList
- type NotificationListItem
- type Response
- type Template
- type TemplateList
- type TemplateListItem
- type WatchOptions
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{
Region: "us-east-1",
Endpoint: "http://api2.transloadit.com",
}
var Version = "v0.1.9"
Go SDK's version
Functions ¶
This section is empty.
Types ¶
type Assembly ¶
type Assembly struct { // Notify url to send a request to once the assembly finishes. // See https://transloadit.com/docs#notifications. NotifyUrl string // Optional template id to use instead of adding steps. TemplateId string // Wait until the assembly completes (or is canceled). Blocking bool // contains filtered or unexported fields }
func (*Assembly) AddReader ¶
func (assembly *Assembly) AddReader(field, name string, reader io.ReadCloser)
Add another reader to upload later.
func (*Assembly) Upload ¶
func (assembly *Assembly) Upload() (*AssemblyInfo, error)
Start the assembly and upload all files. When an error is returned you should also check AssemblyInfo.Error for more information about the error. This happens when there is an error returned by the Transloadit API:
info, err := assembly.Upload() if err != nil { if info != nil && info.Error != "" { // See info.Error } panic(err) }
type AssemblyInfo ¶
type AssemblyInfo struct { AssemblyId string `json:"assembly_id"` ParentId string `json:"parent_id"` AssemblyUrl string `json:"assembly_url"` AssemblySslUrl string `json:"assembly_ssl_url"` BytesReceived int `json:"bytes_received"` BytesExpected int `json:"bytes_expected"` ClientAgent string `json:"client_agent"` ClientIp string `json:"client_ip"` ClientReferer string `json:"client_referer"` StartDate string `json:"start_date"` IsInfinite bool `json:"is_infinite"` HasDupeJobs bool `json:"has_dupe_jobs"` UploadDuration float32 `json:"upload_duration"` NotifyUrl string `json:"notify_url"` NotifyStart string `json:"notify_start"` NotifyStatus string `json:"notify_status"` NotifyDuation float32 `json:"notify_duration"` LastJobCompleted string `json:"last_job_completed"` ExecutionDuration float32 `json:"execution_duration"` ExecutionStart string `json:"execution_start"` Created string `json:"created"` Ok string `json:"ok"` Message string `json:"message"` Files string `json:"files"` Fields map[string]interface{} `json:"fields"` BytesUsage int `json:"bytes_usage"` FilesToStoreOnS3 int `json:"files_to_store_on_s3"` QueuedFilesToStoreOnS3 int `json:"queued_files_to_store_on_s3"` ExecutingJobs []interface{} `json:"executing_jobs"` StartedJobs []interface{} `json:"started_jobs"` ParentAssemblyStatus *AssemblyInfo `json:"parent_assembly_status"` Uploads []*FileInfo `json:"uploads"` Results map[string][]*FileInfo `json:"results"` Params string `json:"params"` Error string `json:"error"` }
type AssemblyList ¶
type AssemblyList struct { Assemblies []*AssemblyListItem `json:"items"` Count int `json:"count"` }
type AssemblyListItem ¶
type AssemblyListItem struct { AssemblyId string `json:"id"` AccountId string `json:"account_id"` TemplateId string `json:"template_id"` Instance string `json:"instance"` NotifyUrl string `json:"notify_url"` RedirectUrl string `json:"redirect_url"` ExecutionDuration float32 `json:"execution_duration"` ExecutionStart time.Time `json:"execution_start"` Created time.Time `json:"created"` Ok string `json:"ok"` Error string `json:"error"` Files string `json:"files"` }
type AssemblyReplay ¶
type AssemblyReplay struct { // Notify url to send a request to once the assembly finishes. // See https://transloadit.com/docs#notifications. NotifyUrl string // Wait until the assembly completes (or is canceled). Blocking bool // contains filtered or unexported fields }
func (*AssemblyReplay) AddStep ¶
func (assembly *AssemblyReplay) AddStep(name string, details map[string]interface{})
Add a step to override the original ones.
func (*AssemblyReplay) ReparseTemplate ¶
func (assembly *AssemblyReplay) ReparseTemplate()
Reparse the template when replaying. Useful if the template has changed since the orignal assembly was created.
func (*AssemblyReplay) Start ¶
func (assembly *AssemblyReplay) Start() (*AssemblyInfo, error)
Start the assembly replay.
type AssemblyWatcher ¶
type AssemblyWatcher struct { Response chan *AssemblyInfo Error chan error // contains filtered or unexported fields }
func (*AssemblyWatcher) Stop ¶
func (watcher *AssemblyWatcher) Stop()
Stop the watcher and close all channels.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
Create a new client using the provided configuration object. An error will be returned if no AuthKey or AuthSecret is found in config.
func (*Client) CancelAssembly ¶
Cancel an assembly using its url.
func (*Client) CreateAssembly ¶
Create a new assembly instance which can be executed later.
func (*Client) CreateTemplate ¶
Save the template.
func (*Client) DeleteTemplate ¶
Delete a template from the list.
func (*Client) EditTemplate ¶
Update the name and content of the template defined using the id.
func (*Client) GetAssembly ¶
func (client *Client) GetAssembly(assemblyUrl string) (*AssemblyInfo, error)
Get information about an assembly using its url.
func (*Client) GetTemplate ¶
Get information about a template using its id.
func (*Client) ListAssemblies ¶
func (client *Client) ListAssemblies(options *ListOptions) (*AssemblyList, error)
List all assemblies matching the criterias.
func (*Client) ListNotifications ¶
func (client *Client) ListNotifications(options *ListOptions) (*NotificationList, error)
List all notificaions matching the criterias.
func (*Client) ListTemplates ¶
func (client *Client) ListTemplates(options *ListOptions) (*TemplateList, error)
List all templates matching the criterias.
func (*Client) ReplayAssembly ¶
func (client *Client) ReplayAssembly(assemblyId string) *AssemblyReplay
Create a new AssemblyReplay instance.
func (*Client) ReplayNotification ¶
Replay a notification which was trigger by assembly defined using the assemblyId. If notifyUrl is not empty it will override the original notify url.
func (*Client) WaitForAssembly ¶
func (client *Client) WaitForAssembly(assemblyUrl string) *AssemblyWatcher
Wait until the status of an assembly is either completed, canceled or aborted.
func (*Client) Watch ¶
func (client *Client) Watch(options *WatchOptions) *Watcher
Watch a directory for changes and convert all changes files and download the result. It will create a new assembly for each file. If the directory already contains some they are all converted. See WatchOptions for possible configuration.
type FileInfo ¶
type FileInfo struct { Id string `json:"id"` Name string `json:"name"` Basename string `json:"basename"` Ext string `json:"ext"` Size int `json:"size"` Mime string `json:"mime"` Type string `json:"type"` Field string `json:"field"` Md5Hash string `json:"md5hash"` OriginalMd5Hash string `json:"original_md5hash"` OriginalId string `json:"original_id"` OriginalBasename string `json:"original_basename"` Url string `json:"url"` SslUrl string `json:"ssl_url"` Meta map[string]interface{} `json:"meta"` }
type ListOptions ¶
type ListOptions struct { Page int `json:"page,omitempty"` PageSize int `json:"pagesize,omitempty"` Sort string `json:"sort,omitempty"` Order string `json:"order,omitempty"` Fields []string `json:"fields,omitempty"` Type string `json:"type,omitempty"` Keywords []string `json:"keyword,omitempty"` AssemblyId string `json:"assembly_id,omitempty"` FromDate *time.Time `json:"fromdate,omitempty"` ToDate *time.Time `json:"todate,omitempty"` // For internal use only! Auth struct { Key string `json:"key"` Expires string `json:"expires"` } `json:"auth"` }
Options when retrieving a list. Look at the documentation which properties are accepted and to see their meaining, e.g. https://transloadit.com/docs/api-docs#retrieve-assembly-list for listing assemblies.
type NotificationList ¶
type NotificationList struct { Notifications []*NotificationListItem `json:"items"` Count int `json:"count"` }
type NotificationListItem ¶
type NotificationListItem struct { Id string `json:"id"` AssemblyId string `json:"assembly_id"` AccountId string `json:"account_id"` Url string `json:"url"` ResponseCode int `json:"response_code"` RespandeData string `json:"response_data"` Duration float32 `json:"duration"` Created time.Time `json:"created"` Error string `json:"error"` }
type Template ¶
type Template struct { Name string `json:"name"` // See AddStep for simple usage. Steps map[string]map[string]interface{} `json:"content"` }
func NewTemplate ¶
Creates a new template instance which can be saved to transloadit.
type TemplateList ¶
type TemplateList struct { Templates []TemplateListItem `json:"items"` Count int `json:"count"` }
type TemplateListItem ¶
type WatchOptions ¶
type WatchOptions struct { // Directory to watch files in (only if Watch is true) Input string // Directoy to put result files in Output string // Watch the input directory or just compile files in input directory Watch bool // Template id to convert files with TemplateId string // Optional notify url for each assembly. NotifyUrl string // Instead of using templates you can define steps Steps map[string]map[string]interface{} // If true the original files will be copied in the output directoy with `-original_0_` prefix. // If false input files will be deleted. Preserve bool // Read template from JSON file. See exmaples for information about the format. TemplateFile string // If true file which are already in the directory won't be compiled. DontProcessDir bool }
type Watcher ¶
type Watcher struct { // Original options passed to Client.Watch. // If Input or Output are relative to the home directory // they will be extended (~/input -> /home/user/input) Options *WatchOptions // Listen for errors Error chan error // Listen for completed assemblies Done chan *AssemblyInfo // Listen for file changes (only if Watch == true) Change chan string // contains filtered or unexported fields }