google-cloud-bigquery 1.21.1 → 1.27.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 +72 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/google-cloud-bigquery.rb +9 -2
- data/lib/google/cloud/bigquery.rb +1 -1
- data/lib/google/cloud/bigquery/convert.rb +3 -1
- data/lib/google/cloud/bigquery/copy_job.rb +15 -6
- data/lib/google/cloud/bigquery/data.rb +12 -0
- data/lib/google/cloud/bigquery/dataset.rb +61 -20
- data/lib/google/cloud/bigquery/dataset/access.rb +293 -16
- data/lib/google/cloud/bigquery/external.rb +352 -3
- data/lib/google/cloud/bigquery/extract_job.rb +154 -50
- data/lib/google/cloud/bigquery/job.rb +35 -1
- data/lib/google/cloud/bigquery/load_job.rb +197 -34
- data/lib/google/cloud/bigquery/model.rb +164 -8
- data/lib/google/cloud/bigquery/policy.rb +431 -0
- data/lib/google/cloud/bigquery/project.rb +164 -68
- data/lib/google/cloud/bigquery/query_job.rb +27 -12
- data/lib/google/cloud/bigquery/routine.rb +127 -5
- data/lib/google/cloud/bigquery/service.rb +50 -11
- data/lib/google/cloud/bigquery/table.rb +181 -42
- data/lib/google/cloud/bigquery/time.rb +6 -0
- 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: 334d37be375f513da083f7338e1324413409a6c30554456c08290ed1337c2701
|
4
|
+
data.tar.gz: f21c7793b5a9f82d0c3840aa5915fd10ef43644ccc1d9ea996a63860fa8b16ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 187d0549552613c40f85001fdf82197db01af5b5e285dfd6f7615a64c62ed74807c0ea31ac560d2a1516dae0c91f14fcc08b143882fcf8437b8d7c964f256348
|
7
|
+
data.tar.gz: e6b80ed9ccff8ffb2f8537a009a6d41a7930ee080f50800001b0afa9f7706a85af58180d091051f34a2499d66ca15f5c084a74cbbff244d8c22d266fc62713db
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,77 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.27.0 / 2021-02-10
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Add Job#reservation_usage
|
8
|
+
* Add Routine#determinism_level
|
9
|
+
* Add Routine#determinism_level
|
10
|
+
* Add Routine#determinism_level=
|
11
|
+
* Add Routine#determinism_level_deterministic?
|
12
|
+
* Add Routine#determinism_level_not_deterministic?
|
13
|
+
* Add Routine::Updater#determinism_level=
|
14
|
+
|
15
|
+
### 1.26.0 / 2021-01-13
|
16
|
+
|
17
|
+
#### Features
|
18
|
+
|
19
|
+
* Add support for Hive Partitioning
|
20
|
+
* Add hive partitioning options to External::DataSource
|
21
|
+
* Add hive partitioning options to LoadJob and LoadJob::Updater
|
22
|
+
* Replace google-api-client with google-apis-bigquery_v2
|
23
|
+
|
24
|
+
### 1.25.0 / 2020-11-16
|
25
|
+
|
26
|
+
#### Features
|
27
|
+
|
28
|
+
* Add routine (UDF) to Dataset::Access
|
29
|
+
* Add support for Table ACLS (IAM Policy)
|
30
|
+
* feat(bigquery): Add support for Table ACLS
|
31
|
+
* Add Bigquery::Policy
|
32
|
+
* Add Table#policy
|
33
|
+
* Add Table#test_iam_permissions
|
34
|
+
* Add Table#update_policy
|
35
|
+
|
36
|
+
### 1.24.0 / 2020-10-29
|
37
|
+
|
38
|
+
#### Features
|
39
|
+
|
40
|
+
* Add iamMember to Dataset::Access
|
41
|
+
|
42
|
+
#### Bug Fixes
|
43
|
+
|
44
|
+
* Ensure dense encoding of JSON responses
|
45
|
+
* Set query param prettyPrint=false for all requests.
|
46
|
+
* Upgrade google-api-client to ~> 0.47
|
47
|
+
|
48
|
+
#### Documentation
|
49
|
+
|
50
|
+
* Update supported types for time partition type
|
51
|
+
|
52
|
+
### 1.23.0 / 2020-09-17
|
53
|
+
|
54
|
+
#### Features
|
55
|
+
|
56
|
+
* quota_project can be set via library configuration ([#7627](https://www.github.com/googleapis/google-cloud-ruby/issues/7627))
|
57
|
+
|
58
|
+
### 1.22.0 / 2020-09-10
|
59
|
+
|
60
|
+
#### Features
|
61
|
+
|
62
|
+
* Add support for ML model export
|
63
|
+
* Add model support to Project#extract and #extract_job
|
64
|
+
* Add ExtractJob#model?
|
65
|
+
* Add ExtractJob#ml_tf_saved_model?
|
66
|
+
* Add ExtractJob#ml_xgboost_booster?
|
67
|
+
* Add Model#extract and #extract_job
|
68
|
+
|
69
|
+
### 1.21.2 / 2020-07-21
|
70
|
+
|
71
|
+
#### Documentation
|
72
|
+
|
73
|
+
* Update Data#each samples
|
74
|
+
|
3
75
|
### 1.21.1 / 2020-05-28
|
4
76
|
|
5
77
|
#### Documentation
|
data/CONTRIBUTING.md
CHANGED
@@ -53,9 +53,15 @@ module Google
|
|
53
53
|
# bigquery = gcloud.bigquery
|
54
54
|
# dataset = bigquery.dataset "my_dataset"
|
55
55
|
# table = dataset.table "my_table"
|
56
|
-
#
|
57
|
-
#
|
56
|
+
#
|
57
|
+
# data = table.data
|
58
|
+
#
|
59
|
+
# # Iterate over the first page of results
|
60
|
+
# data.each do |row|
|
61
|
+
# puts row[:name]
|
58
62
|
# end
|
63
|
+
# # Retrieve the next page of results
|
64
|
+
# data = data.next if data.next?
|
59
65
|
#
|
60
66
|
# @example The default scope can be overridden with the `scope` option:
|
61
67
|
# require "google/cloud"
|
@@ -127,6 +133,7 @@ Google::Cloud.configure.add_config! :bigquery do |config|
|
|
127
133
|
config.add_field! :credentials, default_creds, match: [String, Hash, Google::Auth::Credentials], allow_nil: true
|
128
134
|
config.add_alias! :keyfile, :credentials
|
129
135
|
config.add_field! :scope, nil, match: [String, Array]
|
136
|
+
config.add_field! :quota_project, nil, match: String
|
130
137
|
config.add_field! :retries, nil, match: Integer
|
131
138
|
config.add_field! :timeout, nil, match: Integer
|
132
139
|
config.add_field! :endpoint, nil, match: String
|
@@ -318,7 +318,9 @@ module Google
|
|
318
318
|
"parquet" => "PARQUET",
|
319
319
|
"datastore" => "DATASTORE_BACKUP",
|
320
320
|
"backup" => "DATASTORE_BACKUP",
|
321
|
-
"datastore_backup" => "DATASTORE_BACKUP"
|
321
|
+
"datastore_backup" => "DATASTORE_BACKUP",
|
322
|
+
"ml_tf_saved_model" => "ML_TF_SAVED_MODEL",
|
323
|
+
"ml_xgboost_booster" => "ML_XGBOOST_BOOSTER"
|
322
324
|
}[format.to_s.downcase]
|
323
325
|
return val unless val.nil?
|
324
326
|
format
|
@@ -272,12 +272,21 @@ module Google
|
|
272
272
|
# Sets the labels to use for the job.
|
273
273
|
#
|
274
274
|
# @param [Hash] value A hash of user-provided labels associated with
|
275
|
-
# the job. You can use these to organize and group your jobs.
|
276
|
-
#
|
277
|
-
#
|
278
|
-
#
|
279
|
-
#
|
280
|
-
#
|
275
|
+
# the job. You can use these to organize and group your jobs.
|
276
|
+
#
|
277
|
+
# The labels applied to a resource must meet the following requirements:
|
278
|
+
#
|
279
|
+
# * Each resource can have multiple labels, up to a maximum of 64.
|
280
|
+
# * Each label must be a key-value pair.
|
281
|
+
# * Keys have a minimum length of 1 character and a maximum length of
|
282
|
+
# 63 characters, and cannot be empty. Values can be empty, and have
|
283
|
+
# a maximum length of 63 characters.
|
284
|
+
# * Keys and values can contain only lowercase letters, numeric characters,
|
285
|
+
# underscores, and dashes. All characters must use UTF-8 encoding, and
|
286
|
+
# international characters are allowed.
|
287
|
+
# * The key portion of a label must be unique. However, you can use the
|
288
|
+
# same key with multiple resources.
|
289
|
+
# * Keys must start with a lowercase letter or international character.
|
281
290
|
#
|
282
291
|
# @!group Attributes
|
283
292
|
def labels= value
|
@@ -41,9 +41,12 @@ module Google
|
|
41
41
|
#
|
42
42
|
# data.count # 100000
|
43
43
|
# data.total # 164656
|
44
|
+
#
|
45
|
+
# # Iterate over the first page of results
|
44
46
|
# data.each do |row|
|
45
47
|
# puts row[:word]
|
46
48
|
# end
|
49
|
+
# # Retrieve the next page of results
|
47
50
|
# data = data.next if data.next?
|
48
51
|
#
|
49
52
|
class Data < DelegateClass(::Array)
|
@@ -117,9 +120,12 @@ module Google
|
|
117
120
|
#
|
118
121
|
# data.count # 100000
|
119
122
|
# data.total # 164656
|
123
|
+
#
|
124
|
+
# # Iterate over the first page of results
|
120
125
|
# data.each do |row|
|
121
126
|
# puts row[:word]
|
122
127
|
# end
|
128
|
+
# # Retrieve the next page of results
|
123
129
|
# data = data.next if data.next?
|
124
130
|
#
|
125
131
|
def total
|
@@ -375,9 +381,12 @@ module Google
|
|
375
381
|
#
|
376
382
|
# data.count # 100000
|
377
383
|
# data.total # 164656
|
384
|
+
#
|
385
|
+
# # Iterate over the first page of results
|
378
386
|
# data.each do |row|
|
379
387
|
# puts row[:word]
|
380
388
|
# end
|
389
|
+
# # Retrieve the next page of results
|
381
390
|
# data = data.next if data.next?
|
382
391
|
#
|
383
392
|
def next?
|
@@ -402,9 +411,12 @@ module Google
|
|
402
411
|
#
|
403
412
|
# data.count # 100000
|
404
413
|
# data.total # 164656
|
414
|
+
#
|
415
|
+
# # Iterate over the first page of results
|
405
416
|
# data.each do |row|
|
406
417
|
# puts row[:word]
|
407
418
|
# end
|
419
|
+
# # Retrieve the next page of results
|
408
420
|
# data = data.next if data.next?
|
409
421
|
#
|
410
422
|
def next
|
@@ -313,12 +313,19 @@ module Google
|
|
313
313
|
# @param [Hash<String, String>] labels A hash containing key/value
|
314
314
|
# pairs.
|
315
315
|
#
|
316
|
-
#
|
317
|
-
#
|
318
|
-
#
|
319
|
-
# *
|
320
|
-
# *
|
321
|
-
#
|
316
|
+
# The labels applied to a resource must meet the following requirements:
|
317
|
+
#
|
318
|
+
# * Each resource can have multiple labels, up to a maximum of 64.
|
319
|
+
# * Each label must be a key-value pair.
|
320
|
+
# * Keys have a minimum length of 1 character and a maximum length of
|
321
|
+
# 63 characters, and cannot be empty. Values can be empty, and have
|
322
|
+
# a maximum length of 63 characters.
|
323
|
+
# * Keys and values can contain only lowercase letters, numeric characters,
|
324
|
+
# underscores, and dashes. All characters must use UTF-8 encoding, and
|
325
|
+
# international characters are allowed.
|
326
|
+
# * The key portion of a label must be unique. However, you can use the
|
327
|
+
# same key with multiple resources.
|
328
|
+
# * Keys must start with a lowercase letter or international character.
|
322
329
|
#
|
323
330
|
# @example
|
324
331
|
# require "google/cloud/bigquery"
|
@@ -1171,13 +1178,21 @@ module Google
|
|
1171
1178
|
# is 1,024 characters. If `job_id` is provided, then `prefix` will not
|
1172
1179
|
# be used.
|
1173
1180
|
# @param [Hash] labels A hash of user-provided labels associated with
|
1174
|
-
# the job. You can use these to organize and group your jobs.
|
1175
|
-
#
|
1176
|
-
#
|
1177
|
-
#
|
1178
|
-
#
|
1179
|
-
#
|
1180
|
-
#
|
1181
|
+
# the job. You can use these to organize and group your jobs.
|
1182
|
+
#
|
1183
|
+
# The labels applied to a resource must meet the following requirements:
|
1184
|
+
#
|
1185
|
+
# * Each resource can have multiple labels, up to a maximum of 64.
|
1186
|
+
# * Each label must be a key-value pair.
|
1187
|
+
# * Keys have a minimum length of 1 character and a maximum length of
|
1188
|
+
# 63 characters, and cannot be empty. Values can be empty, and have
|
1189
|
+
# a maximum length of 63 characters.
|
1190
|
+
# * Keys and values can contain only lowercase letters, numeric characters,
|
1191
|
+
# underscores, and dashes. All characters must use UTF-8 encoding, and
|
1192
|
+
# international characters are allowed.
|
1193
|
+
# * The key portion of a label must be unique. However, you can use the
|
1194
|
+
# same key with multiple resources.
|
1195
|
+
# * Keys must start with a lowercase letter or international character.
|
1181
1196
|
# @param [Array<String>, String] udfs User-defined function resources
|
1182
1197
|
# used in a legacy SQL query. May be either a code resource to load from
|
1183
1198
|
# a Google Cloud Storage URI (`gs://bucket/path`), or an inline resource
|
@@ -1474,9 +1489,12 @@ module Google
|
|
1474
1489
|
#
|
1475
1490
|
# data = dataset.query "SELECT name FROM my_table"
|
1476
1491
|
#
|
1492
|
+
# # Iterate over the first page of results
|
1477
1493
|
# data.each do |row|
|
1478
1494
|
# puts row[:name]
|
1479
1495
|
# end
|
1496
|
+
# # Retrieve the next page of results
|
1497
|
+
# data = data.next if data.next?
|
1480
1498
|
#
|
1481
1499
|
# @example Query using legacy SQL:
|
1482
1500
|
# require "google/cloud/bigquery"
|
@@ -1487,9 +1505,12 @@ module Google
|
|
1487
1505
|
# data = dataset.query "SELECT name FROM my_table",
|
1488
1506
|
# legacy_sql: true
|
1489
1507
|
#
|
1508
|
+
# # Iterate over the first page of results
|
1490
1509
|
# data.each do |row|
|
1491
1510
|
# puts row[:name]
|
1492
1511
|
# end
|
1512
|
+
# # Retrieve the next page of results
|
1513
|
+
# data = data.next if data.next?
|
1493
1514
|
#
|
1494
1515
|
# @example Query using positional query parameters:
|
1495
1516
|
# require "google/cloud/bigquery"
|
@@ -1500,9 +1521,12 @@ module Google
|
|
1500
1521
|
# data = dataset.query "SELECT name FROM my_table WHERE id = ?",
|
1501
1522
|
# params: [1]
|
1502
1523
|
#
|
1524
|
+
# # Iterate over the first page of results
|
1503
1525
|
# data.each do |row|
|
1504
1526
|
# puts row[:name]
|
1505
1527
|
# end
|
1528
|
+
# # Retrieve the next page of results
|
1529
|
+
# data = data.next if data.next?
|
1506
1530
|
#
|
1507
1531
|
# @example Query using named query parameters:
|
1508
1532
|
# require "google/cloud/bigquery"
|
@@ -1513,9 +1537,12 @@ module Google
|
|
1513
1537
|
# data = dataset.query "SELECT name FROM my_table WHERE id = @id",
|
1514
1538
|
# params: { id: 1 }
|
1515
1539
|
#
|
1540
|
+
# # Iterate over the first page of results
|
1516
1541
|
# data.each do |row|
|
1517
1542
|
# puts row[:name]
|
1518
1543
|
# end
|
1544
|
+
# # Retrieve the next page of results
|
1545
|
+
# data = data.next if data.next?
|
1519
1546
|
#
|
1520
1547
|
# @example Query using named query parameters with types:
|
1521
1548
|
# require "google/cloud/bigquery"
|
@@ -1528,9 +1555,12 @@ module Google
|
|
1528
1555
|
# params: { ids: [] },
|
1529
1556
|
# types: { ids: [:INT64] }
|
1530
1557
|
#
|
1558
|
+
# # Iterate over the first page of results
|
1531
1559
|
# data.each do |row|
|
1532
1560
|
# puts row[:name]
|
1533
1561
|
# end
|
1562
|
+
# # Retrieve the next page of results
|
1563
|
+
# data = data.next if data.next?
|
1534
1564
|
#
|
1535
1565
|
# @example Execute a DDL statement:
|
1536
1566
|
# require "google/cloud/bigquery"
|
@@ -1569,9 +1599,12 @@ module Google
|
|
1569
1599
|
# query.table = dataset.table "my_table", skip_lookup: true
|
1570
1600
|
# end
|
1571
1601
|
#
|
1602
|
+
# # Iterate over the first page of results
|
1572
1603
|
# data.each do |row|
|
1573
1604
|
# puts row[:name]
|
1574
1605
|
# end
|
1606
|
+
# # Retrieve the next page of results
|
1607
|
+
# data = data.next if data.next?
|
1575
1608
|
#
|
1576
1609
|
# @!group Data
|
1577
1610
|
#
|
@@ -1774,13 +1807,21 @@ module Google
|
|
1774
1807
|
# is 1,024 characters. If `job_id` is provided, then `prefix` will not
|
1775
1808
|
# be used.
|
1776
1809
|
# @param [Hash] labels A hash of user-provided labels associated with
|
1777
|
-
# the job. You can use these to organize and group your jobs.
|
1778
|
-
#
|
1779
|
-
#
|
1780
|
-
#
|
1781
|
-
#
|
1782
|
-
#
|
1783
|
-
#
|
1810
|
+
# the job. You can use these to organize and group your jobs.
|
1811
|
+
#
|
1812
|
+
# The labels applied to a resource must meet the following requirements:
|
1813
|
+
#
|
1814
|
+
# * Each resource can have multiple labels, up to a maximum of 64.
|
1815
|
+
# * Each label must be a key-value pair.
|
1816
|
+
# * Keys have a minimum length of 1 character and a maximum length of
|
1817
|
+
# 63 characters, and cannot be empty. Values can be empty, and have
|
1818
|
+
# a maximum length of 63 characters.
|
1819
|
+
# * Keys and values can contain only lowercase letters, numeric characters,
|
1820
|
+
# underscores, and dashes. All characters must use UTF-8 encoding, and
|
1821
|
+
# international characters are allowed.
|
1822
|
+
# * The key portion of a label must be unique. However, you can use the
|
1823
|
+
# same key with multiple resources.
|
1824
|
+
# * Keys must start with a lowercase letter or international character.
|
1784
1825
|
# @yield [updater] A block for setting the schema and other
|
1785
1826
|
# options for the destination table. The schema can be omitted if the
|
1786
1827
|
# destination table already exists, or if you're loading data from a
|
@@ -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
|