go-sdk: github.com/transloadit/go-sdk Index | Files

package transloadit

import "github.com/transloadit/go-sdk"

Package transloadit provides a client to interact with the Transloadt API.

Index

Package Files

assembly.go notification.go template.go transloadit.go version.go wait.go

Variables

var DefaultConfig = Config{
    Endpoint: "https://api2.transloadit.com",
}

DefaultConfig is the recommended base configuration.

var Version = "v0.1.9"

Version specifies the version of the Go SDK.

type Assembly Uses

type Assembly struct {
    // NotifiyURL specifies a URL to which a request will be sent once the
    // assembly finishes.
    // See https://transloadit.com/docs#notifications.
    NotifyURL string
    // TemplateID specifies a optional template from which the encoding
    // instructions will be fetched.
    // See https://transloadit.com/docs/#15-templates
    TemplateID string
    // contains filtered or unexported fields
}

Assembly contains instructions used for starting assemblies.

func NewAssembly Uses

func NewAssembly() Assembly

NewAssembly will create a new Assembly struct which can be used to start an assembly using Client.StartAssembly.

func (*Assembly) AddFile Uses

func (assembly *Assembly) AddFile(fieldname, filepath string) error

AddFile will open the provided file path and add it to the list which will be uploaded once Client.StartAssembly is invoked. The corresponding field name can be used to reference the file in the assembly instructions.

func (*Assembly) AddReader Uses

func (assembly *Assembly) AddReader(fieldname, filename string, reader io.ReadCloser)

AddReader will add the provided io.Reader to the list which will be uploaded once Client.StartAssembly is invoked. The corresponding field name can be used to reference the file in the assembly instructions.

func (*Assembly) AddStep Uses

func (assembly *Assembly) AddStep(name string, details map[string]interface{})

AddStep will add the provided step to the assembly instructions. Details about possible values can be found at https://transloadit.com/docs/#14-assembly-instructions

type AssemblyInfo Uses

type AssemblyInfo struct {
    Ok      string `json:"ok"`
    Error   string `json:"error"`
    Message string `json:"message"`

    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"`
    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          []string               `json:"executing_jobs"`
    StartedJobs            []string               `json:"started_jobs"`
    ParentAssemblyStatus   *AssemblyInfo          `json:"parent_assembly_status"`
    Uploads                []*FileInfo            `json:"uploads"`
    Results                map[string][]*FileInfo `json:"results"`
    Params                 string                 `json:"params"`
}

AssemblyInfo contains details about an assemblies current status. Details about each value can be found at https://transloadit.com/docs/api-docs/#assembly-status-response

type AssemblyList Uses

type AssemblyList struct {
    Assemblies []*AssemblyListItem `json:"items"`
    Count      int                 `json:"count"`
}

AssemblyList contains a list of assemblies.

type AssemblyListItem Uses

type AssemblyListItem struct {
    Ok    string `json:"ok"`
    Error string `json:"error"`

    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"`
    Files             string     `json:"files"`
}

AssemblyListItem contains reduced details about an assembly.

type AssemblyReplay Uses

type AssemblyReplay struct {
    // NotifiyURL specifies a URL to which a request will be sent once the
    // assembly finishes. This overwrites the notify url from the original
    // assembly instructions.
    // See https://transloadit.com/docs#notifications.
    NotifyURL string
    // ReparseTemplate specifies whether the template should be fetched again
    // before the assembly is replayed. This can be used if the template has
    // changed since the original assembly was created.
    ReparseTemplate bool
    // contains filtered or unexported fields
}

AssemblyReplay contains instructions used for replaying assemblies.

func NewAssemblyReplay Uses

func NewAssemblyReplay(assemblyURL string) AssemblyReplay

NewAssemblyReplay will create a new AssemblyReplay struct which can be used to replay an assemblie's execution using Client.StartAssemblyReplay. The assembly URL must be absolute, for example: https://api2-amberly.transloadit.com/assemblies/15a6b3701d3811e78d7bfba4db1b053e

func (*AssemblyReplay) AddStep Uses

func (assembly *AssemblyReplay) AddStep(name string, details map[string]interface{})

AddStep will add the provided step to the new assembly instructions. When the assembly is replayed, those new steps will be used instead of the original ones. Details about possible values can be found at https://transloadit.com/docs/#14-assembly-instructions.

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client provides an interface to the Transloadit REST API bound to a specific account.

func NewClient Uses

func NewClient(config Config) Client

NewClient creates a new client using the provided configuration struct. It will panic if no Config.AuthKey or Config.AuthSecret are empty.

func (*Client) CancelAssembly Uses

func (client *Client) CancelAssembly(ctx context.Context, assemblyURL string) (*AssemblyInfo, error)

CancelAssembly cancels an assembly which will result in all corresponding uploads and encoding jobs to be aborted. Finally, the updated assembly information after the cancellation will be returned. The assembly URL must be absolute, for example: https://api2-amberly.transloadit.com/assemblies/15a6b3701d3811e78d7bfba4db1b053e

func (*Client) CreateTemplate Uses

func (client *Client) CreateTemplate(ctx context.Context, template Template) (string, error)

CreateTemplate will save the provided template struct as a new template and return the ID of the new template.

func (*Client) DeleteTemplate Uses

func (client *Client) DeleteTemplate(ctx context.Context, templateID string) error

DeleteTemplate will delete the template associated with the provided template ID.

