Class: Yancya::BigQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/yancya/big_query.rb,
lib/yancya/big_query/job.rb,
lib/yancya/big_query/jobs.rb,
lib/yancya/big_query/table.rb,
lib/yancya/big_query/tables.rb,
lib/yancya/big_query/dataset.rb,
lib/yancya/big_query/project.rb,
lib/yancya/big_query/version.rb,
lib/yancya/big_query/datasets.rb,
lib/yancya/big_query/projects.rb,
lib/yancya/big_query/resource.rb,
lib/yancya/big_query/tabledata.rb

Defined Under Namespace

Classes: BQ, Dataset, Datasets, Job, Jobs, Project, Projects, Resource, Table, Tabledata, Tables

Constant Summary collapse

VERSION =
"0.1.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_path:, issuer:, application_name: "github.com/yancya/big_query", application_version: BigQuery::VERSION) ⇒ BigQuery

Returns a new instance of BigQuery.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/yancya/big_query.rb', line 20

def initialize(key_path:,
               issuer:,
               application_name: "github.com/yancya/big_query",
               application_version: BigQuery::VERSION)

  app_info = {
    application_name: application_name,
    application_version: application_version
  }

  client = Google::APIClient.new(app_info)

  asserter = Google::APIClient::JWTAsserter.new(
    issuer,
    "https://www.googleapis.com/auth/bigquery",
    Google::APIClient::PKCS12.load_key(File.open(key_path), "notasecret")
  )

  client.authorization = asserter.authorize

  @bq = BQ.new(client)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



12
13
14
# File 'lib/yancya/big_query.rb', line 12

def client
  @client
end

Instance Method Details

#datasetsObject



43
44
45
# File 'lib/yancya/big_query.rb', line 43

def datasets
  Datasets.new(bq: @bq)
end

#jobsObject



47
48
49
# File 'lib/yancya/big_query.rb', line 47

def jobs
  Jobs.new(bq: @bq)
end

#projectsObject



51
52
53
# File 'lib/yancya/big_query.rb', line 51

def projects
  Projects.new(bq: @bq)
end

#tabledata(project_id:, dataset_id:, table_id:) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/yancya/big_query.rb', line 55

def tabledata(project_id:, dataset_id:, table_id:)
  Tabledata.new(
    project_id: project_id,
    dataset_id: dataset_id,
    table_id: table_id,
    bq: @bq
  )
end

#tablesObject



64
65
66
# File 'lib/yancya/big_query.rb', line 64

def tables
  Tables.new(bq: @bq)
end