gcloud 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +3 -3
  3. data/CHANGELOG.md +92 -0
  4. data/OVERVIEW.md +3 -3
  5. data/lib/gcloud.rb +75 -25
  6. data/lib/gcloud/backoff.rb +5 -1
  7. data/lib/gcloud/bigquery.rb +25 -43
  8. data/lib/gcloud/bigquery/copy_job.rb +13 -13
  9. data/lib/gcloud/bigquery/data.rb +20 -16
  10. data/lib/gcloud/bigquery/dataset.rb +202 -177
  11. data/lib/gcloud/bigquery/dataset/access.rb +118 -104
  12. data/lib/gcloud/bigquery/dataset/list.rb +14 -18
  13. data/lib/gcloud/bigquery/extract_job.rb +12 -12
  14. data/lib/gcloud/bigquery/insert_response.rb +12 -14
  15. data/lib/gcloud/bigquery/job.rb +45 -57
  16. data/lib/gcloud/bigquery/job/list.rb +18 -24
  17. data/lib/gcloud/bigquery/load_job.rb +35 -27
  18. data/lib/gcloud/bigquery/project.rb +53 -73
  19. data/lib/gcloud/bigquery/query_data.rb +28 -35
  20. data/lib/gcloud/bigquery/query_job.rb +18 -18
  21. data/lib/gcloud/bigquery/schema.rb +359 -0
  22. data/lib/gcloud/bigquery/service.rb +506 -0
  23. data/lib/gcloud/bigquery/table.rb +185 -266
  24. data/lib/gcloud/bigquery/table/list.rb +15 -19
  25. data/lib/gcloud/bigquery/view.rb +126 -81
  26. data/lib/gcloud/datastore.rb +39 -27
  27. data/lib/gcloud/datastore/commit.rb +2 -2
  28. data/lib/gcloud/datastore/dataset.rb +8 -19
  29. data/lib/gcloud/datastore/dataset/lookup_results.rb +2 -4
  30. data/lib/gcloud/datastore/dataset/query_results.rb +0 -2
  31. data/lib/gcloud/datastore/entity.rb +7 -1
  32. data/lib/gcloud/datastore/errors.rb +5 -27
  33. data/lib/gcloud/datastore/grpc_utils.rb +4 -3
  34. data/lib/gcloud/datastore/key.rb +6 -0
  35. data/lib/gcloud/datastore/service.rb +18 -12
  36. data/lib/gcloud/datastore/transaction.rb +0 -10
  37. data/lib/gcloud/dns.rb +29 -19
  38. data/lib/gcloud/dns/change.rb +10 -15
  39. data/lib/gcloud/dns/change/list.rb +4 -4
  40. data/lib/gcloud/dns/importer.rb +1 -1
  41. data/lib/gcloud/dns/project.rb +32 -49
  42. data/lib/gcloud/dns/record.rb +8 -2
  43. data/lib/gcloud/dns/record/list.rb +4 -4
  44. data/lib/gcloud/dns/service.rb +167 -0
  45. data/lib/gcloud/dns/zone.rb +33 -52
  46. data/lib/gcloud/dns/zone/list.rb +12 -16
  47. data/lib/gcloud/errors.rb +31 -19
  48. data/lib/gcloud/logging.rb +50 -39
  49. data/lib/gcloud/logging/entry.rb +197 -24
  50. data/lib/gcloud/logging/entry/list.rb +0 -2
  51. data/lib/gcloud/logging/logger.rb +1 -1
  52. data/lib/gcloud/logging/metric.rb +3 -9
  53. data/lib/gcloud/logging/metric/list.rb +0 -2
  54. data/lib/gcloud/logging/project.rb +58 -54
  55. data/lib/gcloud/logging/resource_descriptor.rb +2 -2
  56. data/lib/gcloud/logging/resource_descriptor/list.rb +0 -2
  57. data/lib/gcloud/logging/service.rb +32 -23
  58. data/lib/gcloud/logging/sink.rb +8 -14
  59. data/lib/gcloud/logging/sink/list.rb +0 -2
  60. data/lib/gcloud/pubsub.rb +21 -16
  61. data/lib/gcloud/pubsub/policy.rb +204 -0
  62. data/lib/gcloud/pubsub/project.rb +26 -38
  63. data/lib/gcloud/pubsub/service.rb +39 -31
  64. data/lib/gcloud/pubsub/subscription.rb +56 -59
  65. data/lib/gcloud/pubsub/subscription/list.rb +4 -4
  66. data/lib/gcloud/pubsub/topic.rb +69 -66
  67. data/lib/gcloud/pubsub/topic/list.rb +0 -2
  68. data/lib/gcloud/pubsub/topic/{batch.rb → publisher.rb} +15 -2
  69. data/lib/gcloud/resource_manager.rb +27 -26
  70. data/lib/gcloud/resource_manager/manager.rb +19 -39
  71. data/lib/gcloud/resource_manager/policy.rb +211 -0
  72. data/lib/gcloud/resource_manager/project.rb +97 -121
  73. data/lib/gcloud/resource_manager/project/list.rb +7 -7
  74. data/lib/gcloud/resource_manager/project/updater.rb +4 -9
  75. data/lib/gcloud/resource_manager/service.rb +127 -0
  76. data/lib/gcloud/storage.rb +24 -42
  77. data/lib/gcloud/storage/bucket.rb +104 -192
  78. data/lib/gcloud/storage/bucket/acl.rb +47 -143
  79. data/lib/gcloud/storage/bucket/cors.rb +55 -11
  80. data/lib/gcloud/storage/bucket/list.rb +14 -14
  81. data/lib/gcloud/storage/errors.rb +3 -43
  82. data/lib/gcloud/storage/file.rb +114 -111
  83. data/lib/gcloud/storage/file/acl.rb +27 -113
  84. data/lib/gcloud/storage/file/list.rb +21 -21
  85. data/lib/gcloud/storage/project.rb +49 -59
  86. data/lib/gcloud/storage/service.rb +347 -0
  87. data/lib/gcloud/translate.rb +24 -14
  88. data/lib/gcloud/translate/api.rb +12 -21
  89. data/lib/gcloud/translate/detection.rb +5 -5
  90. data/lib/gcloud/translate/language.rb +1 -1
  91. data/lib/gcloud/translate/service.rb +80 -0
  92. data/lib/gcloud/translate/translation.rb +6 -6
  93. data/lib/gcloud/version.rb +1 -1
  94. data/lib/gcloud/vision.rb +24 -15
  95. data/lib/gcloud/vision/annotate.rb +24 -21
  96. data/lib/gcloud/vision/annotation.rb +9 -9
  97. data/lib/gcloud/vision/annotation/entity.rb +11 -11
  98. data/lib/gcloud/vision/annotation/face.rb +25 -25
  99. data/lib/gcloud/vision/annotation/properties.rb +8 -8
  100. data/lib/gcloud/vision/annotation/safe_search.rb +4 -4
  101. data/lib/gcloud/vision/annotation/text.rb +7 -7
  102. data/lib/gcloud/vision/annotation/vertex.rb +1 -1
  103. data/lib/gcloud/vision/image.rb +11 -11
  104. data/lib/gcloud/vision/location.rb +5 -2
  105. data/lib/gcloud/vision/project.rb +14 -16
  106. data/lib/gcloud/vision/service.rb +66 -0
  107. data/lib/google/api_client.rb +0 -0
  108. metadata +27 -24
  109. data/lib/gcloud/bigquery/connection.rb +0 -624
  110. data/lib/gcloud/bigquery/errors.rb +0 -68
  111. data/lib/gcloud/bigquery/table/schema.rb +0 -234
  112. data/lib/gcloud/dns/connection.rb +0 -173
  113. data/lib/gcloud/dns/errors.rb +0 -68
  114. data/lib/gcloud/resource_manager/connection.rb +0 -134
  115. data/lib/gcloud/resource_manager/errors.rb +0 -68
  116. data/lib/gcloud/storage/connection.rb +0 -444
  117. data/lib/gcloud/translate/connection.rb +0 -85
  118. data/lib/gcloud/translate/errors.rb +0 -68
  119. data/lib/gcloud/upload.rb +0 -95
  120. data/lib/gcloud/vision/connection.rb +0 -63
  121. data/lib/gcloud/vision/errors.rb +0 -69
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "json"
17
+
16
18
  module Gcloud
