Class: Bitmovin::Input

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

Overview

Represents a bitmovin input

Constant Summary collapse

ATTRIBUTES =
%i{
  input_id
  async
  type
  url
  username
  password
  created_at
  region
  bucket
  object_key
  access_key
  secret_key
  account_name
  account_key
  container
  min_bandwidth
  max_bandwidth
}

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

Instance Attribute Summary collapse

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(url, params) ⇒ Hash #initialize(params) ⇒ Hash

Returns Input details as a hash.

Overloads:

  • #initialize(url, params) ⇒ Hash

    Parameters:

    • url (String)

      url of input for URL, S3 or Aspera inputs

    • params (String)

      input params

    Options Hash (params):

    • :async (Boolean)

      Create input async

    • :type (String)

      Type of input

    • :username (String)

      Basic auth username

    • :password (String)

      Basic auth password

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

      S3 bucket region

    • :bucket (String)

      S3 bucket name for s3 input, also can be infered from url

    • :object_key (String)

      S3 object name with containing folder, can be infered from url

    • :access_key (String)

      S3 or GCS access key, required for S3 or GCS inputs

    • :secret_key (String)

      S3 or GCS secret, required for S3 or GCS inputs

    • :account_name (String)

      MS Azure account name, required for Azure inputs

    • :account_key (String)

      MS Azure account key, required for Azure inputs

    • :container (String)

      MS Azure storage container name

    • :min_bandwidth, (String)

      Minimal download bandwidth

    • :max_bandwidth, (String)

      Maximal download bandwidth

  • #initialize(params) ⇒ Hash

    Parameters:

    • params (String)

      input params

    Options Hash (params):

    • :async (Boolean)

      Create input async

    • :type (String)

      Type of input

    • :url (String)

      Aspera/Azure file url

    • :username (String)

      Basic auth username

    • :password (String)

      Basic auth password

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

      S3 bucket region

    • :bucket (String)

      S3 bucket name for s3 input, also can be infered from url

    • :object_key (String)

      S3 object name with containing folder, can be infered from url

    • :access_key (String)

      S3 or GCS access key, required for S3 or GCS inputs

    • :secret_key (String)

      S3 or GCS secret, required for S3 or GCS inputs

    • :account_name (String)

      MS Azure account name, required for Azure inputs

    • :account_key (String)

      MS Azure account key, required for Azure inputs

    • :container (String)

      MS Azure storage container name

    • :min_bandwidth, (String)

      Minimal download bandwidth

    • :max_bandwidth, (String)

      Maximal download bandwidth



85
86
87
88
89
90
91
92
93
94
95
# 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

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



43
44
45
# File 'lib/bitmovin/input.rb', line 43

def params
  @params
end

#urlObject (readonly)

Returns the value of attribute url.



43
44
45
# File 'lib/bitmovin/input.rb', line 43

def url
  @url
end

Class Method Details

.create(*args) ⇒ Bitmovin::Input

Creates a new bitmovin input

Parameters:

Returns:



104
105
106
# File 'lib/bitmovin/input.rb', line 104

def self.create(*args)
  new(*args).create
end

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

Get lsit of available bitmovin inputs (10 per page)

Parameters:

  • page (Number) (defaults to: 1)

    page number

  • reload (Boolean) (defaults to: false)

    force reload

Returns:



139
140
141
142
143
144
145
146
147
148
149
150
151
152
# 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

Instance Method Details

#createBitmovin::Input

Creates a new bitmovin input with params given within initialization

Returns:



112
113
114
# File 'lib/bitmovin/input.rb', line 112

def create
  make_create_request
end

#details(reload = false) ⇒ Object

Get bitmovin input details

Parameters:

  • reload (Boolean) (defaults to: false)

    force data reload from server



120
121
122
123
124
# File 'lib/bitmovin/input.rb', line 120

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

  reload_details
end