filespot

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 17 Imported by: 0

README

Filespot

Filespot is a Go client library for accessing the platformcraft.ru API.

platformcraft.ru API docs: https://doc.platformcraft.ru/filespot/api/

###TODO

  • pagination
  • query params

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(resp *http.Response) error

CheckResponse checks response for errors

func DoClientRequest

func DoClientRequest(ctx context.Context, c *Client, req *http.Request) (*http.Response, error)

DoClientRequest submits request

Types

type Client

type Client struct {
	UserAgent string
	BaseURL   *url.URL

	// Authentication
	APIUserID  string
	APIUserKey string

	// Services provides communication with API endpoints
	Objects         ObjectsService
	Temp            TempService
	Streams         StreamsService
	Players         PlayersService
	Download        DownloadService
	DownloadTasks   DownloadTasksService
	Transcoder      TranscoderService
	TranscoderTasks TranscoderTasksService
	Storage         StorageService
	// contains filtered or unexported fields
}

Client manages communication with platformcraft API

func NewClient

func NewClient(apiUserID, apiUserKey string) *Client

NewClient returns client API

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, data interface{}) (*http.Response, error)

Do sends request and returns API response

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, endpointURL string, body interface{}) (*http.Request, error)

NewRequest creates a API request with HTTP method, endpoint path and payload

type Download

type Download struct {
	Message     string `json:"message"`
	ActiveTasks int    `json:"active_tasks"`
	TaskID      string `json:"task_id"`
}

Download represents a platformcraft Download

type DownloadCli

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

DownloadCli handles communication with API

func (DownloadCli) Create

func (c DownloadCli) Create(ctx context.Context, params interface{}) (*Download, *http.Response, error)

Create Download

type DownloadCreateParams

type DownloadCreateParams struct {
	URL          string `url:"url,omitempty"`
	Path         string `url:"path,omitempty"`
	Name         string `url:"name,omitempty"`
	Autoencoding bool   `url:"autoencoding,omitempty"`
	Presets      string `url:"presets,omitempty"`
	DelOriginal  bool   `url:"del_original,omitempty"`
	Autoplayer   bool   `url:"autoplayer,omitempty"`
}

DownloadCreateParams identifies as query params of Create request

type DownloadService

type DownloadService interface {
	Create(context.Context, interface{}) (*Download, *http.Response, error)
}

DownloadService implements interface with API /download endpoint. See https://doc.platformcraft.ru/filespot/api/en/#download

type DownloadTasksCli

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

DownloadTasksCli handles communication with API

func (DownloadTasksCli) Delete

func (c DownloadTasksCli) Delete(ctx context.Context, id string) (*http.Response, error)

Delete Task

func (DownloadTasksCli) Get

Get Task

func (DownloadTasksCli) List

func (c DownloadTasksCli) List(ctx context.Context) ([]Task, *http.Response, error)

List of Tasks

type DownloadTasksService

type DownloadTasksService interface {
	List(context.Context) ([]Task, *http.Response, error)
	Get(context.Context, string) (*Task, *http.Response, error)
	Delete(context.Context, string) (*http.Response, error)
}

DownloadTasksService implements interface with API /download_tasks endpoint. See https://doc.platformcraft.ru/filespot/api/en/#download_tasks

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Code     uint32 `json:"code"`
	Status   string `json:"status"`
	MsgUser  string `json:"msg_user"`
	MsgDev   string `json:"msg_dev"`
	Doc      string `json:"doc"`
	Advanced string `json:"advanced"`
}

ErrorResponse handles API errors

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error returns formated error

type File

type File struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Path         string `json:"path"`
	Size         int    `json:"size"`
	ContentType  string `json:"content_type"`
	CreateDate   string `json:"create_date"`
	LatestUpdate string `json:"latest_update"`
	ResourceURL  string `json:"resource_url"`
	Video        string `json:"video"`
	CDNURL       string `json:"cdn_url"`
	Status       string `json:"status"`
}

File represents a platformcraft Record File

type Geo

type Geo map[string]map[string]bool

Geo represents platformcraft `geo` type It's a map of `map[continent]map[country]true` Keys `continent` and `country` are ISO codes of continents and counties (e.g, EU и RU). All keys MUST be capitalized. When `country` was set to "ALL" it grants access to whole world. For example:

