google-cloud-bigquery 1.23.0 → 1.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +62 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/google/cloud/bigquery/dataset.rb +97 -10
- data/lib/google/cloud/bigquery/dataset/access.rb +293 -16
- data/lib/google/cloud/bigquery/external.rb +328 -3
- data/lib/google/cloud/bigquery/extract_job.rb +4 -8
- data/lib/google/cloud/bigquery/job.rb +35 -1
- data/lib/google/cloud/bigquery/load_job.rb +182 -28
- data/lib/google/cloud/bigquery/policy.rb +431 -0
- data/lib/google/cloud/bigquery/project.rb +1 -2
- data/lib/google/cloud/bigquery/query_job.rb +9 -6
- data/lib/google/cloud/bigquery/routine.rb +127 -5
- data/lib/google/cloud/bigquery/service.rb +35 -0
- data/lib/google/cloud/bigquery/table.rb +257 -41
- data/lib/google/cloud/bigquery/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44443c8c7fdf80fdfc611bba7ffcad2469ef60ff3aef8899f56a07fb4ced8555
|
4
|
+
data.tar.gz: 3b3f3020b6c4eebfa1a2a974f6d047068bd5d7f114b5d8c843c31401108b15b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fb27c2d28ebb83a3f28a11241b7b260373dceade40159df44e31d6ab5de016079a00ddeba6943a09a6c7f8d303d08a24ca665160cd480b95f314382c2e45943
|
7
|
+
data.tar.gz: cf98a8d90c55cf065265c094a74ccf9f421a89e1c459b05189d4a7b33c8d97c9304c0e7256729de190a9bc7f74195fd6cff9170748cfb3bc4732a297f902b320
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,67 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.28.0 / 2021-03-09
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Add Materialized View support
|
8
|
+
* Add Dataset#create_materialized_view
|
9
|
+
* Add Table#materialized_view?
|
10
|
+
* Add Table#enable_refresh?
|
11
|
+
* Add Table#enable_refresh=
|
12
|
+
* Add Table#last_refresh_time
|
13
|
+
* Add Table#refresh_interval_ms
|
14
|
+
* Add Table#refresh_interval_ms=
|
15
|
+
|
16
|
+
### 1.27.0 / 2021-02-10
|
17
|
+
|
18
|
+
#### Features
|
19
|
+
|
20
|
+
* Add Job#reservation_usage
|
21
|
+
* Add Routine#determinism_level
|
22
|
+
* Add Routine#determinism_level
|
23
|
+
* Add Routine#determinism_level=
|
24
|
+
* Add Routine#determinism_level_deterministic?
|
25
|
+
* Add Routine#determinism_level_not_deterministic?
|
26
|
+
* Add Routine::Updater#determinism_level=
|
27
|
+
|
28
|
+
### 1.26.0 / 2021-01-13
|
29
|
+
|
30
|
+
#### Features
|
31
|
+
|
32
|
+
* Add support for Hive Partitioning
|
33
|
+
* Add hive partitioning options to External::DataSource
|
34
|
+
* Add hive partitioning options to LoadJob and LoadJob::Updater
|
35
|
+
* Replace google-api-client with google-apis-bigquery_v2
|
36
|
+
|
37
|
+
### 1.25.0 / 2020-11-16
|
38
|
+
|
39
|
+
#### Features
|
40
|
+
|
41
|
+
* Add routine (UDF) to Dataset::Access
|
42
|
+
* Add support for Table ACLS (IAM Policy)
|
43
|
+
* feat(bigquery): Add support for Table ACLS
|
44
|
+
* Add Bigquery::Policy
|
45
|
+
* Add Table#policy
|
46
|
+
* Add Table#test_iam_permissions
|
47
|
+
* Add Table#update_policy
|
48
|
+
|
49
|
+
### 1.24.0 / 2020-10-29
|
50
|
+
|
51
|
+
#### Features
|
52
|
+
|
53
|
+
* Add iamMember to Dataset::Access
|
54
|
+
|
55
|
+
#### Bug Fixes
|
56
|
+
|
57
|
+
* Ensure dense encoding of JSON responses
|
58
|
+
* Set query param prettyPrint=false for all requests.
|
59
|
+
* Upgrade google-api-client to ~> 0.47
|
60
|
+
|
61
|
+
#### Documentation
|
62
|
+
|
63
|
+
* Update supported types for time partition type
|
64
|
+
|
3
65
|
### 1.23.0 / 2020-09-17
|
4
66
|
|
5
67
|
#### Features
|
data/CONTRIBUTING.md
CHANGED
@@ -618,15 +618,17 @@ module Google
|
|
618
618
|
end
|
619
619
|
|
620
620
|
##
|
621
|
-
# Creates a new
|
622
|
-
# table, which is a virtual table defined by the given SQL query.
|
621
|
+
# Creates a new view, which is a virtual table defined by the given SQL query.
|
623
622
|
#
|
624
|
-
# BigQuery's
|
625
|
-
#
|
626
|
-
# the view is queried. Queries are billed according to the total amount
|
623
|
+
# With BigQuery's logical views, the query that defines the view is re-executed
|
624
|
+
# every time the view is queried. Queries are billed according to the total amount
|
627
625
|
# of data in all table fields referenced directly or indirectly by the
|
628
626
|
# top-level query. (See {Table#view?} and {Table#query}.)
|
629
627
|
#
|
628
|
+
# For materialized views, see {#create_materialized_view}.
|
629
|
+
#
|
630
|
+
# @see https://cloud.google.com/bigquery/docs/views Creating views
|
631
|
+
#
|
630
632
|
# @param [String] table_id The ID of the view table. The ID must contain
|
631
633
|
# only letters (a-z, A-Z), numbers (0-9), or underscores (_). The
|
632
634
|
# maximum length is 1,024 characters.
|
@@ -667,7 +669,7 @@ module Google
|
|
667
669
|
# dataset = bigquery.dataset "my_dataset"
|
668
670
|
#
|
669
671
|
# view = dataset.create_view "my_view",
|
670
|
-
#
|
672
|
+
# "SELECT name, age FROM proj.dataset.users"
|
671
673
|
#
|
672
674
|
# @example A name and description can be provided:
|
673
675
|
# require "google/cloud/bigquery"
|
@@ -676,13 +678,18 @@ module Google
|
|
676
678
|
# dataset = bigquery.dataset "my_dataset"
|
677
679
|
#
|
678
680
|
# view = dataset.create_view "my_view",
|
679
|
-
#
|
680
|
-
#
|
681
|
+
# "SELECT name, age FROM proj.dataset.users",
|
682
|
+
# name: "My View", description: "This is my view"
|
681
683
|
#
|
682
684
|
# @!group Table
|
683
685
|
#
|
684
|
-
def create_view table_id,
|
685
|
-
|
686
|
+
def create_view table_id,
|
687
|
+
query,
|
688
|
+
name: nil,
|
689
|
+
description: nil,
|
690
|
+
standard_sql: nil,
|
691
|
+
legacy_sql: nil,
|
692
|
+
udfs: nil
|
686
693
|
use_legacy_sql = Convert.resolve_legacy_sql standard_sql, legacy_sql
|
687
694
|
new_view_opts = {
|
688
695
|
table_reference: Google::Apis::BigqueryV2::TableReference.new(
|
@@ -704,6 +711,80 @@ module Google
|
|
704
711
|
Table.from_gapi gapi, service
|
705
712
|
end
|
706
713
|
|
714
|
+
##
|
715
|
+
# Creates a new materialized view.
|
716
|
+
#
|
717
|
+
# Materialized views are precomputed views that periodically cache results of a query for increased performance
|
718
|
+
# and efficiency. BigQuery leverages precomputed results from materialized views and whenever possible reads
|
719
|
+
# only delta changes from the base table to compute up-to-date results.
|
720
|
+
#
|
721
|
+
# Queries that use materialized views are generally faster and consume less resources than queries that retrieve
|
722
|
+
# the same data only from the base table. Materialized views are helpful to significantly boost performance of
|
723
|
+
# workloads that have the characteristic of common and repeated queries.
|
724
|
+
#
|
725
|
+
# For logical views, see {#create_view}.
|
726
|
+
#
|
727
|
+
# @see https://cloud.google.com/bigquery/docs/materialized-views-intro Introduction to materialized views
|
728
|
+
#
|
729
|
+
# @param [String] table_id The ID of the materialized view table. The ID must contain only letters (a-z, A-Z),
|
730
|
+
# numbers (0-9), or underscores (_). The maximum length is 1,024 characters.
|
731
|
+
# @param [String] query The query that BigQuery executes when the materialized view is referenced.
|
732
|
+
# @param [String] name A descriptive name for the table.
|
733
|
+
# @param [String] description A user-friendly description of the table.
|
734
|
+
# @param [Boolean] enable_refresh Enable automatic refresh of the materialized view when the base table is
|
735
|
+
# updated. Optional. The default value is true.
|
736
|
+
# @param [Integer] refresh_interval_ms The maximum frequency in milliseconds at which this materialized view
|
737
|
+
# will be refreshed. Optional. The default value is `1_800_000` (30 minutes).
|
738
|
+
#
|
739
|
+
# @return [Google::Cloud::Bigquery::Table] A new table object.
|
740
|
+
#
|
741
|
+
# @example
|
742
|
+
# require "google/cloud/bigquery"
|
743
|
+
#
|
744
|
+
# bigquery = Google::Cloud::Bigquery.new
|
745
|
+
# dataset = bigquery.dataset "my_dataset"
|
746
|
+
#
|
747
|
+
# materialized_view = dataset.create_materialized_view "my_materialized_view",
|
748
|
+
# "SELECT name, age FROM proj.dataset.users"
|
749
|
+
#
|
750
|
+
# @example Automatic refresh can be disabled:
|
751
|
+
# require "google/cloud/bigquery"
|
752
|
+
#
|
753
|
+
# bigquery = Google::Cloud::Bigquery.new
|
754
|
+
# dataset = bigquery.dataset "my_dataset"
|
755
|
+
#
|
756
|
+
# materialized_view = dataset.create_materialized_view "my_materialized_view",
|
757
|
+
# "SELECT name, age FROM proj.dataset.users",
|
758
|
+
# enable_refresh: false
|
759
|
+
#
|
760
|
+
# @!group Table
|
761
|
+
#
|
762
|
+
def create_materialized_view table_id,
|
763
|
+
query,
|
764
|
+
name: nil,
|
765
|
+
description: nil,
|
766
|
+
enable_refresh: nil,
|
767
|
+
refresh_interval_ms: nil
|
768
|
+
new_view_opts = {
|
769
|
+
table_reference: Google::Apis::BigqueryV2::TableReference.new(
|
770
|
+
project_id: project_id,
|
771
|
+
dataset_id: dataset_id,
|
772
|
+
table_id: table_id
|
773
|
+
),
|
774
|
+
friendly_name: name,
|
775
|
+
description: description,
|
776
|
+
materialized_view: Google::Apis::BigqueryV2::MaterializedViewDefinition.new(
|
777
|
+
enable_refresh: enable_refresh,
|
778
|
+
query: query,
|
779
|
+
refresh_interval_ms: refresh_interval_ms
|
780
|
+
)
|
781
|
+
}.delete_if { |_, v| v.nil? }
|
782
|
+
new_view = Google::Apis::BigqueryV2::Table.new new_view_opts
|
783
|
+
|
784
|
+
gapi = service.insert_table dataset_id, new_view
|
785
|
+
Table.from_gapi gapi, service
|
786
|
+
end
|
787
|
+
|
707
788
|
##
|
708
789
|
# Retrieves an existing table by ID.
|
709
790
|
#
|
@@ -2756,6 +2837,12 @@ module Google
|
|
2756
2837
|
raise "not implemented in #{self.class}"
|
2757
2838
|
end
|
2758
2839
|
|
2840
|
+
##
|
2841
|
+
# @raise [RuntimeError] not implemented
|
2842
|
+
def create_materialized_view(*)
|
2843
|
+
raise "not implemented in #{self.class}"
|
2844
|
+
end
|
2845
|
+
|
2759
2846
|
##
|
2760
2847
|
# @raise [RuntimeError] not implemented
|
2761
2848
|
def table(*)
|
@@ -48,16 +48,19 @@ module Google
|
|
48
48
|
|
49
49
|
# @private
|
50
50
|
SCOPES = {
|
51
|
-
"
|
52
|
-
"user_by_email" => :user_by_email,
|
53
|
-
"userByEmail" => :user_by_email,
|
51
|
+
"domain" => :domain,
|
54
52
|
"group" => :group_by_email,
|
55
53
|
"group_by_email" => :group_by_email,
|
56
54
|
"groupByEmail" => :group_by_email,
|
57
|
-
"
|
55
|
+
"iam_member" => :iam_member,
|
56
|
+
"iamMember" => :iam_member,
|
57
|
+
"routine" => :routine,
|
58
58
|
"special" => :special_group,
|
59
59
|
"special_group" => :special_group,
|
60
60
|
"specialGroup" => :special_group,
|
61
|
+
"user" => :user_by_email,
|
62
|
+
"user_by_email" => :user_by_email,
|
63
|
+
"userByEmail" => :user_by_email,
|
61
64
|
"view" => :view
|
62
65
|
}.freeze
|
63
66
|
|
@@ -150,6 +153,26 @@ module Google
|
|
150
153
|
add_access_role_scope_value :reader, :group, email
|
151
154
|
end
|
152
155
|
|
156
|
+
##
|
157
|
+
# Add reader access to some other type of member that appears in the IAM
|
158
|
+
# Policy but isn't a user, group, domain, or special group.
|
159
|
+
#
|
160
|
+
# @param [String] identity The identity reference.
|
161
|
+
#
|
162
|
+
# @example
|
163
|
+
# require "google/cloud/bigquery"
|
164
|
+
#
|
165
|
+
# bigquery = Google::Cloud::Bigquery.new
|
166
|
+
# dataset = bigquery.dataset "my_dataset"
|
167
|
+
#
|
168
|
+
# dataset.access do |access|
|
169
|
+
# access.add_reader_iam_member "entity@example.com"
|
170
|
+
# end
|
171
|
+
#
|
172
|
+
def add_reader_iam_member identity
|
173
|
+
add_access_role_scope_value :reader, :iam_member, identity
|
174
|
+
end
|
175
|
+
|
153
176
|
##
|
154
177
|
# Add reader access to a domain.
|
155
178
|
#
|
@@ -190,6 +213,33 @@ module Google
|
|
190
213
|
add_access_role_scope_value :reader, :special, group
|
191
214
|
end
|
192
215
|
|
216
|
+
##
|
217
|
+
# Add access to a routine from a different dataset. Queries executed
|
218
|
+
# against that routine will have read access to views/tables/routines
|
219
|
+
# in this dataset. Only UDF is supported for now. The role field is
|
220
|
+
# not required when this field is set. If that routine is updated by
|
221
|
+
# any user, access to the routine needs to be granted again via an
|
222
|
+
# update operation.
|
223
|
+
#
|
224
|
+
# @param [Google::Cloud::Bigquery::Routine] routine A routine object.
|
225
|
+
#
|
226
|
+
# @example
|
227
|
+
# require "google/cloud/bigquery"
|
228
|
+
#
|
229
|
+
# bigquery = Google::Cloud::Bigquery.new
|
230
|
+
# dataset = bigquery.dataset "my_dataset"
|
231
|
+
# other_dataset = bigquery.dataset "my_other_dataset", skip_lookup: true
|
232
|
+
#
|
233
|
+
# routine = other_dataset.routine "my_routine"
|
234
|
+
#
|
235
|
+
# dataset.access do |access|
|
236
|
+
# access.add_reader_routine routine
|
237
|
+
# end
|
238
|
+
#
|
239
|
+
def add_reader_routine routine
|
240
|
+
add_access_routine routine
|
241
|
+
end
|
242
|
+
|
193
243
|
##
|
194
244
|
# Add reader access to a view.
|
195
245
|
#
|
@@ -205,9 +255,9 @@ module Google
|
|
205
255
|
#
|
206
256
|
# bigquery = Google::Cloud::Bigquery.new
|
207
257
|
# dataset = bigquery.dataset "my_dataset"
|
208
|
-
# other_dataset = bigquery.dataset "my_other_dataset"
|
258
|
+
# other_dataset = bigquery.dataset "my_other_dataset", skip_lookup: true
|
209
259
|
#
|
210
|
-
# view = other_dataset.table "my_view"
|
260
|
+
# view = other_dataset.table "my_view", skip_lookup: true
|
211
261
|
#
|
212
262
|
# dataset.access do |access|
|
213
263
|
# access.add_reader_view view
|
@@ -255,6 +305,26 @@ module Google
|
|
255
305
|
add_access_role_scope_value :writer, :group, email
|
256
306
|
end
|
257
307
|
|
308
|
+
##
|
309
|
+
# Add writer access to some other type of member that appears in the IAM
|
310
|
+
# Policy but isn't a user, group, domain, or special group.
|
311
|
+
#
|
312
|
+
# @param [String] identity The identity reference.
|
313
|
+
#
|
314
|
+
# @example
|
315
|
+
# require "google/cloud/bigquery"
|
316
|
+
#
|
317
|
+
# bigquery = Google::Cloud::Bigquery.new
|
318
|
+
# dataset = bigquery.dataset "my_dataset"
|
319
|
+
#
|
320
|
+
# dataset.access do |access|
|
321
|
+
# access.add_writer_iam_member "entity@example.com"
|
322
|
+
# end
|
323
|
+
#
|
324
|
+
def add_writer_iam_member identity
|
325
|
+
add_access_role_scope_value :writer, :iam_member, identity
|
326
|
+
end
|
327
|
+
|
258
328
|
##
|
259
329
|
# Add writer access to a domain.
|
260
330
|
#
|
@@ -333,6 +403,26 @@ module Google
|
|
333
403
|
add_access_role_scope_value :owner, :group, email
|
334
404
|
end
|
335
405
|
|
406
|
+
##
|
407
|
+
# Add owner access to some other type of member that appears in the IAM
|
408
|
+
# Policy but isn't a user, group, domain, or special group.
|
409
|
+
#
|
410
|
+
# @param [String] identity The identity reference.
|
411
|
+
#
|
412
|
+
# @example
|
413
|
+
# require "google/cloud/bigquery"
|
414
|
+
#
|
415
|
+
# bigquery = Google::Cloud::Bigquery.new
|
416
|
+
# dataset = bigquery.dataset "my_dataset"
|
417
|
+
#
|
418
|
+
# dataset.access do |access|
|
419
|
+
# access.add_owner_iam_member "entity@example.com"
|
420
|
+
# end
|
421
|
+
#
|
422
|
+
def add_owner_iam_member identity
|
423
|
+
add_access_role_scope_value :owner, :iam_member, identity
|
424
|
+
end
|
425
|
+
|
336
426
|
##
|
337
427
|
# Add owner access to a domain.
|
338
428
|
#
|
@@ -411,6 +501,26 @@ module Google
|
|
411
501
|
remove_access_role_scope_value :reader, :group, email
|
412
502
|
end
|
413
503
|
|
504
|
+
##
|
505
|
+
# Remove reader access from some other type of member that appears in the IAM
|
506
|
+
# Policy but isn't a user, group, domain, or special group.
|
507
|
+
#
|
508
|
+
# @param [String] identity The identity reference.
|
509
|
+
#
|
510
|
+
# @example
|
511
|
+
# require "google/cloud/bigquery"
|
512
|
+
#
|
513
|
+
# bigquery = Google::Cloud::Bigquery.new
|
514
|
+
# dataset = bigquery.dataset "my_dataset"
|
515
|
+
#
|
516
|
+
# dataset.access do |access|
|
517
|
+
# access.remove_reader_iam_member "entity@example.com"
|
518
|
+
# end
|
519
|
+
#
|
520
|
+
def remove_reader_iam_member identity
|
521
|
+
remove_access_role_scope_value :reader, :iam_member, identity
|
522
|
+
end
|
523
|
+
|
414
524
|
##
|
415
525
|
# Remove reader access from a domain.
|
416
526
|
#
|
@@ -451,6 +561,28 @@ module Google
|
|
451
561
|
remove_access_role_scope_value :reader, :special, group
|
452
562
|
end
|
453
563
|
|
564
|
+
##
|
565
|
+
# Remove reader access from a routine from a different dataset.
|
566
|
+
#
|
567
|
+
# @param [Google::Cloud::Bigquery::Routine] routine A routine object.
|
568
|
+
#
|
569
|
+
# @example
|
570
|
+
# require "google/cloud/bigquery"
|
571
|
+
#
|
572
|
+
# bigquery = Google::Cloud::Bigquery.new
|
573
|
+
# dataset = bigquery.dataset "my_dataset"
|
574
|
+
# other_dataset = bigquery.dataset "my_other_dataset", skip_lookup: true
|
575
|
+
#
|
576
|
+
# routine = other_dataset.routine "my_routine", skip_lookup: true
|
577
|
+
#
|
578
|
+
# dataset.access do |access|
|
579
|
+
# access.remove_reader_routine routine
|
580
|
+
# end
|
581
|
+
#
|
582
|
+
def remove_reader_routine routine
|
583
|
+
remove_access_routine routine
|
584
|
+
end
|
585
|
+
|
454
586
|
##
|
455
587
|
# Remove reader access from a view.
|
456
588
|
#
|
@@ -466,9 +598,9 @@ module Google
|
|
466
598
|
#
|
467
599
|
# bigquery = Google::Cloud::Bigquery.new
|
468
600
|
# dataset = bigquery.dataset "my_dataset"
|
469
|
-
# other_dataset = bigquery.dataset "my_other_dataset"
|
601
|
+
# other_dataset = bigquery.dataset "my_other_dataset", skip_lookup: true
|
470
602
|
#
|
471
|
-
# view = other_dataset.table "my_view"
|
603
|
+
# view = other_dataset.table "my_view", skip_lookup: true
|
472
604
|
#
|
473
605
|
# dataset.access do |access|
|
474
606
|
# access.remove_reader_view view
|
@@ -516,6 +648,26 @@ module Google
|
|
516
648
|
remove_access_role_scope_value :writer, :group, email
|
517
649
|
end
|
518
650
|
|
651
|
+
##
|
652
|
+
# Remove writer access from some other type of member that appears in the IAM
|
653
|
+
# Policy but isn't a user, group, domain, or special group.
|
654
|
+
#
|
655
|
+
# @param [String] identity The identity reference.
|
656
|
+
#
|
657
|
+
# @example
|
658
|
+
# require "google/cloud/bigquery"
|
659
|
+
#
|
660
|
+
# bigquery = Google::Cloud::Bigquery.new
|
661
|
+
# dataset = bigquery.dataset "my_dataset"
|
662
|
+
#
|
663
|
+
# dataset.access do |access|
|
664
|
+
# access.remove_writer_iam_member "entity@example.com"
|
665
|
+
# end
|
666
|
+
#
|
667
|
+
def remove_writer_iam_member identity
|
668
|
+
remove_access_role_scope_value :writer, :iam_member, identity
|
669
|
+
end
|
670
|
+
|
519
671
|
##
|
520
672
|
# Remove writer access from a domain.
|
521
673
|
#
|
@@ -594,6 +746,26 @@ module Google
|
|
594
746
|
remove_access_role_scope_value :owner, :group, email
|
595
747
|
end
|
596
748
|
|
749
|
+
##
|
750
|
+
# Remove owner access from some other type of member that appears in the IAM
|
751
|
+
# Policy but isn't a user, group, domain, or special group.
|
752
|
+
#
|
753
|
+
# @param [String] identity The identity reference.
|
754
|
+
#
|
755
|
+
# @example
|
756
|
+
# require "google/cloud/bigquery"
|
757
|
+
#
|
758
|
+
# bigquery = Google::Cloud::Bigquery.new
|
759
|
+
# dataset = bigquery.dataset "my_dataset"
|
760
|
+
#
|
761
|
+
# dataset.access do |access|
|
762
|
+
# access.remove_owner_iam_member "entity@example.com"
|
763
|
+
# end
|
764
|
+
#
|
765
|
+
def remove_owner_iam_member identity
|
766
|
+
remove_access_role_scope_value :owner, :iam_member, identity
|
767
|
+
end
|
768
|
+
|
597
769
|
##
|
598
770
|
# Remove owner access from a domain.
|
599
771
|
#
|
@@ -670,6 +842,25 @@ module Google
|
|
670
842
|
lookup_access_role_scope_value :reader, :group, email
|
671
843
|
end
|
672
844
|
|
845
|
+
##
|
846
|
+
# Checks reader access for some other type of member that appears in the IAM
|
847
|
+
# Policy but isn't a user, group, domain, or special group.
|
848
|
+
#
|
849
|
+
# @param [String] identity The identity reference.
|
850
|
+
#
|
851
|
+
# @example
|
852
|
+
# require "google/cloud/bigquery"
|
853
|
+
#
|
854
|
+
# bigquery = Google::Cloud::Bigquery.new
|
855
|
+
# dataset = bigquery.dataset "my_dataset"
|
856
|
+
#
|
857
|
+
# access = dataset.access
|
858
|
+
# access.reader_iam_member? "entity@example.com" #=> false
|
859
|
+
#
|
860
|
+
def reader_iam_member? identity
|
861
|
+
lookup_access_role_scope_value :reader, :iam_member, identity
|
862
|
+
end
|
863
|
+
|
673
864
|
##
|
674
865
|
# Checks reader access for a domain.
|
675
866
|
#
|
@@ -708,6 +899,32 @@ module Google
|
|
708
899
|
lookup_access_role_scope_value :reader, :special, group
|
709
900
|
end
|
710
901
|
|
902
|
+
##
|
903
|
+
# Checks access for a routine from a different dataset. Queries executed
|
904
|
+
# against that routine will have read access to views/tables/routines
|
905
|
+
# in this dataset. Only UDF is supported for now. The role field is
|
906
|
+
# not required when this field is set. If that routine is updated by
|
907
|
+
# any user, access to the routine needs to be granted again via an
|
908
|
+
# update operation.
|
909
|
+
#
|
910
|
+
# @param [Google::Cloud::Bigquery::Routine] routine A routine object.
|
911
|
+
#
|
912
|
+
# @example
|
913
|
+
# require "google/cloud/bigquery"
|
914
|
+
#
|
915
|
+
# bigquery = Google::Cloud::Bigquery.new
|
916
|
+
# dataset = bigquery.dataset "my_dataset"
|
917
|
+
# other_dataset = bigquery.dataset "my_other_dataset", skip_lookup: true
|
918
|
+
#
|
919
|
+
# routine = other_dataset.routine "my_routine", skip_lookup: true
|
920
|
+
#
|
921
|
+
# access = dataset.access
|
922
|
+
# access.reader_routine? routine #=> false
|
923
|
+
#
|
924
|
+
def reader_routine? routine
|
925
|
+
lookup_access_routine routine
|
926
|
+
end
|
927
|
+
|
711
928
|
##
|
712
929
|
# Checks reader access for a view.
|
713
930
|
#
|
@@ -723,9 +940,9 @@ module Google
|
|
723
940
|
#
|
724
941
|
# bigquery = Google::Cloud::Bigquery.new
|
725
942
|
# dataset = bigquery.dataset "my_dataset"
|
726
|
-
# other_dataset = bigquery.dataset "my_other_dataset"
|
943
|
+
# other_dataset = bigquery.dataset "my_other_dataset", skip_lookup: true
|
727
944
|
#
|
728
|
-
# view = other_dataset.table "my_view"
|
945
|
+
# view = other_dataset.table "my_view", skip_lookup: true
|
729
946
|
#
|
730
947
|
# access = dataset.access
|
731
948
|
# access.reader_view? view #=> false
|
@@ -770,6 +987,25 @@ module Google
|
|
770
987
|
lookup_access_role_scope_value :writer, :group, email
|
771
988
|
end
|
772
989
|
|
990
|
+
##
|
991
|
+
# Checks writer access for some other type of member that appears in the IAM
|
992
|
+
# Policy but isn't a user, group, domain, or special group.
|
993
|
+
#
|
994
|
+
# @param [String] identity The identity reference.
|
995
|
+
#
|
996
|
+
# @example
|
997
|
+
# require "google/cloud/bigquery"
|
998
|
+
#
|
999
|
+
# bigquery = Google::Cloud::Bigquery.new
|
1000
|
+
# dataset = bigquery.dataset "my_dataset"
|
1001
|
+
#
|
1002
|
+
# access = dataset.access
|
1003
|
+
# access.writer_iam_member? "entity@example.com" #=> false
|
1004
|
+
#
|
1005
|
+
def writer_iam_member? identity
|
1006
|
+
lookup_access_role_scope_value :writer, :iam_member, identity
|
1007
|
+
end
|
1008
|
+
|
773
1009
|
##
|
774
1010
|
# Checks writer access for a domain.
|
775
1011
|
#
|
@@ -844,6 +1080,25 @@ module Google
|
|
844
1080
|
lookup_access_role_scope_value :owner, :group, email
|
845
1081
|
end
|
846
1082
|
|
1083
|
+
##
|
1084
|
+
# Checks owner access for some other type of member that appears in the IAM
|
1085
|
+
# Policy but isn't a user, group, domain, or special group.
|
1086
|
+
#
|
1087
|
+
# @param [String] identity The identity reference.
|
1088
|
+
#
|
1089
|
+
# @example
|
1090
|
+
# require "google/cloud/bigquery"
|
1091
|
+
#
|
1092
|
+
# bigquery = Google::Cloud::Bigquery.new
|
1093
|
+
# dataset = bigquery.dataset "my_dataset"
|
1094
|
+
#
|
1095
|
+
# access = dataset.access
|
1096
|
+
# access.owner_iam_member? "entity@example.com" #=> false
|
1097
|
+
#
|
1098
|
+
def owner_iam_member? identity
|
1099
|
+
lookup_access_role_scope_value :owner, :iam_member, identity
|
1100
|
+
end
|
1101
|
+
|
847
1102
|
##
|
848
1103
|
# Checks owner access for a domain.
|
849
1104
|
#
|
@@ -942,12 +1197,22 @@ module Google
|
|
942
1197
|
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
943
1198
|
end
|
944
1199
|
|
1200
|
+
# @private
|
1201
|
+
def add_access_routine routine
|
1202
|
+
value = routine.routine_ref
|
1203
|
+
# Remove existing routine rule, if any
|
1204
|
+
@rules.reject!(&find_by_scope_and_resource_ref(:routine, value))
|
1205
|
+
# Add new rule for this role, scope, and value
|
1206
|
+
opts = { routine: value }
|
1207
|
+
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
1208
|
+
end
|
1209
|
+
|
945
1210
|
# @private
|
946
1211
|
def add_access_view value
|
947
1212
|
# scope is view, make sure value is in the right format
|
948
1213
|
value = validate_view value
|
949
1214
|
# Remove existing view rule, if any
|
950
|
-
@rules.reject!(&
|
1215
|
+
@rules.reject!(&find_by_scope_and_resource_ref(:view, value))
|
951
1216
|
# Add new rule for this role, scope, and value
|
952
1217
|
opts = { view: value }
|
953
1218
|
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
@@ -965,12 +1230,18 @@ module Google
|
|
965
1230
|
)
|
966
1231
|
end
|
967
1232
|
|
1233
|
+
# @private
|
1234
|
+
def remove_access_routine routine
|
1235
|
+
# Remove existing routine rule, if any
|
1236
|
+
@rules.reject!(&find_by_scope_and_resource_ref(:routine, routine.routine_ref))
|
1237
|
+
end
|
1238
|
+
|
968
1239
|
# @private
|
969
1240
|
def remove_access_view value
|
970
1241
|
# scope is view, make sure value is in the right format
|
971
1242
|
value = validate_view value
|
972
1243
|
# Remove existing view rule, if any
|
973
|
-
@rules.reject!(&
|
1244
|
+
@rules.reject!(&find_by_scope_and_resource_ref(:view, value))
|
974
1245
|
end
|
975
1246
|
|
976
1247
|
# @private
|
@@ -983,12 +1254,18 @@ module Google
|
|
983
1254
|
!(!@rules.detect(&find_by_role_and_scope_and_value(role, scope, value)))
|
984
1255
|
end
|
985
1256
|
|
1257
|
+
# @private
|
1258
|
+
def lookup_access_routine routine
|
1259
|
+
# Detect routine rule, if any
|
1260
|
+
!(!@rules.detect(&find_by_scope_and_resource_ref(:routine, routine.routine_ref)))
|
1261
|
+
end
|
1262
|
+
|
986
1263
|
# @private
|
987
1264
|
def lookup_access_view value
|
988
1265
|
# scope is view, make sure value is in the right format
|
989
1266
|
value = validate_view value
|
990
1267
|
# Detect view rule, if any
|
991
|
-
!(!@rules.detect(&
|
1268
|
+
!(!@rules.detect(&find_by_scope_and_resource_ref(:view, value)))
|
992
1269
|
end
|
993
1270
|
|
994
1271
|
# @private
|
@@ -1007,11 +1284,11 @@ module Google
|
|
1007
1284
|
end
|
1008
1285
|
end
|
1009
1286
|
|
1010
|
-
# @private
|
1011
|
-
def
|
1287
|
+
# @private Compare hash representations to find table_ref, routine_ref.
|
1288
|
+
def find_by_scope_and_resource_ref scope, value
|
1012
1289
|
lambda do |a|
|
1013
1290
|
h = a.to_h
|
1014
|
-
h[
|
1291
|
+
h[scope].to_h == value.to_h
|
1015
1292
|
end
|
1016
1293
|
end
|
1017
1294
|
end
|