func (*Client) GetAssembly Uses

func (client *Client) GetAssembly(ctx context.Context, assemblyURL string) (*AssemblyInfo, error)

GetAssembly fetches the full assembly status from the provided URL. The assembly URL must be absolute, for example: https://api2-amberly.transloadit.com/assemblies/15a6b3701d3811e78d7bfba4db1b053e

func (*Client) GetTemplate Uses

func (client *Client) GetTemplate(ctx context.Context, templateID string) (template Template, err error)

GetTemplate will retrieve details about the template associated with the provided template ID.

func (*Client) ListAssemblies Uses

func (client *Client) ListAssemblies(ctx context.Context, options *ListOptions) (AssemblyList, error)

ListAssemblies will fetch all assemblies matching the provided criteria.

func (*Client) ListNotifications Uses

func (client *Client) ListNotifications(ctx context.Context, options *ListOptions) (list NotificationList, err error)

ListNotifications will return a list containing all notifications matching the criteria defined using the ListOptions structure.

func (*Client) ListTemplates Uses

func (client *Client) ListTemplates(ctx context.Context, options *ListOptions) (list TemplateList, err error)

ListTemplates will retrieve all templates matching the criteria.

func (*Client) ReplayNotification Uses

func (client *Client) ReplayNotification(ctx context.Context, assemblyID string, notifyURL string) error

ReplayNotification instructs the endpoint to replay the notification corresponding to the provided assembly ID. If notifyURL is not empty it will override the notify URL used in the assembly instructions.

func (*Client) StartAssembly Uses

func (client *Client) StartAssembly(ctx context.Context, assembly Assembly) (*AssemblyInfo, error)

StartAssembly will upload all provided files and instruct the endpoint to start executing it. The function will return after all uploads complete and the remote server received the instructions (or the provided context times out). It won't wait until the execution has finished and results are available, which can be achieved using WaitForAssembly.

When an error is returned you should also check AssemblyInfo.Error for more information about the error sent by the Transloadit API:

info, err := assembly.Upload()
if err != nil {
	if info != nil && info.Error != "" {
		// See info.Error
	}
	panic(err)
}

func (*Client) StartAssemblyReplay Uses

func (client *Client) StartAssemblyReplay(ctx context.Context, assembly AssemblyReplay) (*AssemblyInfo, error)

StartAssemblyReplay will instruct the endpoint to replay the entire assembly execution.

func (*Client) UpdateTemplate Uses

func (client *Client) UpdateTemplate(ctx context.Context, templateID string, newTemplate Template) error

UpdateTemplate will update the template associated with the provided template ID to match the new name and new content. Please be aware that you are not able to change a template's ID.

func (*Client) WaitForAssembly Uses

func (client *Client) WaitForAssembly(ctx context.Context, assembly *AssemblyInfo) (*AssemblyInfo, error)

WaitForAssembly fetches continuously the assembly status until is either completed (ASSEMBLY_COMPLETED), canceled (ASSEMBLY_CANCELED) or aborted (REQUEST_ABORTED). If you want to end this loop prematurely, you can cancel the supplied context.

type Config Uses

type Config struct {
    AuthKey    string
    AuthSecret string
    Endpoint   string
}

Config defines the configuration options for a client.

type FileInfo Uses

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"`
}

FileInfo contains details about a file which was either uploaded or is the result of an executed assembly.

type ListOptions Uses

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"`
}

ListOptions defines criteria used when a list is being retrieved. Details about each property can be found at https://transloadit.com/docs/api-docs#retrieve-assembly-list.

type Notification Uses

type Notification struct {
    ID           string    `json:"id"`
    AssemblyID   string    `json:"assembly_id"`
    AccountID    string    `json:"account_id"`
    URL          string    `json:"url"`
    ResponseCode int       `json:"response_code"`
    ResponseData string    `json:"response_data"`
    Duration     float32   `json:"duration"`
    Created      time.Time `json:"created"`
    Error        string    `json:"error"`
}

Notification contains details about a notification.

type NotificationList Uses

type NotificationList struct {
    Notifications []Notification `json:"items"`
    Count         int            `json:"count"`
}

NotificationList contains a list of notifications.

type RequestError Uses

type RequestError struct {
    Code    string `json:"error"`
    Message string `json:"message"`
}

RequestError represents an error returned by the Transloadit API alongside additional service-specific information.

func (RequestError) Error Uses

func (err RequestError) Error() string

Error return a formatted message describing the error.

type Template Uses

type Template struct {
    ID      string          `json:"id"`
    Name    string          `json:"name"`
    Content TemplateContent `json:"content"`
}

Template contains details about a single template.

func NewTemplate Uses

func NewTemplate() Template

NewTemplate returns a new Template struct with initialized values. This template will not be saved to Transloadit. To do so, please use the Client.CreateTemplate function.

func (*Template) AddStep Uses

func (template *Template) AddStep(name string, step map[string]interface{})

AddStep will add the provided step to the Template.Content.Steps map.

type TemplateContent Uses

type TemplateContent struct {
    Steps map[string]interface{} `json:"steps"`
}

TemplateContent contains details about the content of a single template.

type TemplateList Uses

type TemplateList struct {
    Templates []Template `json:"items"`
    Count     int        `json:"count"`
}

TemplateList contains a list of templates.

Package transloadit imports 13 packages (graph) and is imported by 1 packages. Updated 2017-07-08. Refresh now. Tools for package owners.