grants acccess to Europe and North America
  &Geo{
      "EU": {
          "ALL": true,
      },
      "NA": {
          "ALL": true,
      },
  }
grants access only to Russia
  &Geo{
      "EU": {
          "RU": true,
      },
  }
type Link struct {
	ID       string `json:"id"`
	ObjectID string `json:"object_id"`
	Href     string `json:"href"`
	Secure   bool   `json:"secure"`
	Exp      int    `json:"exp"`
	ForSale  bool   `json:"for_sale"`
	Geo      Geo    `json:"geo"`
}

Link represents a platformcraft temporary Link

type LinkCreateRequest

type LinkCreateRequest struct {
	ObjectID string `json:"object_id"`
	Endless  bool   `json:"endless"`
	Exp      int    `json:"exp"`
	Secure   bool   `json:"secure"`
	Geo      Geo    `json:"geo"`
}

LinkCreateRequest identifies Link for the Create request

type Object

type Object struct {
	ID           string          `json:"id"`
	Name         string          `json:"name"`
	Path         string          `json:"path"`
	IsDir        bool            `json:"is_dir"`
	Size         uint32          `json:"size"`
	ContentType  string          `json:"content_type"`
	CreateDate   string          `json:"create_date"`
	LatestUpdate string          `json:"latest_update"`
	ResourceURL  string          `json:"resource_url"`
	CDNURL       string          `json:"cdn_url"`
	VODHLS       string          `json:"vod_hls"`
	Video        string          `json:"video"`
	Private      bool            `json:"private"`
	Status       string          `json:"status"`
	Advanced     *ObjectAdvanced `json:"advanced"`
	Previews     []string        `json:"previews"`
	Description  string          `json:"description"`
}

Object represents a platformcraft Object

type ObjectAdvanced

type ObjectAdvanced struct {
	AudioStreams []ObjectAudioStream `json:"audio_streams"`
	Format       *ObjectFormat       `json:"format"`
	VideoStreams []ObjectVideoStream `json:"video_streams"`
}

ObjectAdvanced of Object

type ObjectAudioStream

type ObjectAudioStream struct {
	BitRate       uint32  `json:"bit_rate"`
	ChannelLayout string  `json:"channel_layout"`
	Channels      uint32  `json:"channels"`
	CodecLongName string  `json:"codec_long_name"`
	CodecType     string  `json:"codec_type"`
	Duration      float32 `json:"duration"`
	Index         uint32  `json:"index"`
	SampleRate    uint32  `json:"sample_rate"`
}

ObjectAudioStream of Object

type ObjectCreateRequest

type ObjectCreateRequest struct {
	File         string `url:"file"`
	Name         string `url:"name,omitempty"`
	Private      bool   `url:"private,omitempty"`
	Autoencoding bool   `url:"autoencoding,omitempty"`
	Presets      string `url:"presets,omitempty"`
	DelOriginal  bool   `url:"del_original,omitempty"`
	Autoplayer   bool   `url:"autoplayer,omitempty"`
}

ObjectCreateRequest identifies Object for the Create request

func (ObjectCreateRequest) Multipart

func (o ObjectCreateRequest) Multipart() (*bytes.Buffer, string, error)

Multipart represents Object as multipart data

type ObjectFormat

type ObjectFormat struct {
	BitRate        uint32  `json:"bit_rate"`
	Duration       float32 `json:"duration"`
	FormatLongName string  `json:"format_long_name"`
	FormatName     string  `json:"format_name"`
	NBStreams      uint32  `json:"nb_streams"`
}

ObjectFormat of Object

type ObjectUpdateRequest

type ObjectUpdateRequest struct {
	Name        string `json:"name"`
	Folder      string `json:"folder"`
	Description string `json:"description"`
	MaxHeight   int    `json:"max_height"`
	MaxWidth    int    `json:"max_width"`
	Private     bool   `json:"private"`
}

ObjectUpdateRequest identifies Object for the Update request

type ObjectVideoStream

