synq

package
v0.0.0-...-07cd16e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2019 License: MIT Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DEFAULT_V2_URL       = "https://b9n2fsyd6jbfihx82.stoplight-proxy.io"
	DEFAULT_UPLOADER_URL = "https://s6krcbatzuuhmspse.stoplight-proxy.io"
	DEFAULT_PAGE_SIZE    = 100
	SYNQ_VERSION         = "v2"
	SYNQ_ROUTE           = "v1"
)
View Source
const (
	DEFAULT_TIMEOUT_MS = 5000   // 5 seconds
	DEFAULT_UPLOAD_MS  = 600000 // 5 minutes
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Id              string           `json:"id"`
	Name            string           `json:"name"`
	Type            string           `json:"type"`
	Status          string           `json:"status"`
	Domain          string           `json:"domain"`
	Contact         string           `json:"contact_person"`
	CreatedAt       string           `json:"created_at"`
	UpdatedAt       string           `json:"updated_at"`
	PartneredOn     string           `json:"partnered_on"`
	AccountSettings []AccountSetting `json:"account_settings"`
	Distributors    []Distributor    `json:"distributor_accounts"`
}

type AccountResp

type AccountResp struct {
	Account Account `json:"data"`
}

type AccountSetting

type AccountSetting struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type ApiF

type ApiF interface {
	Version() string
	GetKey() string
	GetUrl() string
	GetTimeout(string) time.Duration
	SetTimeout(string, time.Duration)
	ParseError(int, []byte) error
	SetUrl(string)
	SetKey(string)
}

type ApiV2

type ApiV2 struct {
	*BaseApi
	User        string
	Password    string
	UploadUrl   string
	TokenExpiry time.Time
	PageSize    int
}

func Login

func Login(user, password string, serverUrl ...string) (ApiV2, error)

func NewV2

func NewV2(token string, timeouts ...time.Duration) ApiV2

func (*ApiV2) Create

func (a *ApiV2) Create(body ...[]byte) (VideoV2, error)

func (*ApiV2) CreateAccount

func (a *ApiV2) CreateAccount(name string, type_ string) string

func (*ApiV2) CreateAssetSettings

func (a *ApiV2) CreateAssetSettings(assetId string, settingIds []string) error

func (*ApiV2) GetAccount

func (a *ApiV2) GetAccount(id string) (account Account, err error)

func (*ApiV2) GetAsset

func (a *ApiV2) GetAsset(id string) (asset Asset, err error)

Helper function to get an Asset

func (*ApiV2) GetAssetList

func (a *ApiV2) GetAssetList() ([]Asset, error)

func (*ApiV2) GetRawVideos

func (a *ApiV2) GetRawVideos(accountId string) ([]json.RawMessage, error)

func (*ApiV2) GetSettingsByName

func (a *ApiV2) GetSettingsByName(settingsName string) (settings Settings, err error)

func (*ApiV2) GetUploadParams

func (a *ApiV2) GetUploadParams(vid string, params upload.UploadRequest) (up upload.UploadParameters, err error)

func (*ApiV2) GetVideo

func (a *ApiV2) GetVideo(id string) (video VideoV2, err error)

Helper function to get details for a video, will create video object

func (*ApiV2) GetVideos

func (a *ApiV2) GetVideos(accountId string) ([]VideoV2, error)

func (ApiV2) ParseError

func (a ApiV2) ParseError(status int, bytes []byte) error

func (*ApiV2) SetApi

func (a *ApiV2) SetApi(video *VideoV2)

this sets the api object properly on the Video object and the assets

func (*ApiV2) UpdateAssetMetadata

func (a *ApiV2) UpdateAssetMetadata(id string, metadata json.RawMessage) (asset Asset, err error)

func (ApiV2) Version

func (a ApiV2) Version() string

type Asset

type Asset struct {
	AccountId        string                  `json:"account_id"`
	VideoId          string                  `json:"video_id"`
	Id               string                  `json:"id"`
	Location         string                  `json:"location"`
	Url              string                  `json:"url"`
	State            string                  `json:"state"`
	Type             string                  `json:"type"`
	CreatedAt        string                  `json:"created_at"`
	UpdatedAt        string                  `json:"updated_at"`
	Metadata         json.RawMessage         `json:"metadata"`
	VmafScore        float64                 `json:"vmaf_score"`
	UploadInfo       AssetUpload             `json:"upload_info,omitempty"`
	Api              ApiV2                   `json:"-"`
	Video            VideoV2                 `json:"-"`
	UploadParameters upload.UploadParameters `json:"-"`
}

func (*Asset) Delete

func (a *Asset) Delete() error

func (*Asset) GetUrl

func (a *Asset) GetUrl() string

func (*Asset) Update

func (a *Asset) Update() error

func (*Asset) UploadFile