17
19
  module Bigquery
18
20
  ##
@@ -29,28 +31,24 @@ module Gcloud
29
31
  end
30
32
 
31
33
  def insert_count
32
- @insert_count ||= @rows.count - error_count
34
+ @rows.count - error_count
33
35
  end
34
36
 
35
37
  def error_count
36
- @error_count ||= Array(@gapi["insertErrors"]).count
38
+ Array(@gapi.insert_errors).count
37
39
  end
38
40
 
39
41
  def insert_errors
40
- @insert_errors ||= begin
41
- Array(@gapi["insertErrors"]).map do |ie|
42
- row = @rows[ie["index"]]
43
- errors = ie["errors"]
44
- InsertError.new row, errors
45
- end
42
+ Array(@gapi.insert_errors).map do |ie|
43
+ row = @rows[ie.index]
44
+ errors = ie.errors.map { |e| JSON.parse e.to_json }
45
+ InsertError.new row, errors
46
46
  end
47
47
  end
48
48
 
49
49
  def error_rows
50
- @error_rows ||= begin
51
- Array(@gapi["insertErrors"]).map do |ie|
52
- @rows[ie["index"]]
53
- end
50
+ Array(@gapi.insert_errors).map do |ie|
51
+ @rows[ie.index]
54
52
  end
