class Bitmovin::Input

Represents a bitmovin input @see bitmovin.com/encoding-documentation/encoder-api-reference-documentation/#/reference/inputs/ Bitmovin Input docs

Constants

ATTRIBUTES

Attributes

params[R]
url[R]

Public Class Methods

create(*args) click to toggle source

Creates a new bitmovin input

@param (initialize)

@return [Bitmovin::Input] Bitmovin Input details

# File lib/bitmovin/input.rb, line 104
def self.create(*args)
  new(*args).create
end
list(page = 1, reload = false) click to toggle source

Get lsit of available bitmovin inputs (10 per page)

@param page [Number] page number @param reload [Boolean] force reload

@return [Array<Bitmovin::Input>] array of bitmovin inputs

# File lib/bitmovin/input.rb, line 139
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/inputs/#{ page }", initheaders = headers

  response = Bitmovin.http.request get

  list = prepare_response_json(response.body).map { |input| Bitmovin::Input.new(input) }

  val = instance_variable_set(var_name, list)
end
new(*args) click to toggle source

@overload initialize(url, params)

@param url [String] url of input for URL, S3 or Aspera inputs
@param params [String] input params
@option params {Boolean] :async Create input async
@option params [String] :type Type of input
@option params [String] :username Basic auth username
@option params [String] :password Basic auth password
@option params [String] :region ('us-east-1') S3 bucket region
@option params [String] :bucket S3 bucket name for s3 input, also can be infered from url
@option params [String] :object_key S3 object name with containing folder, can be infered from url
@option params [String] :access_key S3 or GCS access key, required for S3 or GCS inputs
@option params [String] :secret_key S3 or GCS secret, required for S3 or GCS inputs
@option params [String] :account_name MS Azure account name, required for Azure inputs
@option params [String] :account_key MS Azure account key, required for Azure inputs
@option params [String] :container MS Azure storage container name
@option params [String] :min_bandwidth, Minimal download bandwidth
@option params [String] :max_bandwidth, Maximal download bandwidth

@overload initialize(params)

@param params [String] input params
@option params {Boolean] :async Create input async
@option params [String] :type Type of input
@option params [String] :url Aspera/Azure file url
@option params [String] :username Basic auth username
@option params [String] :password Basic auth password
@option params [String] :region ('us-east-1') S3 bucket region
@option params [String] :bucket S3 bucket name for s3 input, also can be infered from url
@option params [String] :object_key S3 object name with containing folder, can be infered from url
@option params [String] :access_key S3 or GCS access key, required for S3 or GCS inputs
@option params [String] :secret_key S3 or GCS secret, required for S3 or GCS inputs
@option params [String] :account_name MS Azure account name, required for Azure inputs
@option params [String] :account_key MS Azure account key, required for Azure inputs
@option params [String] :container MS Azure storage container name
@option params [String] :min_bandwidth, Minimal download bandwidth
@option params [String] :max_bandwidth, Maximal download bandwidth

@return [Hash] Input details as a hash

# File lib/bitmovin/input.rb, line 85
def initialize(*args)
  @params = args.pop

  @url = args.pop if args.length == 1

  if @url
    @params[:bucket] = extract_bucket(url) if !@params[:bucket] && @params[:type] == "s3"
    @params[:object_key] = extract_object_key(url) if !@params[:object_key]  && @params[:type] == "s3"
    @params[:url]
  end
end

Public Instance Methods

create() click to toggle source

Creates a new bitmovin input with params given within initialization @return [Bitmovin::Input] Bitmovin Input details

# File lib/bitmovin/input.rb, line 112
def create
  make_create_request
end
details(reload = false) click to toggle source

Get bitmovin input details @param reload [Boolean] force data reload from server

# File lib/bitmovin/input.rb, line 120
def details(reload = false)
  return @params if !reload && @params

  reload_details
end

Private Instance Methods

make_create_request() click to toggle source

@private

# File lib/bitmovin/input.rb, line 160
def make_create_request
  if %w{s3 gcs}.include? params[:type]
    raise Bitmovin::ApiParameterEmptyError.new(parameter = :access_key) unless params[:access_key]
    raise Bitmovin::ApiParameterEmptyError.new(parameter = :secret_key) unless params[:secret_key]
  end

  payload = prepare_request_json(params)
  path = params[:async] ? "/api/input/createasync" : "/api/input/create"
  post = Net::HTTP::Post.new path, initheaders = headers
  post.body = payload

  response = Bitmovin.http.request post

  @params = prepare_response_json(response.body)
  self
rescue Net::HTTPRequestTimeOut => e
  nil
end
reload_details() click to toggle source

@private

# File lib/bitmovin/input.rb, line 181
def reload_details
  get = Net::HTTP::Get.new "/api/input/#{@params[:input_id]}", initheaders = headers

  response = Bitmovin.http.request get

  @params = prepare_response_json(response.body)
end