func (a *Asset) UploadFile(fileName string) error

type AssetList

type AssetList struct {
	Assets []Asset `json:"data"`
}

type AssetResponse

type AssetResponse struct {
	Asset *Asset `json:"data"`
}

type AssetUpload

type AssetUpload struct {
	Checksum     string     `json:"checksum,omitempty"`
	ChecksumSize int64      `json:"checksum_size,omitempty"`
	Size         int64      `json:"size,omitempty"`
	Started      *time.Time `json:"started,omitempty"`
	Finished     *time.Time `json:"finished,omitempty"`
	Filename     string     `json:"filename,omitempty"`
}

type AwsError

type AwsError struct {
	Code      string
	Message   string
	Condition string
	RequestId string
	HostId    string
}

type BaseApi

type BaseApi struct {
	Key           string
	Url           string
	Timeout       time.Duration
	UploadTimeout time.Duration
	Version       string
}

func NewBase

func NewBase(key string, timeouts ...time.Duration) BaseApi

func (*BaseApi) GetKey

func (b *BaseApi) GetKey() string

func (*BaseApi) GetTimeout

func (b *BaseApi) GetTimeout(type_ string) time.Duration

func (*BaseApi) GetUrl

func (b *BaseApi) GetUrl() string

func (*BaseApi) SetKey

func (b *BaseApi) SetKey(key string)

func (*BaseApi) SetTimeout

func (b *BaseApi) SetTimeout(type_ string, dur time.Duration)

func (*BaseApi) SetUrl

func (b *BaseApi) SetUrl(url string)

type Distributor

type Distributor struct {
	DistributorId string `json:"distributor_id"`
}

type ErrorRespV2

type ErrorRespV2 struct {
	Message string `json:"message"`
}

type LoginResp

type LoginResp struct {
	Token       string    `json:"jwt"`
	TokenExpiry time.Time `json:"exp"`
}

type Settings

type Settings struct {
	Id        string `json:"id"`
	Name      string `json:"name"`
	Type      string `json:"type"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type SettingsResp

type SettingsResp struct {
	Settings Settings `json:"data"`
}

type VideoAccount

type VideoAccount struct {
	Id string `json:"account_id"`
}

type VideoList

type VideoList struct {
	Videos     []json.RawMessage `json:"data"`
	PageSize   int               `json:"page_size"`
	PageNumber int               `json:"page_number"`
}

type VideoResp

type VideoResp struct {
	Video VideoV2 `json:"data"`
}

type VideoV2

type VideoV2 struct {
	Id                string          `json:"id"`
	Userdata          json.RawMessage `json:"user_data"`
	Metadata          json.RawMessage `json:"metadata"`
	CreatedAt         time.Time       `json:"created_at"`
	UpdatedAt         time.Time       `json:"updated_at"`
	Api               *ApiV2          `json:"-"`
	Assets            []Asset         `json:"assets"`
	AccountIds        []string        `json:"account_ids"`
	CompletenessScore float64         `json:"completeness_score"`
}

func (*VideoV2) AddAccount

func (v *VideoV2) AddAccount(accountId string) error

func (*VideoV2) CreateAsset

func (v *VideoV2) CreateAsset(state, fileType, location string) (Asset, error)

func (*VideoV2) CreateAssetForUpload

func (v *VideoV2) CreateAssetForUpload(req upload.UploadRequest) (asset Asset, err error)

This will call Unicorn's /v2/video/<id>/upload API, which will create an asset and create a signed S3 location to upload to, including the signature url for multipart uploads

func (*VideoV2) CreateOrUpdateAsset

func (v *VideoV2) CreateOrUpdateAsset(asset *Asset) error

func (*VideoV2) Display

func (v *VideoV2) Display() (str string)

Helper function to display information about a file

func (*VideoV2) FindAsset

func (v *VideoV2) FindAsset(location string) (Asset, bool)

func (*VideoV2) FindAssetByType

func (v *VideoV2) FindAssetByType(assetType string) ([]Asset, bool)

func (VideoV2) GetAsset

func (v VideoV2) GetAsset(assetId string) (Asset, error)

func (*VideoV2) GetBaseUrl

func (v *VideoV2) GetBaseUrl() string

func (*VideoV2) GetUploadParams

func (v *VideoV2) GetUploadParams(req upload.UploadRequest) (up upload.UploadParameters, err error)

This will get the upload params for a sepcific video, if assetId is passed in it will be used instead (assuming it exists)

func (*VideoV2) GetVideoAssetList

func (v *VideoV2) GetVideoAssetList() error

func (*VideoV2) Scan

func (v *VideoV2) Scan(src interface{}) error

func (*VideoV2) Update

func (v *VideoV2) Update() error

func (VideoV2) Value

func (v VideoV2) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL