Class: GoogleBigquery::Table

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

Instance Attribute Summary collapse

Attributes inherited from Client

#api, #client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#defaults_options, #parse_response, parse_response

Constructor Details

#initialize(opts = {}) ⇒ Table

Returns a new instance of Table.



7
8
9
# File 'lib/google_bigquery/table.rb', line 7

def initialize( opts={})
  super
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/google_bigquery/table.rb', line 5

def options
  @options
end

Class Method Details

.create(project_id, dataset_id, body = {}) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/google_bigquery/table.rb', line 44

def self.create(project_id, dataset_id, body={})
  res = GoogleBigquery::Auth.client.execute(
    :api_method=> GoogleBigquery::Auth.api.tables.insert, 
    :body_object=> body , #{"datasetReference"=> {"datasetId" =>"whoa"}}, 
    :parameters=> {"projectId"=> project_id, "datasetId"=> dataset_id }
  )
  parse_response(res)
end

.delete(project_id, dataset_id, table_id, body = {}) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/google_bigquery/table.rb', line 53

def self.delete(project_id, dataset_id, table_id, body={})
  res = GoogleBigquery::Auth.client.execute(
    :api_method=> GoogleBigquery::Auth.api.tables.delete, 
    #:body_object=> body, #{"deleteContents"=> false}, 
    :parameters=> {"projectId"=> project_id, "datasetId" => dataset_id, "tableId"=> table_id }
  )
   res.status == 204 ?  true : parse_response(res)
end

.get(project_id, dataset_id, table_id) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/google_bigquery/table.rb', line 18

def self.get(project_id, dataset_id, table_id)
  res = GoogleBigquery::Auth.client.execute(
    :api_method=> GoogleBigquery::Auth.api.tables.get, 
    :parameters=> {"projectId"=> project_id, "datasetId"=> dataset_id, "tableId"=> table_id  }
  )
  parse_response(res)
end

.list(project_id, dataset_id) ⇒ Object



11
12
13
14
15
16
# File 'lib/google_bigquery/table.rb', line 11

def self.list(project_id, dataset_id)
  parse_response GoogleBigquery::Auth.client.execute( 
    GoogleBigquery::Auth.api.tables.list,
    projectId: project_id, datasetId: dataset_id
  )
end

.patch(project_id, dataset_id, table_id, body = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/google_bigquery/table.rb', line 35

def self.patch(project_id, dataset_id, table_id, body={})
  res = GoogleBigquery::Auth.client.execute(
    :api_method=> GoogleBigquery::Auth.api.tables.update, 
    :body_object=> body , #{"datasetReference"=> {"datasetId" =>"whoa"}}, 
    :parameters=> {"projectId"=> project_id, "datasetId" => dataset_id, "tableId"=> table_id }
  )
  parse_response(res)
end

.update(project_id, dataset_id, table_id, body = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/google_bigquery/table.rb', line 26

def self.update(project_id, dataset_id, table_id, body={})
  res = GoogleBigquery::Auth.client.execute(
    :api_method=> GoogleBigquery::Auth.api.tables.update, 
    :body_object=> body , #{"datasetReference"=> {"datasetId" =>"whoa"}}, 
    :parameters=> {"projectId"=> project_id, "datasetId" => dataset_id, "tableId"=> table_id }
  )
  parse_response(res)
end