type ObjectVideoStream struct {
	BitRate            uint32  `json:"bit_rate"`
	CodecName          string  `json:"codec_name"`
	CodecType          string  `json:"codec_type"`
	CodecLongName      string  `json:"codeclongname"`
	DisplayAspectRatio string  `json:"display_aspect_ratio"`
	Duration           float32 `json:"duration"`
	FPS                float32 `json:"fps"`
	Height             uint32  `json:"height"`
	Index              uint32  `json:"index"`
	Width              uint32  `json:"width"`
}

ObjectVideoStream of Object

type ObjectsCli

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

ObjectsCli handles communication with API

func (ObjectsCli) Create

func (c ObjectsCli) Create(ctx context.Context, objectCreateRequest *ObjectCreateRequest) (*Object, *http.Response, error)

Create Object

func (ObjectsCli) Delete

func (c ObjectsCli) Delete(ctx context.Context, id string) (*http.Response, error)

Delete Object

func (ObjectsCli) Get

func (c ObjectsCli) Get(ctx context.Context, id string) (*Object, *http.Response, error)

Get Object

func (ObjectsCli) List

func (c ObjectsCli) List(ctx context.Context, params interface{}) ([]Object, *http.Response, error)

List returns list of all objects (files) in container

func (ObjectsCli) Update

func (c ObjectsCli) Update(ctx context.Context, id string, objectUpdateRequest *ObjectUpdateRequest) (*http.Response, error)

Update Object

type ObjectsListParams

type ObjectsListParams struct {
	// Filters
	Folder      string `url:"folder,omitempty"`
	Name        string `url:"name,omitempty"`
	Ext         string `url:"ext,omitempty"`
	Private     bool   `url:"private,omitempty"`
	ShowFolders bool   `url:"show_folders,omitempty"`

	// Pagination
	Limit    int `url:"limit,omitempty"`
	Start    int `url:"start,omitempty"`
	Pagingts int `url:"pagingts,omitempty"`
}

ObjectsListParams identifies as query params of List request

type ObjectsService

ObjectsService implements interface with API /objects endpoint. See https://doc.platformcraft.ru/filespot/api/en/#objects

type Paging

type Paging struct {
	Next string `json:"next"`
	Prev string `json:"prev"`
}

Paging represents pagination

type Player

type Player struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Path          string `json:"path"`
	IsDir         bool   `json:"is_dir"`
	Videos        videos `json:"videos"`
	ScreenShotURL string `json:"screen_shot_url"`
	VastAdTagURL  string `json:"vast_ad_tag_url"`
	CreateDate    string `json:"create_date"`
	Href          string `json:"href"`
	FrameTag      string `json:"frame_tag"`
	Description   string `json:"description"`
	Tags          tags   `json:"tags"`
	Geo           Geo    `json:"geo"`
}

Player represents a platformcraft Player

type PlayerCreateRequest

type PlayerCreateRequest struct {
	Name         string `json:"name"`
	Folder       string `json:"folder"`
	Videos       videos `json:"videos"`
	ScreenShotID string `json:"screen_shot_id"`
	VastAdTagURL string `json:"vast_ad_tag_url"`
	Description  string `json:"description"`
	Tags         tags   `json:"tags"`
	Geo          Geo    `json:"geo"`
}

PlayerCreateRequest identifies Player for the Create request

type PlayerUpdateRequest

type PlayerUpdateRequest struct {
	Name         string `json:"name"`
	Folder       string `json:"folder"`
	Videos       videos `json:"videos"`
	ScreenShotID string `json:"screen_shot_id"`
	Description  string `json:"description"`
	Tags         tags   `json:"tags"`
	Geo          Geo    `json:"geo"`
}

PlayerUpdateRequest indentifies Player for the Update request

type PlayersCli

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

PlayersCli handles communication with API

func (PlayersCli) Create

func (c PlayersCli) Create(ctx context.Context, playerCreateRequest *PlayerCreateRequest) (*Player, *http.Response, error)

Create Player

func (PlayersCli) Delete

func (c PlayersCli) Delete(ctx context.Context, id string) (*http.Response, error)

Delete Player

func (PlayersCli) Get

func (c PlayersCli) Get(ctx context.Context, id string) (*Player, *http.Response, error)

Get Player

func (PlayersCli) List

