Class: Bitmovin::Output

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Includes:
Helpers
Defined in:
lib/bitmovin/output.rb

Overview

Represents a bitmovin Output

Constant Summary collapse

ATTRIBUTES =
%i{
  output_id
  type
  name
  bucket
  region
  access_key
  secret_key
  account_name
  account_key
  container
  prefix
  make_public
  create_sub_directory
  created_at
}

Constants included from Helpers

Helpers::S3_BUCKET_IN_URL_REGEX, Helpers::S3_BUCKET_SUBDOMAIN_REGEX, Helpers::S3_OBJECT_KEY_IN_URL_REGEX, Helpers::S3_OBJECT_KEY_SUBDOMAIN_REGEX

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

deep_camelize_keys, deep_underscore_keys, extract_bucket, extract_object_key, prepare_request_json, prepare_response_json

Constructor Details

#initialize(params = {}) ⇒ Output

Returns a new instance of Output.

Parameters:

  • params (Hash) (defaults to: {})

    Output details

Options Hash (params):

  • :type (String)

    Type of Output

  • :name (String)

    Name of output profile

  • :bucket (String)

    S3 Bucket name for s3 output

  • :region (String) — default: 'us-east-1'

    S3 region of bucket, required for S3 outputs

  • :access_key (String)

    S3/GCS Access Key, required for S3 outputs

  • :secret_key (String)

    S3/GCS Secret key, required for S3 outputs

  • :account_name (String)

    MS Azure account name, required for Azure outputs

  • :account_key (String)

    MS Azure account key, required for Azure outputs

  • :container (String)

    Name of Azure storage container

  • :prefix (String)

    Virtual sub-directory for file

  • :make_public (Boolean)

    If true, all transfered files can be accessed by their respective URL from anyone

  • :create_sub_directory (Boolean) — default: true

    if true, create a sub directory for your job (<job_id>_<hash>)



55
56
57
# File 'lib/bitmovin/output.rb', line 55

def initialize(params={})
  @details = params
end

Class Method Details

.create(params = {}) ⇒ Bitmovin::Output

Creates a new bitmovin output

Parameters:

Returns:



66
67
68
# File 'lib/bitmovin/output.rb', line 66

def self.create(params={})
  new(params).create
end

.list(page = 1, reload = false) ⇒ Array<Bitmovin::Output>

Get lsit of available bitmovin outputs (10 per page)

Parameters:

  • page (Number) (defaults to: 1)

    page number

  • reload (Boolean) (defaults to: false)

    force reload

Returns:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/bitmovin/output.rb', line 99

def list(page = 1, reload = false)
  var_name = :"@list_p#{ page }"
  val = instance_variable_get var_name

  return val if val && !reload

  get = Net::HTTP::Get.new "/api/outputs/?page=#{ page }", initheaders = headers

  response = Bitmovin.http.request get

  list = prepare_response_json(response.body).map { |output| Bitmovin::Output.new(output) }

  val = instance_variable_set var_name, list
end

Instance Method Details

#createBitmovin::Input

Creates a new bitmovin output with params given within initialization

Returns:



74
75
76
# File 'lib/bitmovin/output.rb', line 74

def create
  make_create_request
end

#details(reload = false) ⇒ Hash

Get bitmovin input details

Parameters:

  • reload (Boolean) (defaults to: false)

    force data reload from server

Returns:

  • (Hash)

    output data as a ruby hash



82
83
84
85
86
# File 'lib/bitmovin/output.rb', line 82

def details(reload = false)
  return @details if !reload && @details

  reload_details
end