class TableauTrustedInterface::Report
Attributes
auth_server[R]
embed_params[RW]
path[RW]
ticket[R]
user[R]
view_server[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 9 def initialize(options = {}) @path = options.fetch(:path, nil) @embed_params = parse_embed_params(options.fetch(:embed_params, {})) @user = options.fetch(:user, TableauTrustedInterface.config.default_tableau_user) @auth_server = options.fetch(:auth_server, (TableauTrustedInterface.config.default_tableau_auth_server || options.fetch(:server, TableauTrustedInterface.config.default_tableau_server))) @view_server = options.fetch(:view_server, (TableauTrustedInterface.config.default_tableau_view_server || options.fetch(:server, TableauTrustedInterface.config.default_tableau_server))) @ticket = generate_ticket raise TicketDenied, 'Check Tableau IP white-listing or user access' if @ticket == '-1' end
Public Instance Methods
report_embed_url()
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 24 def report_embed_url report.expand(query: embed_params).to_s end
report_url()
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 20 def report_url report.expand(query: nil).to_s end
Private Instance Methods
address()
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 50 def address Addressable::Template.new('{scheme}://{host}{/segments*}/{+report_path}{?query*}') end
generate_ticket()
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 34 def generate_ticket raise MissingConfiguration unless user && auth_server && view_server RestClient.post(URI.join(auth_server, 'trusted').to_s, username: user) rescue SocketError, RestClient::RequestTimeout raise ServerUnavailable, auth_server end
parse_embed_params(params)
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 30 def parse_embed_params(params) Hash[params.map { |key, value| [":#{key}", value] }] end
report()
click to toggle source
# File lib/tableau_trusted_interface/report.rb, line 41 def report address.partial_expand( scheme: URI.parse(view_server).scheme, host: URI.parse(view_server).host, segments: ['trusted', ticket, 'views'], report_path: path ) end