Class: GoogleBigquery::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/google_bigquery/auth.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuth

Returns a new instance of Auth.



7
8
9
10
11
# File 'lib/google_bigquery/auth.rb', line 7

def initialize
  @config = GoogleBigquery::Config
  @key = Google::APIClient::KeyUtils.load_from_pkcs12(@config.key_file, @config.pass_phrase)
  @asserter = Google::APIClient::JWTAsserter.new( @config.email, @config.scope, @key)
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



4
5
6
# File 'lib/google_bigquery/auth.rb', line 4

def api
  @api
end

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/google_bigquery/auth.rb', line 4

def client
  @client
end

Class Method Details

.authorized?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/google_bigquery/auth.rb', line 22

def self.authorized?
  client.present?
end

Instance Method Details

#authorizeObject



13
14
15
16
17
18
19
20
# File 'lib/google_bigquery/auth.rb', line 13

def authorize
  @client = Google::APIClient.new(application_name: "BigBroda", application_version: GoogleBigquery::VERSION )
  @client.authorization = @asserter.authorize
  @client.retries = @config.retries.to_i if @config.retries.to_i > 1
  @api = @client.discovered_api('bigquery', 'v2')
  self.class.api = @api
  self.class.client = @client
end