func (c PlayersCli) List(ctx context.Context, params interface{}) ([]Player, *http.Response, error)

List of Players

func (PlayersCli) Update

func (c PlayersCli) Update(ctx context.Context, id string, playerUpdateRequest *PlayerUpdateRequest) (*http.Response, error)

Update Player

type PlayersService

PlayersService implements interface with API /players endpoint. See https://doc.platformcraft.ru/filespot/api/en/#players

type Preset

type Preset struct {
	ID         string                     `json:"id"`
	Name       string                     `json:"name"`
	Container  string                     `json:"container"`
	Video      map[string]string          `json:"video"`
	Audio      map[string]string          `json:"audio"`
	Watermarks map[string]watermarkParams `json:"watermarks"`
}

Preset represents a platformcraft Preset

type Record

type Record struct {
	Status string   `json:"status"`
	Files  []string `json:"files"`
}

Record represents a platformcraft Record

type SecureLink struct {
	Hash string `json:"hash"`
	URL  string `json:"url"`
}

SecureLink represents a platformcraft Secure Link

type SecureLinkRequest

type SecureLinkRequest struct {
	IP string `json:"ip"`
	TS int    `json:"ts"`
}

SecureLinkRequest identifies data for Secure request

type Storage

type Storage struct {
	Used  int `json:"used"`
	Limit int `json:"limit"`
}

Storage represents a platformcraft Storage

type StorageCli

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

StorageCli handles communication with API

func (StorageCli) Get

func (c StorageCli) Get(ctx context.Context) (*Storage, *http.Response, error)

Get Storage

type StorageService

type StorageService interface {
	Get(context.Context) (*Storage, *http.Response, error)
}

StorageService implements interface with API /storage endpoint. See https://doc.platformcraft.ru/filespot/api/en/#storage

type Stream

type Stream struct {
	ID                 string `json:"id"`
	User               string `json:"user"`
	Name               string `json:"name"`
	URL                string `json:"url"`
	IsInstantRecording bool   `json:"is_instant_recording"`
}

Stream represents a platformcraft Stream

type StreamCreateRequest

type StreamCreateRequest struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

StreamCreateRequest identifies Stream for the Create request

type StreamStartRequest

type StreamStartRequest struct {
	StopTimeout int `json:"stop_timeout"`
}

StreamStartRequest identifies streaming process for the Start request

type StreamsCli

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

StreamsCli handles communication with API

func (StreamsCli) Create

func (c StreamsCli) Create(ctx context.Context, streamCreateRequest *StreamCreateRequest) (*Stream, *http.Response, error)

Create Stream

func (StreamsCli) CreateSchedule

func (c StreamsCli) CreateSchedule(ctx context.Context, id string) (string, *http.Response, error)

CreateSchedule returns record_id

func (StreamsCli) Delete

func (c StreamsCli) Delete(ctx context.Context, id string) (*http.Response, error)

Delete Stream

func (StreamsCli) DeleteSchedule

func (c StreamsCli) DeleteSchedule(ctx context.Context, streamID string, recordID string) (*http.Response, error)

DeleteSchedule deletes record

func (StreamsCli) Get

func (c StreamsCli) Get(ctx context.Context, id string) (*Stream, *http.Response, error)

Get Stream

func (StreamsCli) List

func (c StreamsCli) List(ctx context.Context) ([]Stream, *http.Response, error)

List of Streams

func (StreamsCli) Rec

func (c StreamsCli) Rec(ctx context.Context, id string) (*Record, *http.Response, error)

Rec returns Record

func (StreamsCli) Start

func (c StreamsCli) Start(ctx context.Context, id string, streamStartRequest *StreamStartRequest) (*http.Response, error)

Start Stream

func (StreamsCli) Stop

func (c StreamsCli) Stop(ctx context.Context, id string) ([]File, *http.Response, error)

Stop Stream

type Task

type Task struct {
	ID         string `json:"id"`
	Category   string `json:"category"`
	Title      string `json:"title"`
	Body       string `json:"body"`
	Status     string `json:"status"`
	TimeStart  string `json:"time_start"`
	TimeFinish string `json:"time_finish"`
	Lock       bool   `json:"lock"`
}

Task represents a platformcraft Task

