google-cloud-bigquery 1.52.1 → 1.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/lib/google/cloud/bigquery/condition.rb +218 -0
- data/lib/google/cloud/bigquery/convert.rb +10 -1
- data/lib/google/cloud/bigquery/data.rb +9 -3
- data/lib/google/cloud/bigquery/dataset/access.rb +281 -28
- data/lib/google/cloud/bigquery/dataset.rb +13 -4
- data/lib/google/cloud/bigquery/external/csv_source.rb +171 -0
- data/lib/google/cloud/bigquery/external/data_source.rb +216 -0
- data/lib/google/cloud/bigquery/load_job.rb +167 -0
- data/lib/google/cloud/bigquery/project.rb +39 -7
- data/lib/google/cloud/bigquery/query_job.rb +8 -5
- data/lib/google/cloud/bigquery/routine.rb +77 -0
- data/lib/google/cloud/bigquery/service.rb +17 -12
- data/lib/google/cloud/bigquery/table.rb +77 -3
- data/lib/google/cloud/bigquery/version.rb +1 -1
- metadata +14 -7
|
@@ -121,6 +121,13 @@ module Google
|
|
|
121
121
|
# Add reader access to a user.
|
|
122
122
|
#
|
|
123
123
|
# @param [String] email The email address for the entity.
|
|
124
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
125
|
+
# optional condition for the access rule. A condition is a CEL
|
|
126
|
+
# expression that is evaluated to determine if the access rule
|
|
127
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
128
|
+
# more information. To specify a condition, the
|
|
129
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
130
|
+
# represents an absence of a condition. The default is `nil`.
|
|
124
131
|
#
|
|
125
132
|
# @example
|
|
126
133
|
# require "google/cloud/bigquery"
|
|
@@ -132,14 +139,35 @@ module Google
|
|
|
132
139
|
# access.add_reader_user "entity@example.com"
|
|
133
140
|
# end
|
|
134
141
|
#
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
# @example With a condition:
|
|
143
|
+
# require "google/cloud/bigquery"
|
|
144
|
+
#
|
|
145
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
146
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
147
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
148
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
149
|
+
# title: "Table foo only"
|
|
150
|
+
# )
|
|
151
|
+
#
|
|
152
|
+
# dataset.access do |access|
|
|
153
|
+
# access.add_reader_user "entity@example.com", condition: condition
|
|
154
|
+
# end
|
|
155
|
+
#
|
|
156
|
+
def add_reader_user email, condition: nil
|
|
157
|
+
add_access_role_scope_value :reader, :user, email, condition
|
|
137
158
|
end
|
|
138
159
|
|
|
139
160
|
##
|
|
140
161
|
# Add reader access to a group.
|
|
141
162
|
#
|
|
142
163
|
# @param [String] email The email address for the entity.
|
|
164
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
165
|
+
# optional condition for the access rule. A condition is a CEL
|
|
166
|
+
# expression that is evaluated to determine if the access rule
|
|
167
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
168
|
+
# more information. To specify a condition, the
|
|
169
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
170
|
+
# represents an absence of a condition. The default is `nil`.
|
|
143
171
|
#
|
|
144
172
|
# @example
|
|
145
173
|
# require "google/cloud/bigquery"
|
|
@@ -151,8 +179,22 @@ module Google
|
|
|
151
179
|
# access.add_reader_group "entity@example.com"
|
|
152
180
|
# end
|
|
153
181
|
#
|
|
154
|
-
|
|
155
|
-
|
|
182
|
+
# @example With a condition:
|
|
183
|
+
# require "google/cloud/bigquery"
|
|
184
|
+
#
|
|
185
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
186
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
187
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
188
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
189
|
+
# title: "Table foo only"
|
|
190
|
+
# )
|
|
191
|
+
#
|
|
192
|
+
# dataset.access do |access|
|
|
193
|
+
# access.add_reader_group "entity@example.com", condition: condition
|
|
194
|
+
# end
|
|
195
|
+
#
|
|
196
|
+
def add_reader_group email, condition: nil
|
|
197
|
+
add_access_role_scope_value :reader, :group, email, condition
|
|
156
198
|
end
|
|
157
199
|
|
|
158
200
|
##
|
|
@@ -160,6 +202,13 @@ module Google
|
|
|
160
202
|
# Policy but isn't a user, group, domain, or special group.
|
|
161
203
|
#
|
|
162
204
|
# @param [String] identity The identity reference.
|
|
205
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
206
|
+
# optional condition for the access rule. A condition is a CEL
|
|
207
|
+
# expression that is evaluated to determine if the access rule
|
|
208
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
209
|
+
# more information. To specify a condition, the
|
|
210
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
211
|
+
# represents an absence of a condition. The default is `nil`.
|
|
163
212
|
#
|
|
164
213
|
# @example
|
|
165
214
|
# require "google/cloud/bigquery"
|
|
@@ -171,8 +220,22 @@ module Google
|
|
|
171
220
|
# access.add_reader_iam_member "entity@example.com"
|
|
172
221
|
# end
|
|
173
222
|
#
|
|
174
|
-
|
|
175
|
-
|
|
223
|
+
# @example With a condition:
|
|
224
|
+
# require "google/cloud/bigquery"
|
|
225
|
+
#
|
|
226
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
227
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
228
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
229
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
230
|
+
# title: "Table foo only"
|
|
231
|
+
# )
|
|
232
|
+
#
|
|
233
|
+
# dataset.access do |access|
|
|
234
|
+
# access.add_reader_iam_member "entity@example.com", condition: condition
|
|
235
|
+
# end
|
|
236
|
+
#
|
|
237
|
+
def add_reader_iam_member identity, condition: nil
|
|
238
|
+
add_access_role_scope_value :reader, :iam_member, identity, condition
|
|
176
239
|
end
|
|
177
240
|
|
|
178
241
|
##
|
|
@@ -180,6 +243,13 @@ module Google
|
|
|
180
243
|
#
|
|
181
244
|
# @param [String] domain A [Cloud Identity
|
|
182
245
|
# domain](https://cloud.google.com/iam/docs/overview#cloudid_name_domain).
|
|
246
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
247
|
+
# optional condition for the access rule. A condition is a CEL
|
|
248
|
+
# expression that is evaluated to determine if the access rule
|
|
249
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
250
|
+
# more information. To specify a condition, the
|
|
251
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
252
|
+
# represents an absence of a condition. The default is `nil`.
|
|
183
253
|
#
|
|
184
254
|
# @example
|
|
185
255
|
# require "google/cloud/bigquery"
|
|
@@ -191,8 +261,22 @@ module Google
|
|
|
191
261
|
# access.add_reader_domain "example.com"
|
|
192
262
|
# end
|
|
193
263
|
#
|
|
194
|
-
|
|
195
|
-
|
|
264
|
+
# @example With a condition:
|
|
265
|
+
# require "google/cloud/bigquery"
|
|
266
|
+
#
|
|
267
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
268
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
269
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
270
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
271
|
+
# title: "Table foo only"
|
|
272
|
+
# )
|
|
273
|
+
#
|
|
274
|
+
# dataset.access do |access|
|
|
275
|
+
# access.add_reader_domain "example.com", condition: condition
|
|
276
|
+
# end
|
|
277
|
+
#
|
|
278
|
+
def add_reader_domain domain, condition: nil
|
|
279
|
+
add_access_role_scope_value :reader, :domain, domain, condition
|
|
196
280
|
end
|
|
197
281
|
|
|
198
282
|
##
|
|
@@ -212,7 +296,7 @@ module Google
|
|
|
212
296
|
# end
|
|
213
297
|
#
|
|
214
298
|
def add_reader_special group
|
|
215
|
-
add_access_role_scope_value :reader, :special, group
|
|
299
|
+
add_access_role_scope_value :reader, :special, group, nil
|
|
216
300
|
end
|
|
217
301
|
|
|
218
302
|
##
|
|
@@ -311,6 +395,13 @@ module Google
|
|
|
311
395
|
# Add writer access to a user.
|
|
312
396
|
#
|
|
313
397
|
# @param [String] email The email address for the entity.
|
|
398
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
399
|
+
# optional condition for the access rule. A condition is a CEL
|
|
400
|
+
# expression that is evaluated to determine if the access rule
|
|
401
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
402
|
+
# more information. To specify a condition, the
|
|
403
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
404
|
+
# represents an absence of a condition. The default is `nil`.
|
|
314
405
|
#
|
|
315
406
|
# @example
|
|
316
407
|
# require "google/cloud/bigquery"
|
|
@@ -322,14 +413,35 @@ module Google
|
|
|
322
413
|
# access.add_writer_user "entity@example.com"
|
|
323
414
|
# end
|
|
324
415
|
#
|
|
325
|
-
|
|
326
|
-
|
|
416
|
+
# @example With a condition:
|
|
417
|
+
# require "google/cloud/bigquery"
|
|
418
|
+
#
|
|
419
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
420
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
421
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
422
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
423
|
+
# title: "Table foo only"
|
|
424
|
+
# )
|
|
425
|
+
#
|
|
426
|
+
# dataset.access do |access|
|
|
427
|
+
# access.add_writer_user "entity@example.com", condition: condition
|
|
428
|
+
# end
|
|
429
|
+
#
|
|
430
|
+
def add_writer_user email, condition: nil
|
|
431
|
+
add_access_role_scope_value :writer, :user, email, condition
|
|
327
432
|
end
|
|
328
433
|
|
|
329
434
|
##
|
|
330
435
|
# Add writer access to a group.
|
|
331
436
|
#
|
|
332
437
|
# @param [String] email The email address for the entity.
|
|
438
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
439
|
+
# optional condition for the access rule. A condition is a CEL
|
|
440
|
+
# expression that is evaluated to determine if the access rule
|
|
441
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
442
|
+
# more information. To specify a condition, the
|
|
443
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
444
|
+
# represents an absence of a condition. The default is `nil`.
|
|
333
445
|
#
|
|
334
446
|
# @example
|
|
335
447
|
# require "google/cloud/bigquery"
|
|
@@ -341,8 +453,22 @@ module Google
|
|
|
341
453
|
# access.add_writer_group "entity@example.com"
|
|
342
454
|
# end
|
|
343
455
|
#
|
|
344
|
-
|
|
345
|
-
|
|
456
|
+
# @example With a condition:
|
|
457
|
+
# require "google/cloud/bigquery"
|
|
458
|
+
#
|
|
459
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
460
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
461
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
462
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
463
|
+
# title: "Table foo only"
|
|
464
|
+
# )
|
|
465
|
+
#
|
|
466
|
+
# dataset.access do |access|
|
|
467
|
+
# access.add_writer_group "entity@example.com", condition: condition
|
|
468
|
+
# end
|
|
469
|
+
#
|
|
470
|
+
def add_writer_group email, condition: nil
|
|
471
|
+
add_access_role_scope_value :writer, :group, email, condition
|
|
346
472
|
end
|
|
347
473
|
|
|
348
474
|
##
|
|
@@ -350,6 +476,13 @@ module Google
|
|
|
350
476
|
# Policy but isn't a user, group, domain, or special group.
|
|
351
477
|
#
|
|
352
478
|
# @param [String] identity The identity reference.
|
|
479
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
480
|
+
# optional condition for the access rule. A condition is a CEL
|
|
481
|
+
# expression that is evaluated to determine if the access rule
|
|
482
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
483
|
+
# more information. To specify a condition, the
|
|
484
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
485
|
+
# represents an absence of a condition. The default is `nil`.
|
|
353
486
|
#
|
|
354
487
|
# @example
|
|
355
488
|
# require "google/cloud/bigquery"
|
|
@@ -361,8 +494,22 @@ module Google
|
|
|
361
494
|
# access.add_writer_iam_member "entity@example.com"
|
|
362
495
|
# end
|
|
363
496
|
#
|
|
364
|
-
|
|
365
|
-
|
|
497
|
+
# @example With a condition:
|
|
498
|
+
# require "google/cloud/bigquery"
|
|
499
|
+
#
|
|
500
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
501
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
502
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
503
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
504
|
+
# title: "Table foo only"
|
|
505
|
+
# )
|
|
506
|
+
#
|
|
507
|
+
# dataset.access do |access|
|
|
508
|
+
# access.add_writer_iam_member "entity@example.com", condition: condition
|
|
509
|
+
# end
|
|
510
|
+
#
|
|
511
|
+
def add_writer_iam_member identity, condition: nil
|
|
512
|
+
add_access_role_scope_value :writer, :iam_member, identity, condition
|
|
366
513
|
end
|
|
367
514
|
|
|
368
515
|
##
|
|
@@ -370,6 +517,13 @@ module Google
|
|
|
370
517
|
#
|
|
371
518
|
# @param [String] domain A [Cloud Identity
|
|
372
519
|
# domain](https://cloud.google.com/iam/docs/overview#cloudid_name_domain).
|
|
520
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
521
|
+
# optional condition for the access rule. A condition is a CEL
|
|
522
|
+
# expression that is evaluated to determine if the access rule
|
|
523
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
524
|
+
# more information. To specify a condition, the
|
|
525
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
526
|
+
# represents an absence of a condition. The default is `nil`.
|
|
373
527
|
#
|
|
374
528
|
# @example
|
|
375
529
|
# require "google/cloud/bigquery"
|
|
@@ -381,8 +535,22 @@ module Google
|
|
|
381
535
|
# access.add_writer_domain "example.com"
|
|
382
536
|
# end
|
|
383
537
|
#
|
|
384
|
-
|
|
385
|
-
|
|
538
|
+
# @example With a condition:
|
|
539
|
+
# require "google/cloud/bigquery"
|
|
540
|
+
#
|
|
541
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
542
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
543
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
544
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
545
|
+
# title: "Table foo only"
|
|
546
|
+
# )
|
|
547
|
+
#
|
|
548
|
+
# dataset.access do |access|
|
|
549
|
+
# access.add_writer_domain "example.com", condition: condition
|
|
550
|
+
# end
|
|
551
|
+
#
|
|
552
|
+
def add_writer_domain domain, condition: nil
|
|
553
|
+
add_access_role_scope_value :writer, :domain, domain, condition
|
|
386
554
|
end
|
|
387
555
|
|
|
388
556
|
##
|
|
@@ -402,13 +570,20 @@ module Google
|
|
|
402
570
|
# end
|
|
403
571
|
#
|
|
404
572
|
def add_writer_special group
|
|
405
|
-
add_access_role_scope_value :writer, :special, group
|
|
573
|
+
add_access_role_scope_value :writer, :special, group, nil
|
|
406
574
|
end
|
|
407
575
|
|
|
408
576
|
##
|
|
409
577
|
# Add owner access to a user.
|
|
410
578
|
#
|
|
411
579
|
# @param [String] email The email address for the entity.
|
|
580
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
581
|
+
# optional condition for the access rule. A condition is a CEL
|
|
582
|
+
# expression that is evaluated to determine if the access rule
|
|
583
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
584
|
+
# more information. To specify a condition, the
|
|
585
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
586
|
+
# represents an absence of a condition. The default is `nil`.
|
|
412
587
|
#
|
|
413
588
|
# @example
|
|
414
589
|
# require "google/cloud/bigquery"
|
|
@@ -420,14 +595,35 @@ module Google
|
|
|
420
595
|
# access.add_owner_user "entity@example.com"
|
|
421
596
|
# end
|
|
422
597
|
#
|
|
423
|
-
|
|
424
|
-
|
|
598
|
+
# @example With a condition:
|
|
599
|
+
# require "google/cloud/bigquery"
|
|
600
|
+
#
|
|
601
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
602
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
603
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
604
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
605
|
+
# title: "Table foo only"
|
|
606
|
+
# )
|
|
607
|
+
#
|
|
608
|
+
# dataset.access do |access|
|
|
609
|
+
# access.add_owner_user "entity@example.com", condition: condition
|
|
610
|
+
# end
|
|
611
|
+
#
|
|
612
|
+
def add_owner_user email, condition: nil
|
|
613
|
+
add_access_role_scope_value :owner, :user, email, condition
|
|
425
614
|
end
|
|
426
615
|
|
|
427
616
|
##
|
|
428
617
|
# Add owner access to a group.
|
|
429
618
|
#
|
|
430
619
|
# @param [String] email The email address for the entity.
|
|
620
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
621
|
+
# optional condition for the access rule. A condition is a CEL
|
|
622
|
+
# expression that is evaluated to determine if the access rule
|
|
623
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
624
|
+
# more information. To specify a condition, the
|
|
625
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
626
|
+
# represents an absence of a condition. The default is `nil`.
|
|
431
627
|
#
|
|
432
628
|
# @example
|
|
433
629
|
# require "google/cloud/bigquery"
|
|
@@ -439,8 +635,22 @@ module Google
|
|
|
439
635
|
# access.add_owner_group "entity@example.com"
|
|
440
636
|
# end
|
|
441
637
|
#
|
|
442
|
-
|
|
443
|
-
|
|
638
|
+
# @example With a condition:
|
|
639
|
+
# require "google/cloud/bigquery"
|
|
640
|
+
#
|
|
641
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
642
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
643
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
644
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
645
|
+
# title: "Table foo only"
|
|
646
|
+
# )
|
|
647
|
+
#
|
|
648
|
+
# dataset.access do |access|
|
|
649
|
+
# access.add_owner_group "entity@example.com", condition: condition
|
|
650
|
+
# end
|
|
651
|
+
#
|
|
652
|
+
def add_owner_group email, condition: nil
|
|
653
|
+
add_access_role_scope_value :owner, :group, email, condition
|
|
444
654
|
end
|
|
445
655
|
|
|
446
656
|
##
|
|
@@ -448,6 +658,13 @@ module Google
|
|
|
448
658
|
# Policy but isn't a user, group, domain, or special group.
|
|
449
659
|
#
|
|
450
660
|
# @param [String] identity The identity reference.
|
|
661
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
662
|
+
# optional condition for the access rule. A condition is a CEL
|
|
663
|
+
# expression that is evaluated to determine if the access rule
|
|
664
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
665
|
+
# more information. To specify a condition, the
|
|
666
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
667
|
+
# represents an absence of a condition. The default is `nil`.
|
|
451
668
|
#
|
|
452
669
|
# @example
|
|
453
670
|
# require "google/cloud/bigquery"
|
|
@@ -459,8 +676,22 @@ module Google
|
|
|
459
676
|
# access.add_owner_iam_member "entity@example.com"
|
|
460
677
|
# end
|
|
461
678
|
#
|
|
462
|
-
|
|
463
|
-
|
|
679
|
+
# @example With a condition:
|
|
680
|
+
# require "google/cloud/bigquery"
|
|
681
|
+
#
|
|
682
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
683
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
684
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
685
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
686
|
+
# title: "Table foo only"
|
|
687
|
+
# )
|
|
688
|
+
#
|
|
689
|
+
# dataset.access do |access|
|
|
690
|
+
# access.add_owner_iam_member "entity@example.com", condition: condition
|
|
691
|
+
# end
|
|
692
|
+
#
|
|
693
|
+
def add_owner_iam_member identity, condition: nil
|
|
694
|
+
add_access_role_scope_value :owner, :iam_member, identity, condition
|
|
464
695
|
end
|
|
465
696
|
|
|
466
697
|
##
|
|
@@ -468,6 +699,13 @@ module Google
|
|
|
468
699
|
#
|
|
469
700
|
# @param [String] domain A [Cloud Identity
|
|
470
701
|
# domain](https://cloud.google.com/iam/docs/overview#cloudid_name_domain).
|
|
702
|
+
# @param [Google::Cloud::Bigquery::Condition, nil] condition An
|
|
703
|
+
# optional condition for the access rule. A condition is a CEL
|
|
704
|
+
# expression that is evaluated to determine if the access rule
|
|
705
|
+
# should be applied. See {Google::Cloud::Bigquery::Condition} for
|
|
706
|
+
# more information. To specify a condition, the
|
|
707
|
+
# `access_policy_version` on the dataset must be set to `3`. `nil`
|
|
708
|
+
# represents an absence of a condition. The default is `nil`.
|
|
471
709
|
#
|
|
472
710
|
# @example
|
|
473
711
|
# require "google/cloud/bigquery"
|
|
@@ -479,8 +717,22 @@ module Google
|
|
|
479
717
|
# access.add_owner_domain "example.com"
|
|
480
718
|
# end
|
|
481
719
|
#
|
|
482
|
-
|
|
483
|
-
|
|
720
|
+
# @example With a condition:
|
|
721
|
+
# require "google/cloud/bigquery"
|
|
722
|
+
#
|
|
723
|
+
# bigquery = Google::Cloud::Bigquery.new
|
|
724
|
+
# dataset = bigquery.dataset "my_dataset"
|
|
725
|
+
# condition = Google::Cloud::Bigquery::Condition.new(
|
|
726
|
+
# "resource.name.startsWith(\"projects/my-project/datasets/my_dataset/tables/foo\")",
|
|
727
|
+
# title: "Table foo only"
|
|
728
|
+
# )
|
|
729
|
+
#
|
|
730
|
+
# dataset.access do |access|
|
|
731
|
+
# access.add_owner_domain "example.com", condition: condition
|
|
732
|
+
# end
|
|
733
|
+
#
|
|
734
|
+
def add_owner_domain domain, condition: nil
|
|
735
|
+
add_access_role_scope_value :owner, :domain, domain, condition
|
|
484
736
|
end
|
|
485
737
|
|
|
486
738
|
##
|
|
@@ -500,7 +752,7 @@ module Google
|
|
|
500
752
|
# end
|
|
501
753
|
#
|
|
502
754
|
def add_owner_special group
|
|
503
|
-
add_access_role_scope_value :owner, :special, group
|
|
755
|
+
add_access_role_scope_value :owner, :special, group, nil
|
|
504
756
|
end
|
|
505
757
|
|
|
506
758
|
##
|
|
@@ -1309,7 +1561,7 @@ module Google
|
|
|
1309
1561
|
end
|
|
1310
1562
|
|
|
1311
1563
|
# @private
|
|
1312
|
-
def add_access_role_scope_value role, scope, value
|
|
1564
|
+
def add_access_role_scope_value role, scope, value, condition
|
|
1313
1565
|
role = validate_role role
|
|
1314
1566
|
scope = validate_scope scope
|
|
1315
1567
|
# If scope is special group, make sure value is in the list
|
|
@@ -1318,6 +1570,7 @@ module Google
|
|
|
1318
1570
|
@rules.reject!(&find_by_scope_and_value(scope, value))
|
|
1319
1571
|
# Add new rule for this role, scope, and value
|
|
1320
1572
|
opts = { role: role, scope => value }
|
|
1573
|
+
opts[:condition] = condition.to_gapi unless condition.nil?
|
|
1321
1574
|
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(**opts)
|
|
1322
1575
|
end
|
|
1323
1576
|
|
|
@@ -59,12 +59,17 @@ module Google
|
|
|
59
59
|
# @private A Google API Client Dataset Reference object.
|
|
60
60
|
attr_reader :reference
|
|
61
61
|
|
|
62
|
+
##
|
|
63
|
+
# @private Access Policy Version for get, update, patch, and insert API calls
|
|
64
|
+
attr_accessor :access_policy_version
|
|
65
|
+
|
|
62
66
|
##
|
|
63
67
|
# @private Create an empty Dataset object.
|
|
64
68
|
def initialize
|
|
65
69
|
@service = nil
|
|
66
70
|
@gapi = nil
|
|
67
71
|
@reference = nil
|
|
72
|
+
@access_policy_version = nil
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
##
|
|
@@ -1710,6 +1715,8 @@ module Google
|
|
|
1710
1715
|
# `flatten` is false. Optional. The default value is false.
|
|
1711
1716
|
# @param [String] session_id The ID of an existing session. See the
|
|
1712
1717
|
# `create_session` param in {#query_job} and {Job#session_id}.
|
|
1718
|
+
# @param [Boolean] format_options_use_int64_timestamp Output timestamp
|
|
1719
|
+
# as usec int64. Default is true.
|
|
1713
1720
|
# @yield [job] a job configuration object
|
|
1714
1721
|
# @yieldparam [Google::Cloud::Bigquery::QueryJob::Updater] job a job
|
|
1715
1722
|
# configuration object for setting additional options for the query.
|
|
@@ -1864,6 +1871,7 @@ module Google
|
|
|
1864
1871
|
standard_sql: nil,
|
|
1865
1872
|
legacy_sql: nil,
|
|
1866
1873
|
session_id: nil,
|
|
1874
|
+
format_options_use_int64_timestamp: true,
|
|
1867
1875
|
&block
|
|
1868
1876
|
job = query_job query,
|
|
1869
1877
|
params: params,
|
|
@@ -1877,7 +1885,7 @@ module Google
|
|
|
1877
1885
|
job.wait_until_done!
|
|
1878
1886
|
ensure_job_succeeded! job
|
|
1879
1887
|
|
|
1880
|
-
job.data max: max
|
|
1888
|
+
job.data max: max, format_options_use_int64_timestamp: format_options_use_int64_timestamp
|
|
1881
1889
|
end
|
|
1882
1890
|
|
|
1883
1891
|
##
|
|
@@ -2444,7 +2452,7 @@ module Google
|
|
|
2444
2452
|
#
|
|
2445
2453
|
def reload!
|
|
2446
2454
|
ensure_service!
|
|
2447
|
-
@gapi = service.get_project_dataset project_id, dataset_id
|
|
2455
|
+
@gapi = service.get_project_dataset project_id, dataset_id, access_policy_version: @access_policy_version
|
|
2448
2456
|
@reference = nil
|
|
2449
2457
|
@exists = nil
|
|
2450
2458
|
self
|
|
@@ -2573,10 +2581,11 @@ module Google
|
|
|
2573
2581
|
|
|
2574
2582
|
##
|
|
2575
2583
|
# @private New Dataset from a Google API Client object.
|
|
2576
|
-
def self.from_gapi gapi, conn
|
|
2584
|
+
def self.from_gapi gapi, conn, access_policy_version: nil
|
|
2577
2585
|
new.tap do |f|
|
|
2578
2586
|
f.gapi = gapi
|
|
2579
2587
|
f.service = conn
|
|
2588
|
+
f.access_policy_version = access_policy_version
|
|
2580
2589
|
end
|
|
2581
2590
|
end
|
|
2582
2591
|
|
|
@@ -2900,7 +2909,7 @@ module Google
|
|
|
2900
2909
|
patch_args = attributes.to_h { |attr| [attr, @gapi.send(attr)] }
|
|
2901
2910
|
patch_gapi = Google::Apis::BigqueryV2::Dataset.new(**patch_args)
|
|
2902
2911
|
patch_gapi.etag = etag if etag
|
|
2903
|
-
@gapi = service.patch_dataset dataset_id, patch_gapi
|
|
2912
|
+
@gapi = service.patch_dataset dataset_id, patch_gapi, access_policy_version: @access_policy_version
|
|
2904
2913
|
end
|
|
2905
2914
|
|
|
2906
2915
|
##
|