55
53
  end
56
54
 
@@ -60,9 +58,9 @@ module Gcloud
60
58
  []
61
59
  end
62
60
 
63
- # @private
61
+ # @private New InsertResponse from the inserted rows and a
62
+ # Google::Apis::BigqueryV2::InsertAllTableDataResponse object.
64
63
  def self.from_gapi rows, gapi
65
- gapi = gapi.to_hash if gapi.respond_to? :to_hash
66
64
  new rows, gapi
67
65
  end
68
66
 
@@ -13,9 +13,11 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "gcloud/errors"
17
+ require "gcloud/bigquery/service"
16
18
  require "gcloud/bigquery/query_data"
17
19
  require "gcloud/bigquery/job/list"
18
- require "gcloud/bigquery/errors"
20
+ require "json"
19
21
 
20
22
  module Gcloud
21
23
  module Bigquery
@@ -55,8 +57,8 @@ module Gcloud
55
57
  #
56
58
  class Job
57
59
  ##
58
- # @private The Connection object.
59
- attr_accessor :connection
60
+ # @private The Service object.
61
+ attr_accessor :service
60
62
 
61
63
  ##
62
64
  # @private The Google API Client object.
@@ -65,20 +67,20 @@ module Gcloud
65
67
  ##
66
68
  # @private Create an empty Job object.
67
69
  def initialize
68
- @connection = nil
70
+ @service = nil
69
71
  @gapi = {}
70
72
  end
71
73
 
72
74
  ##
73
75
  # The ID of the job.
74
76
  def job_id
75
- @gapi["jobReference"]["jobId"]
77
+ @gapi.job_reference.job_id
76
78
  end
77
79
 
78
80
  ##
79
81
  # The ID of the project containing the job.
80
82
  def project_id
81
- @gapi["jobReference"]["projectId"]
83
+ @gapi.job_reference.project_id
82
84
  end
83
85
 
84
86
  ##
@@ -87,8 +89,8 @@ module Gcloud
87
89
  # completed successfully. Use {#failed?} to discover if an error occurred
88
90
  # or if the job was successful.
89
91
  def state
90
- return nil if @gapi["status"].nil?
91
- @gapi["status"]["state"]
92
+ return nil if @gapi.status.nil?
93
+ @gapi.status.state
92
94
  end
93
95
 
94
96
  ##
@@ -124,9 +126,9 @@ module Gcloud
124
126
  ##
125
127
  # The time when the job was created.
126
128
  def created_at
