Class: BigQuery::Client
- Inherits:
-
Object
- Object
- BigQuery::Client
- Defined in:
- lib/big_query/client.rb,
lib/big_query/client/jobs.rb,
lib/big_query/client/load.rb,
lib/big_query/client/query.rb,
lib/big_query/client/errors.rb,
lib/big_query/client/tables.rb,
lib/big_query/client/datasets.rb
Defined Under Namespace
Modules: Datasets, Errors, Insert, Jobs, Query, Tables
Constant Summary
Constants included from Tables
Tables::ALLOWED_FIELD_MODES, Tables::ALLOWED_FIELD_TYPES
Instance Attribute Summary collapse
-
#dataset ⇒ Object
Returns the value of attribute dataset.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #refresh_auth ⇒ Object
Methods included from Insert
Methods included from Datasets
#create_dataset, #datasets, #datasets_formatted, #delete_dataset
Methods included from Tables
#create_table, #delete_table, #describe_table, #insert, #patch_table, #table_data, #tables, #tables_formatted, #update_table
Methods included from Jobs
#get_query_results, #insert_job, #job, #jobs
Methods included from Query
Methods included from Errors
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/big_query/client.rb', line 19 def initialize(opts = {}) @client = Google::APIClient.new( application_name: 'BigQuery ruby app', application_version: BigQuery::VERSION, faraday_option: opts['faraday_option'] ) begin key = Google::APIClient::KeyUtils.load_from_pkcs12(opts['key'], 'notasecret') rescue ArgumentError key = Google::APIClient::KeyUtils.load_from_pem(opts['key'], 'notasecret') end @client. = Signet::OAuth2::Client.new( token_credential_uri: 'https://accounts.google.com/o/oauth2/token', audience: 'https://accounts.google.com/o/oauth2/token', scope: 'https://www.googleapis.com/auth/bigquery', issuer: opts['service_email'], signing_key: key) refresh_auth @bq = @client.discovered_api("bigquery", "v2") @project_id = opts['project_id'] @dataset = opts['dataset'] end |
Instance Attribute Details
#dataset ⇒ Object
Returns the value of attribute dataset.
17 18 19 |
# File 'lib/big_query/client.rb', line 17 def dataset @dataset end |
#project_id ⇒ Object
Returns the value of attribute project_id.
17 18 19 |
# File 'lib/big_query/client.rb', line 17 def project_id @project_id end |
Instance Method Details
#refresh_auth ⇒ Object
47 48 49 |
# File 'lib/big_query/client.rb', line 47 def refresh_auth @client..fetch_access_token! end |