type TempCli

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

TempCli handles communication with API

func (TempCli) Create

func (c TempCli) Create(ctx context.Context, linkCreateRequest *LinkCreateRequest) (*Link, *http.Response, error)

Create Link

func (TempCli) Delete

func (c TempCli) Delete(ctx context.Context, id string) (*http.Response, error)

Delete Link

func (TempCli) Get

func (c TempCli) Get(ctx context.Context, id string) (*Link, *http.Response, error)

Get Link

func (TempCli) List

func (c TempCli) List(ctx context.Context, params interface{}) ([]Link, *http.Response, error)

List of Links

func (TempCli) Secure

func (c TempCli) Secure(ctx context.Context, id string, secureLinkRequest *SecureLinkRequest) (*SecureLink, *http.Response, error)

Secure Link

type TempListParams

type TempListParams struct {
	ObjectID string `url:"object_id,omitempty"`
	ForSale  bool   `json:"for_sale,omitempty"`
	Secure   bool   `json:"secure,omitempty"`
}

TempListParams identifies as query params of List request

type TempService

TempService implements interface with API /temp endpoint. See https://doc.platformcraft.ru/filespot/api/en/#temp

type Transcoder

type Transcoder struct {
	ActiveTasks int    `json:"active_tasks"`
	TaskID      string `json:"task_id"`
}

Transcoder represents a platformcraft Transcoder

type TranscoderCli

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

TranscoderCli handles communication with API

func (TranscoderCli) Concat

func (c TranscoderCli) Concat(ctx context.Context, transcoderConcatRequest *TranscoderConcatRequest) (*Transcoder, *http.Response, error)

Concat Transcoder

func (TranscoderCli) Create

func (c TranscoderCli) Create(ctx context.Context, id string, transcoderCreateRequest *TranscoderCreateRequest) (*Transcoder, *http.Response, error)

Create Transcoder

func (TranscoderCli) HLS

func (c TranscoderCli) HLS(ctx context.Context, id string, transcoderHLSRequest *TranscoderHLSRequest) (*Transcoder, *http.Response, error)

HLS Transcoder

func (TranscoderCli) Presets

func (c TranscoderCli) Presets(ctx context.Context) ([]Preset, *http.Response, error)

Presets Transcoder

type TranscoderConcatRequest

type TranscoderConcatRequest struct {
	Files []string `json:"files"`
	Path  string   `json:"path"`
	Name  string   `json:"name"`
}

TranscoderConcatRequest identifies params for the Concat request

type TranscoderCreateRequest

type TranscoderCreateRequest struct {
	Presets     []string  `json:"presets"`
	Path        string    `json:"path"`
	Watermarks  watermark `json:"watermarks"`
	DelOriginal bool      `json:"del_original"`
	Start       int       `json:"start"`
	Duration    int       `json:"duration"`
}

TranscoderCreateRequest identifies params for the Create request

type TranscoderHLSRequest

type TranscoderHLSRequest struct {
	Presets         []string `json:"presets"`
	SegmentDuration int      `json:"segment_duration"`
}

TranscoderHLSRequest identifies params for the HLS request

type TranscoderService

TranscoderService implements interface with API /transcoder endpoint. See https://doc.platformcraft.ru/filespot/api/en/#transcoder

type TranscoderTasksCli

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

TranscoderTasksCli handles communication with API

func (TranscoderTasksCli) Delete

func (c TranscoderTasksCli) Delete(ctx context.Context, id string) (*http.Response, error)

Delete transcoder Task

func (TranscoderTasksCli) Get

Get Task

func (TranscoderTasksCli) HLS

HLS Task

func (TranscoderTasksCli) List

List returns list of all transcoders tasks

type TranscoderTasksService

type TranscoderTasksService interface {
	List(context.Context) ([]Task, *http.Response, error)
	Get(context.Context, string) (*Task, *http.Response, error)
	HLS(context.Context, string) (*Task, *http.Response, error)
	Delete(context.Context, string) (*http.Response, error)
}

TranscoderTasksService implements interface with API /transcoder_tasks endpoint. See https://doc.platformcraft.ru/filespot/api/en/#transcoder_tasks

Jump to

Keyboard shortcuts

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