127
- return nil if @gapi["statistics"].nil?
128
- return nil if @gapi["statistics"]["creationTime"].nil?
129
- Time.at(@gapi["statistics"]["creationTime"] / 1000.0)
129
+ Time.at(Integer(@gapi.statistics.creation_time) / 1000.0)
130
+ rescue
131
+ nil
130
132
  end
131
133
 
132
134
  ##
@@ -134,18 +136,18 @@ module Gcloud
134
136
  # This field is present after the job's state changes from `PENDING`
135
137
  # to either `RUNNING` or `DONE`.
136
138
  def started_at
137
- return nil if @gapi["statistics"].nil?
138
- return nil if @gapi["statistics"]["startTime"].nil?
139
- Time.at(@gapi["statistics"]["startTime"] / 1000.0)
139
+ Time.at(Integer(@gapi.statistics.start_time) / 1000.0)
140
+ rescue
141
+ nil
140
142
  end
141
143
 
142
144
  ##
143
145
  # The time when the job ended.
144
146
  # This field is present when the job's state is `DONE`.
145
147
  def ended_at
146
- return nil if @gapi["statistics"].nil?
147
- return nil if @gapi["statistics"]["endTime"].nil?
148
- Time.at(@gapi["statistics"]["endTime"] / 1000.0)
148
+ Time.at(Integer(@gapi.statistics.end_time) / 1000.0)
149
+ rescue
150
+ nil
149
151
  end
150
152
 
151
153
  ##
@@ -154,9 +156,7 @@ module Gcloud
154
156
  # @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
155
157
  # reference
156
158
  def configuration
157
- hash = @gapi["configuration"] || {}
158
- hash = hash.to_hash if hash.respond_to? :to_hash
159
- hash
159
+ JSON.parse @gapi.configuration.to_json
160
160
  end
161
161
  alias_method :config, :configuration
162
162
 
@@ -166,9 +166,7 @@ module Gcloud
166
166
  # @see https://cloud.google.com/bigquery/docs/reference/v2/jobs Jobs API
167
167
  # reference
168
168
  def statistics
169
- hash = @gapi["statistics"] || {}
170
- hash = hash.to_hash if hash.respond_to? :to_hash
171
- hash
169
+ JSON.parse @gapi.statistics.to_json
172
170
  end
173
171
  alias_method :stats, :statistics
174
172
 
@@ -176,9 +174,7 @@ module Gcloud
176
174
  # The job's status. Returns a hash. The values contained in the hash are
177
175
  # also exposed by {#state}, {#error}, and {#errors}.
178
176
  def status
179
- hash = @gapi["status"] || {}
180
- hash = hash.to_hash if hash.respond_to? :to_hash
181
- hash
177
+ JSON.parse @gapi.status.to_json
182
178
  end
183
179
 
184
180
  ##
@@ -196,38 +192,33 @@ module Gcloud
196
192
  # }
197
193
  #
198
194
  def error
199
- status["errorResult"]
195
+ return nil if @gapi.status.nil?
196
+ return nil if @gapi.status.error_result.nil?
197
+ JSON.parse @gapi.status.error_result.to_json
200
198
  end
201
199
 
202
200
  ##
203
201
  # The errors for the job, if any errors have occurred. Returns an array
204
202
  # of hash objects. See {#error}.
205
203
  def errors
206
- Array status["errors"]
204
+ return [] if @gapi.status.nil?
205
+ Array(@gapi.status.errors).map { |e| JSON.parse e.to_json }
207
206
  end
208
207
 
209
208
  ##
210
209
  # Created a new job with the current configuration.
211
210
  def rerun!
212
- ensure_connection!
213
- resp = connection.insert_job configuration
214
- if resp.success?
215
- Job.from_gapi resp.data, connection
216
- else
217
- fail ApiError.from_response(resp)
218
- end
211
+ ensure_service!
212
+ gapi = service.insert_job @gapi.configuration
213
+ Job.from_gapi gapi, service
219
214
  end
220
215
 
221
216
  ##
222
217
  # Reloads the job with current data from the BigQuery service.
223
218
  def reload!
224
- ensure_connection!
225
- resp = connection.get_job job_id
226
- if resp.success?
227
- @gapi = resp.data
228
- else
229
- fail ApiError.from_response(resp)
230
- end
219
+ ensure_service!
220
+ gapi = service.get_job job_id
221
+ @gapi = gapi
231
222
  end
