Class: Conversant::V3::Services::VMS

Inherits:
Base
  • Object
show all
Includes:
Authorization
Defined in:
lib/conversant/v3/services/vms.rb,
lib/conversant/v3/services/vms/partner.rb,
lib/conversant/v3/services/vms/business.rb,
lib/conversant/v3/services/vms/analytics.rb,
lib/conversant/v3/services/vms/transcoding.rb,
lib/conversant/v3/services/vms/partner/business.rb,
lib/conversant/v3/services/vms/partner/analytics.rb,
sig/conversant/v3/services/vms.rbs

Overview

VMS (Video Management System) service

Defined Under Namespace

Classes: Analytics, Business, Partner, Transcoding, VodTranscoding

Constant Summary

Constants included from HttpClient

HttpClient::PORTAL_SESSION_REDIS_KEY, HttpClient::SSO_GW_SESSION2_REDIS_KEY

Instance Attribute Summary

Attributes inherited from Base

#customer_id, #type

Instance Method Summary collapse

Methods included from Authorization

#authorize, #authorized_headers, #base_headers, #build_cookie_hash, #build_headers_with_cookies, #cached_session, #fetch_session_cookie, #fetch_sso_session, #format_cookies, #log_missing_session, #session_cache_key, #sso_cache_key

Methods inherited from Base

#configuration, #identifier, #initialize, #logger, #portal_endpoint, #redis, #sso_endpoint, #validate_configuration!

Methods included from HttpClient

#add_cookies_to_headers, #authenticate, #configuration, #cookie_jar, #cookie_jar=, #debug_log, #extract_form_action, #http_get, #http_post, #login_url, #parse_cookie_to_jar, #redis, #request, #sso_login, #update_cookie_jar

Constructor Details

This class inherits a constructor from Conversant::V3::Base

Instance Method Details

#analyticsAnalytics

Get analytics service instance

Returns:

  • (Analytics)

    analytics service for video metrics

Since:

  • 1.0.0



40
41
42
# File 'lib/conversant/v3/services/vms.rb', line 40

def analytics
  @analytics ||= Analytics.new(self)
end

#businessBusiness

Get business metrics service instance

Returns:

  • (Business)

    business service for billing metrics

Since:

  • 1.0.0



48
49
50
# File 'lib/conversant/v3/services/vms.rb', line 48

def business
  @business ||= Business.new(self)
end

#fetch_new_sessionString?

Returns:

  • (String, nil)

Since:

  • 1.0.0



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/conversant/v3/services/vms.rb', line 102

def fetch_new_session
  sessions = authenticate
  return nil unless sessions && sessions[:session] && sessions[:sso_gw_session2]

  timestamp = (Time.now.to_f * 1000).to_i
  reporting_url = "#{configuration.private_vms_endpoint}/reporting/vms/federation/business/usage"
  reporting_url += "?customerId=#{customer_id}&type=#{type || 2}&t=#{timestamp}"

  logger.debug "#{identifier}.METHOD:authorize.REQUESTING_JSESSIONID"

  response = RestClient.get(
    reporting_url,
    {
      authority: URI.parse(configuration.private_vms_endpoint).hostname,
      referer: portal_endpoint,
      user_agent: configuration.default_ua,
      cookies: {
        'SESSION': sessions[:session],
        'SSO_GW_SESSION2': sessions[:sso_gw_session2]
      },
      timeout: 30,
      open_timeout: 30
    }
  )

  if response.cookies['JSESSIONID']
    jsessionid = response.cookies['JSESSIONID']
    redis.set(session_cache_key, jsessionid, ex: configuration.cache_ttl)
    logger.debug "#{identifier}.METHOD:authorize.JSESSIONID_OBTAINED"
    jsessionid
  else
    logger.error "#{identifier}.METHOD:authorize.NO_JSESSIONID_IN_RESPONSE"
    nil
  end
rescue RestClient::Unauthorized, RestClient::Forbidden => e
  logger.error "#{identifier}.METHOD:authorize.AUTH_ERROR:#{e.message}"
  nil
rescue StandardError => e
  logger.error "#{identifier}.METHOD:authorize.ERROR:#{e.message}"
  nil
end

#partnerPartner

Get partner service instance

Provides access to partner-level analytics for Video Management System that aggregate data across multiple customer accounts.

Examples:

Access partner analytics

vms = Conversant::V3.vms(12345)
transcoding = vms.partner.analytics.transcoding(payload)

Returns:

  • (Partner)

    partner service for VMS analytics

Since:

  • 1.0.12



63
64
65
# File 'lib/conversant/v3/services/vms.rb', line 63

def partner
  @partner ||= Partner.new(self)
end

#partner_analyticsVMS::Partner::Analytics

Deprecated.

Use #partner instead

Get partner analytics service instance (deprecated)

Returns:

Since:

  • 1.0.8



73
74
75
# File 'lib/conversant/v3/services/vms.rb', line 73

def partner_analytics
  @partner_analytics ||= Partner::Analytics.new(self)
end

#requires_session?Boolean

Returns:

  • (Boolean)

Since:

  • 1.0.0



154
155
156
# File 'lib/conversant/v3/services/vms.rb', line 154

def requires_session?
  true
end

#service_endpointString

Returns:

  • (String)

Since:

  • 1.0.0



146
147
148
# File 'lib/conversant/v3/services/vms.rb', line 146

def service_endpoint
  configuration.private_vms_endpoint
end

Returns:

  • (String)

Since:

  • 1.0.0



150
151
152
# File 'lib/conversant/v3/services/vms.rb', line 150

def session_cookie_name
  'JSESSIONID'
end

#transcodingTranscoding

Get transcoding service instance

Returns:

  • (Transcoding)

    transcoding service for job management

Since:

  • 1.0.0



32
33
34
# File 'lib/conversant/v3/services/vms.rb', line 32

def transcoding
  @transcoding ||= Transcoding.new(self)
end

#vod_transcodingVodTranscoding

Service accessors

Returns:



51
# File 'sig/conversant/v3/services/vms.rbs', line 51

def vod_transcoding: () -> VodTranscoding