232
223
  alias_method :refresh!, :reload!
233
224
 
@@ -263,7 +254,7 @@ module Gcloud
263
254
  klass = klass_for gapi
264
255
  klass.new.tap do |f|
265
256
  f.gapi = gapi
266
- f.connection = conn
257
+ f.service = conn
267
258
  end
268
259
  end
269
260
 
@@ -271,34 +262,31 @@ module Gcloud
271
262
 
272
263
  ##
273
264
  # Raise an error unless an active connection is available.
274
- def ensure_connection!
275
- fail "Must have active connection" unless connection
265
+ def ensure_service!
266
+ fail "Must have active connection" unless service
276
267
  end
277
268
 
278
269
  ##
279
270
  # Get the subclass for a job type
280
271
  def self.klass_for gapi
281
- if gapi["configuration"]["copy"]
272
+ if gapi.configuration.copy
282
273
  return CopyJob
283
- elsif gapi["configuration"]["extract"]
274
+ elsif gapi.configuration.extract
284
275
  return ExtractJob
285
- elsif gapi["configuration"]["load"]
276
+ elsif gapi.configuration.load
286
277
  return LoadJob
287
- elsif gapi["configuration"]["query"]
278
+ elsif gapi.configuration.query
288
279
  return QueryJob
289
280
  end
290
281
  Job
291
282
  end
292
283
 
293
284
  def retrieve_table project_id, dataset_id, table_id
294
- ensure_connection!
295
- resp = connection.get_project_table project_id, dataset_id, table_id
296
- if resp.success?
297
- Table.from_gapi resp.data, connection
298
- else
299
- return nil if resp.status == 404
300
- fail ApiError.from_response(resp)
301
- end
285
+ ensure_service!
286
+ gapi = service.get_project_table project_id, dataset_id, table_id
287
+ Table.from_gapi gapi, service
288
+ rescue Gcloud::NotFoundError
289
+ nil
302
290
  end
303
291
  end
304
292
  end
@@ -29,9 +29,6 @@ module Gcloud
29
29
  # A hash of this page of results.
30
30
  attr_accessor :etag
31
31
 
32
- # Total number of jobs in this collection.
33
- attr_accessor :total
34
-
35
32
  ##
36
33
  # @private Create a new Job::List with an array of jobs.
37
34
  def initialize arr = []
@@ -74,14 +71,10 @@ module Gcloud
74
71
  # end
75
72
  def next
76
73
  return nil unless next?
77
- ensure_connection!
74
+ ensure_service!
78
75
  options = { all: @hidden, token: token, max: @max, filter: @filter }
79
- resp = @connection.list_jobs options
80
- if resp.success?
81
- self.class.from_response resp, @connection, @hidden, @max, @filter
82
- else
83
- fail ApiError.from_response(resp)
84
- end
76
+ gapi = @service.list_jobs options
77
+ self.class.from_gapi gapi, @service, @hidden, @max, @filter
85
78
  end
86
79
 
87
80
  ##
@@ -150,27 +143,28 @@ module Gcloud
150
143
  end
151
144
 
152
145
  ##
153
- # @private New Job::List from a response object.
154
- def self.from_response resp, conn, hidden = nil, max = nil, filter = nil
155
- jobs = List.new(Array(resp.data["jobs"]).map do |gapi_object|
156
- Job.from_gapi gapi_object, conn
146
+ # @private New Job::List from a Google API Client
147
+ # Google::Apis::BigqueryV2::JobList object.
148
+ def self.from_gapi gapi_list, service, hidden = nil, max = nil,
149
+ filter = nil
150
+ jobs = List.new(Array(gapi_list.jobs).map do |gapi_object|
151
+ Job.from_gapi gapi_object, service
157
152
  end)
158
- jobs.instance_variable_set "@token", resp.data["nextPageToken"]
159
- jobs.instance_variable_set "@etag", resp.data["etag"]
160
- jobs.instance_variable_set "@total", resp.data["totalItems"]
161
- jobs.instance_variable_set "@connection", conn
162
- jobs.instance_variable_set "@hidden", hidden
163
- jobs.instance_variable_set "@max", max
164
- jobs.instance_variable_set "@filter", filter
153
+ jobs.instance_variable_set :@token, gapi_list.next_page_token
154
+ jobs.instance_variable_set :@etag, gapi_list.etag
155
+ jobs.instance_variable_set :@service, service
156
+ jobs.instance_variable_set :@hidden, hidden
157
+ jobs.instance_variable_set :@max, max
158
+ jobs.instance_variable_set :@filter, filter
165
159
  jobs
166
160
  end
167
161
 
168
162
  protected
169
163
 
170
164
  ##
171
- # Raise an error unless an active connection is available.
172
- def ensure_connection!
173
- fail "Must have active connection" unless @connection
165
+ # Raise an error unless an active service is available.
166
+ def ensure_service!
167
+ fail "Must have active connection" unless @service
174
168
  end
175
169
  end
176
170
  end
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "gcloud/bigquery/service"
17
+
16
18
  module Gcloud
17
19
  module Bigquery
18
20
  ##
@@ -31,39 +33,39 @@ module Gcloud
31
33
  # The URI or URIs representing the Google Cloud Storage files from which
32
34
  # the operation loads data.
33
35
  def sources
34
- Array config["load"]["sourceUris"]
36
+ Array @gapi.configuration.load.source_uris
35
37
  end
36
38
 
37
39
  ##
38
40
  # The table into which the operation loads data. This is the table on
39
41
  # which {Table#load} was invoked. Returns a {Table} instance.
40
42
  def destination
41
- table = config["load"]["destinationTable"]
43
+ table = @gapi.configuration.load.destination_table
42
44
  return nil unless table
43
- retrieve_table table["projectId"],
44
- table["datasetId"],
45
- table["tableId"]
45
+ retrieve_table table.project_id,
46
+ table.dataset_id,
47
+ table.table_id
46
48
  end
47
49
 
48
50
  ##
49
51
  # The delimiter used between fields in the source data. The default is a
50
52
  # comma (,).
51
53
  def delimiter
52
- config["load"]["fieldDelimiter"] || ","
54
+ @gapi.configuration.load.field_delimiter || ","
53
55
  end
54
56
 
55
57
  ##
56
58
  # The number of header rows at the top of a CSV file to skip. The default
57
59
  # value is `0`.
58
60
  def skip_leading_rows
59
- config["load"]["skipLeadingRows"] || 0
61
+ @gapi.configuration.load.skip_leading_rows || 0
60
62
  end
61
63
 
62
64
  ##
63
65
  # Checks if the character encoding of the data is UTF-8. This is the
64
66
  # default.
65
67
  def utf8?
66
- val = config["load"]["encoding"]
68
+ val = @gapi.configuration.load.encoding
67
69
  return true if val.nil?
68
70
  val == "UTF-8"
69
71
  end
@@ -71,7 +73,7 @@ module Gcloud
71
73
  ##
72
74
  # Checks if the character encoding of the data is ISO-8859-1.
73
75
  def iso8859_1?
74
- val = config["load"]["encoding"]
76
+ val = @gapi.configuration.load.encoding
75
77
  val == "ISO-8859-1"
76
78
  end
77
79
 
@@ -82,7 +84,7 @@ module Gcloud
82
84
  # contains quoted newline characters, {#quoted_newlines?} should return
83
85
  # `true`.
84
86
  def quote
85
- val = config["load"]["quote"]
87
+ val = @gapi.configuration.load.quote
86
88
  val = "\"" if val.nil?
87
89
  val
88
90
  end
@@ -93,7 +95,7 @@ module Gcloud
93
95
  # returned. The default value is `0`, which requires that all records be
94
96
  # valid.
95
97
  def max_bad_records
96
- val = config["load"]["maxBadRecords"]
98
+ val = @gapi.configuration.load.max_bad_records
97
99
  val = 0 if val.nil?
98
100
  val
99
101
  end
@@ -102,7 +104,7 @@ module Gcloud
102
104
  # Checks if quoted data sections may contain newline characters in a CSV
103
105
  # file. The default is `false`.
104
106
  def quoted_newlines?
105
- val = config["load"]["allowQuotedNewlines"]
107
+ val = @gapi.configuration.load.allow_quoted_newlines
106
108
  val = true if val.nil?
107
109
  val
108
110
  end
@@ -111,14 +113,14 @@ module Gcloud
111
113
  # Checks if the format of the source data is
112
114
  # [newline-delimited JSON](http://jsonlines.org/). The default is `false`.
113
115
  def json?
114
- val = config["load"]["sourceFormat"]
116
+ val = @gapi.configuration.load.source_format
115
117
  val == "NEWLINE_DELIMITED_JSON"
116
118
  end
117
119
 
118
120
  ##
119
121
  # Checks if the format of the source data is CSV. The default is `true`.
120
122
  def csv?
121
- val = config["load"]["sourceFormat"]
123
+ val = @gapi.configuration.load.source_format
122
124
  return true if val.nil?
123
125
  val == "CSV"
124
126
  end
@@ -126,7 +128,7 @@ module Gcloud
126
128
  ##
127
129
  # Checks if the source data is a Google Cloud Datastore backup.
128
130
  def backup?
129
- val = config["load"]["sourceFormat"]
131
+ val = @gapi.configuration.load.source_format
130
132
  val == "DATASTORE_BACKUP"
131
133
  end
132
134
 
@@ -137,7 +139,7 @@ module Gcloud
137
139
  # if there are too many bad records, an error is returned. The default
138
140
  # value is `false`. Only applicable to CSV, ignored for other formats.
139
141
  def allow_jagged_rows?
140
- val = config["load"]["allowJaggedRows"]
142
+ val = @gapi.configuration.load.allow_jagged_rows
141
143
  val = false if val.nil?
142
144
  val
143
145
  end
@@ -149,45 +151,51 @@ module Gcloud
149
151
  # records, and if there are too many bad records, an invalid error is
150
152
  # returned. The default is `false`.
151
153
  def ignore_unknown_values?
152
- val = config["load"]["ignoreUnknownValues"]
154
+ val = @gapi.configuration.load.ignore_unknown_values
153
155
  val = false if val.nil?
154
156
  val
155
157
  end
156
158
 
157
159
  ##
158
- # The schema for the data. Returns a hash. Can be empty if the table
159
- # has already has the correct schema (see {Table#schema=} and
160
- # {Table#schema}), or if the schema can be inferred from the loaded data.
160
+ # The schema for the data. Returns a hash. Can be empty if the table has
161
+ # already has the correct schema (see {Table#schema}), or if the schema
162
+ # can be inferred from the loaded data.
161
163
  def schema
162
- val = config["load"]["schema"]
163
- val = {} if val.nil?
164
- val
164
+ Schema.from_gapi(@gapi.configuration.load.schema).freeze
165
165
  end
166
166
 
167
167
  ##
168
168
  # The number of source files.
169
169
  def input_files
170
- stats["load"]["inputFiles"]
170
+ Integer @gapi.statistics.load.input_files
171
+ rescue
172
+ nil
171
173
  end
172
174
 
173
175
  ##
174
176
  # The number of bytes of source data.
175
177
  def input_file_bytes
176
- stats["load"]["inputFileBytes"]
178
+ Integer @gapi.statistics.load.input_file_bytes
179
+ rescue
180
+ nil
177
181
  end
178
182
 
179
183
  ##
180
184
  # The number of rows that have been loaded into the table. While an
181
185
  # import job is in the running state, this value may change.
182
186
  def output_rows
183
- stats["load"]["outputRows"]
187
+ Integer @gapi.statistics.load.output_rows
188
+ rescue
189
+ nil
184
190
  end
185
191
 
186
192
  ##
187
193
  # The number of bytes that have been loaded into the table. While an
188
194
  # import job is in the running state, this value may change.
189
195
  def output_bytes
190
- stats["load"]["outputBytes"]
196
+ Integer @gapi.statistics.load.output_bytes
197
+ rescue
198
+ nil
191
199
  end
192
200
  end
193
201
  end