gcloud 0.12.2 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/gcloud.rb +27 -456
- data/lib/gcloud/bigquery.rb +2 -382
- data/lib/gcloud/datastore.rb +2 -576
- data/lib/gcloud/dns.rb +2 -321
- data/lib/gcloud/logging.rb +1 -322
- data/lib/gcloud/pubsub.rb +2 -476
- data/lib/gcloud/resource_manager.rb +2 -273
- data/lib/gcloud/storage.rb +2 -440
- data/lib/gcloud/translate.rb +1 -250
- data/lib/gcloud/version.rb +2 -2
- data/lib/gcloud/vision.rb +1 -501
- metadata +36 -332
- data/AUTHENTICATION.md +0 -75
- data/CHANGELOG.md +0 -382
- data/OVERVIEW.md +0 -259
- data/lib/gcloud/backoff.rb +0 -150
- data/lib/gcloud/bigquery/copy_job.rb +0 -97
- data/lib/gcloud/bigquery/credentials.rb +0 -29
- data/lib/gcloud/bigquery/data.rb +0 -239
- data/lib/gcloud/bigquery/dataset.rb +0 -753
- data/lib/gcloud/bigquery/dataset/access.rb +0 -507
- data/lib/gcloud/bigquery/dataset/list.rb +0 -169
- data/lib/gcloud/bigquery/extract_job.rb +0 -117
- data/lib/gcloud/bigquery/insert_response.rb +0 -81
- data/lib/gcloud/bigquery/job.rb +0 -299
- data/lib/gcloud/bigquery/job/list.rb +0 -172
- data/lib/gcloud/bigquery/load_job.rb +0 -202
- data/lib/gcloud/bigquery/project.rb +0 -475
- data/lib/gcloud/bigquery/query_data.rb +0 -234
- data/lib/gcloud/bigquery/query_job.rb +0 -137
- data/lib/gcloud/bigquery/schema.rb +0 -359
- data/lib/gcloud/bigquery/service.rb +0 -506
- data/lib/gcloud/bigquery/table.rb +0 -1141
- data/lib/gcloud/bigquery/table/list.rb +0 -180
- data/lib/gcloud/bigquery/view.rb +0 -475
- data/lib/gcloud/credentials.rb +0 -129
- data/lib/gcloud/datastore/commit.rb +0 -148
- data/lib/gcloud/datastore/credentials.rb +0 -35
- data/lib/gcloud/datastore/cursor.rb +0 -76
- data/lib/gcloud/datastore/dataset.rb +0 -660
- data/lib/gcloud/datastore/dataset/lookup_results.rb +0 -219
- data/lib/gcloud/datastore/dataset/query_results.rb +0 -386
- data/lib/gcloud/datastore/entity.rb +0 -449
- data/lib/gcloud/datastore/errors.rb +0 -41
- data/lib/gcloud/datastore/gql_query.rb +0 -211
- data/lib/gcloud/datastore/grpc_utils.rb +0 -132
- data/lib/gcloud/datastore/key.rb +0 -281
- data/lib/gcloud/datastore/properties.rb +0 -128
- data/lib/gcloud/datastore/query.rb +0 -348
- data/lib/gcloud/datastore/service.rb +0 -167
- data/lib/gcloud/datastore/transaction.rb +0 -362
- data/lib/gcloud/dns/change.rb +0 -158
- data/lib/gcloud/dns/change/list.rb +0 -173
- data/lib/gcloud/dns/credentials.rb +0 -29
- data/lib/gcloud/dns/importer.rb +0 -183
- data/lib/gcloud/dns/project.rb +0 -247
- data/lib/gcloud/dns/record.rb +0 -170
- data/lib/gcloud/dns/record/list.rb +0 -174
- data/lib/gcloud/dns/service.rb +0 -167
- data/lib/gcloud/dns/zone.rb +0 -759
- data/lib/gcloud/dns/zone/list.rb +0 -168
- data/lib/gcloud/dns/zone/transaction.rb +0 -176
- data/lib/gcloud/errors.rb +0 -206
- data/lib/gcloud/gce.rb +0 -56
- data/lib/gcloud/grpc_utils.rb +0 -87
- data/lib/gcloud/logging/credentials.rb +0 -29
- data/lib/gcloud/logging/entry.rb +0 -465
- data/lib/gcloud/logging/entry/http_request.rb +0 -141
- data/lib/gcloud/logging/entry/list.rb +0 -177
- data/lib/gcloud/logging/entry/operation.rb +0 -90
- data/lib/gcloud/logging/logger.rb +0 -307
- data/lib/gcloud/logging/metric.rb +0 -169
- data/lib/gcloud/logging/metric/list.rb +0 -172
- data/lib/gcloud/logging/project.rb +0 -642
- data/lib/gcloud/logging/resource.rb +0 -84
- data/lib/gcloud/logging/resource_descriptor.rb +0 -137
- data/lib/gcloud/logging/resource_descriptor/list.rb +0 -174
- data/lib/gcloud/logging/service.rb +0 -267
- data/lib/gcloud/logging/sink.rb +0 -227
- data/lib/gcloud/logging/sink/list.rb +0 -171
- data/lib/gcloud/pubsub/credentials.rb +0 -29
- data/lib/gcloud/pubsub/message.rb +0 -94
- data/lib/gcloud/pubsub/policy.rb +0 -204
- data/lib/gcloud/pubsub/project.rb +0 -482
- data/lib/gcloud/pubsub/received_message.rb +0 -160
- data/lib/gcloud/pubsub/service.rb +0 -334
- data/lib/gcloud/pubsub/subscription.rb +0 -565
- data/lib/gcloud/pubsub/subscription/list.rb +0 -208
- data/lib/gcloud/pubsub/topic.rb +0 -511
- data/lib/gcloud/pubsub/topic/list.rb +0 -174
- data/lib/gcloud/pubsub/topic/publisher.rb +0 -85
- data/lib/gcloud/resource_manager/credentials.rb +0 -30
- data/lib/gcloud/resource_manager/manager.rb +0 -266
- data/lib/gcloud/resource_manager/policy.rb +0 -211
- data/lib/gcloud/resource_manager/project.rb +0 -484
- data/lib/gcloud/resource_manager/project/list.rb +0 -167
- data/lib/gcloud/resource_manager/project/updater.rb +0 -130
- data/lib/gcloud/resource_manager/service.rb +0 -127
- data/lib/gcloud/storage/bucket.rb +0 -775
- data/lib/gcloud/storage/bucket/acl.rb +0 -810
- data/lib/gcloud/storage/bucket/cors.rb +0 -153
- data/lib/gcloud/storage/bucket/list.rb +0 -172
- data/lib/gcloud/storage/credentials.rb +0 -29
- data/lib/gcloud/storage/errors.rb +0 -65
- data/lib/gcloud/storage/file.rb +0 -842
- data/lib/gcloud/storage/file/acl.rb +0 -425
- data/lib/gcloud/storage/file/list.rb +0 -191
- data/lib/gcloud/storage/file/verifier.rb +0 -67
- data/lib/gcloud/storage/project.rb +0 -316
- data/lib/gcloud/storage/service.rb +0 -347
- data/lib/gcloud/translate/api.rb +0 -241
- data/lib/gcloud/translate/detection.rb +0 -137
- data/lib/gcloud/translate/language.rb +0 -69
- data/lib/gcloud/translate/service.rb +0 -80
- data/lib/gcloud/translate/translation.rb +0 -112
- data/lib/gcloud/vision/annotate.rb +0 -224
- data/lib/gcloud/vision/annotation.rb +0 -455
- data/lib/gcloud/vision/annotation/entity.rb +0 -234
- data/lib/gcloud/vision/annotation/face.rb +0 -1750
- data/lib/gcloud/vision/annotation/properties.rb +0 -245
- data/lib/gcloud/vision/annotation/safe_search.rb +0 -161
- data/lib/gcloud/vision/annotation/text.rb +0 -236
- data/lib/gcloud/vision/annotation/vertex.rb +0 -108
- data/lib/gcloud/vision/credentials.rb +0 -29
- data/lib/gcloud/vision/image.rb +0 -590
- data/lib/gcloud/vision/location.rb +0 -115
- data/lib/gcloud/vision/project.rb +0 -278
- data/lib/gcloud/vision/service.rb +0 -66
- data/lib/google/api/annotations.rb +0 -14
- data/lib/google/api/http.rb +0 -30
- data/lib/google/api/label.rb +0 -24
- data/lib/google/api/monitored_resource.rb +0 -25
- data/lib/google/datastore/v1beta3/datastore.rb +0 -115
- data/lib/google/datastore/v1beta3/datastore_services.rb +0 -33
- data/lib/google/datastore/v1beta3/entity.rb +0 -63
- data/lib/google/datastore/v1beta3/query.rb +0 -128
- data/lib/google/devtools/cloudtrace/v1/trace.rb +0 -78
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +0 -32
- data/lib/google/example/library/v1/library.rb +0 -91
- data/lib/google/example/library/v1/library_services.rb +0 -40
- data/lib/google/iam/v1/iam_policy.rb +0 -33
- data/lib/google/iam/v1/iam_policy_services.rb +0 -30
- data/lib/google/iam/v1/policy.rb +0 -25
- data/lib/google/logging/type/http_request.rb +0 -28
- data/lib/google/logging/type/log_severity.rb +0 -27
- data/lib/google/logging/v2/log_entry.rb +0 -44
- data/lib/google/logging/v2/logging.rb +0 -56
- data/lib/google/logging/v2/logging_config.rb +0 -59
- data/lib/google/logging/v2/logging_config_services.rb +0 -32
- data/lib/google/logging/v2/logging_metrics.rb +0 -51
- data/lib/google/logging/v2/logging_metrics_services.rb +0 -32
- data/lib/google/logging/v2/logging_services.rb +0 -31
- data/lib/google/longrunning/operations.rb +0 -50
- data/lib/google/longrunning/operations_services.rb +0 -29
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/pubsub/v1/pubsub.rb +0 -129
- data/lib/google/pubsub/v1/pubsub_services.rb +0 -56
- data/lib/google/pubsub/v1beta2/pubsub.rb +0 -126
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +0 -56
- data/lib/google/rpc/code.rb +0 -32
- data/lib/google/rpc/error_details.rb +0 -61
- data/lib/google/rpc/status.rb +0 -19
- data/lib/google/type/color.rb +0 -20
- data/lib/google/type/date.rb +0 -18
- data/lib/google/type/dayofweek.rb +0 -23
- data/lib/google/type/latlng.rb +0 -17
- data/lib/google/type/money.rb +0 -18
- data/lib/google/type/timeofday.rb +0 -19
@@ -1,507 +0,0 @@
|
|
1
|
-
# Copyright 2015 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
module Gcloud
|
17
|
-
module Bigquery
|
18
|
-
class Dataset
|
19
|
-
##
|
20
|
-
# # Dataset Access Control
|
21
|
-
#
|
22
|
-
# Represents the Access rules for a {Dataset}.
|
23
|
-
#
|
24
|
-
# @see https://cloud.google.com/bigquery/access-control BigQuery Access
|
25
|
-
# Control
|
26
|
-
#
|
27
|
-
# @example
|
28
|
-
# require "gcloud"
|
29
|
-
#
|
30
|
-
# gcloud = Gcloud.new
|
31
|
-
# bigquery = gcloud.bigquery
|
32
|
-
# dataset = bigquery.dataset "my_dataset"
|
33
|
-
#
|
34
|
-
# dataset.access do |access|
|
35
|
-
# access.add_owner_group "owners@example.com"
|
36
|
-
# access.add_writer_user "writer@example.com"
|
37
|
-
# access.remove_writer_user "readers@example.com"
|
38
|
-
# access.add_reader_special :all
|
39
|
-
# access.add_reader_view other_dataset_view_object
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
class Access
|
43
|
-
# @private
|
44
|
-
ROLES = { "reader" => "READER",
|
45
|
-
"writer" => "WRITER",
|
46
|
-
"owner" => "OWNER" }
|
47
|
-
|
48
|
-
# @private
|
49
|
-
SCOPES = { "user" => :user_by_email,
|
50
|
-
"user_by_email" => :user_by_email,
|
51
|
-
"userByEmail" => :user_by_email,
|
52
|
-
"group" => :group_by_email,
|
53
|
-
"group_by_email" => :group_by_email,
|
54
|
-
"groupByEmail" => :group_by_email,
|
55
|
-
"domain" => :domain,
|
56
|
-
"special" => :special_group,
|
57
|
-
"special_group" => :special_group,
|
58
|
-
"specialGroup" => :special_group,
|
59
|
-
"view" => :view }
|
60
|
-
|
61
|
-
# @private
|
62
|
-
GROUPS = { "owners" => "projectOwners",
|
63
|
-
"project_owners" => "projectOwners",
|
64
|
-
"projectOwners" => "projectOwners",
|
65
|
-
"readers" => "projectReaders",
|
66
|
-
"project_readers" => "projectReaders",
|
67
|
-
"projectReaders" => "projectReaders",
|
68
|
-
"writers" => "projectWriters",
|
69
|
-
"project_writers" => "projectWriters",
|
70
|
-
"projectWriters" => "projectWriters",
|
71
|
-
"all" => "allAuthenticatedUsers",
|
72
|
-
"all_authenticated_users" => "allAuthenticatedUsers",
|
73
|
-
"allAuthenticatedUsers" => "allAuthenticatedUsers" }
|
74
|
-
|
75
|
-
##
|
76
|
-
# @private
|
77
|
-
# Initialized a new Access object.
|
78
|
-
# Must provide a valid Google::Apis::BigqueryV2::Dataset object.
|
79
|
-
# Access will mutate the gapi object.
|
80
|
-
def initialize
|
81
|
-
@rules = [] # easiest to do this in the constructor
|
82
|
-
@original_rules_hashes = @rules.map(&:to_h)
|
83
|
-
end
|
84
|
-
|
85
|
-
# @private
|
86
|
-
def changed?
|
87
|
-
@original_rules_hashes != @rules.map(&:to_h)
|
88
|
-
end
|
89
|
-
|
90
|
-
# @private
|
91
|
-
def empty?
|
92
|
-
@rules.empty?
|
93
|
-
end
|
94
|
-
|
95
|
-
# @private
|
96
|
-
def freeze
|
97
|
-
@rules = @rules.map(&:dup).map(&:freeze)
|
98
|
-
@rules.freeze
|
99
|
-
super
|
100
|
-
end
|
101
|
-
|
102
|
-
##
|
103
|
-
# @private View the access rules as an array of hashes.
|
104
|
-
def to_a
|
105
|
-
@rules.map(&:to_h)
|
106
|
-
end
|
107
|
-
|
108
|
-
##
|
109
|
-
# Add reader access to a user.
|
110
|
-
def add_reader_user email
|
111
|
-
add_access_role_scope_value :reader, :user, email
|
112
|
-
end
|
113
|
-
|
114
|
-
##
|
115
|
-
# Add reader access to a group.
|
116
|
-
def add_reader_group email
|
117
|
-
add_access_role_scope_value :reader, :group, email
|
118
|
-
end
|
119
|
-
|
120
|
-
##
|
121
|
-
# Add reader access to a domain.
|
122
|
-
def add_reader_domain domain
|
123
|
-
add_access_role_scope_value :reader, :domain, domain
|
124
|
-
end
|
125
|
-
|
126
|
-
##
|
127
|
-
# Add reader access to a special group.
|
128
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
129
|
-
def add_reader_special group
|
130
|
-
add_access_role_scope_value :reader, :special, group
|
131
|
-
end
|
132
|
-
|
133
|
-
##
|
134
|
-
# Add reader access to a view.
|
135
|
-
# The view can be a Gcloud::Bigquery::View object,
|
136
|
-
# or a string identifier as specified by the
|
137
|
-
# [Query
|
138
|
-
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
139
|
-
# +project_name:datasetId.tableId+.
|
140
|
-
def add_reader_view view
|
141
|
-
add_access_view view
|
142
|
-
end
|
143
|
-
|
144
|
-
##
|
145
|
-
# Add writer access to a user.
|
146
|
-
def add_writer_user email
|
147
|
-
add_access_role_scope_value :writer, :user, email
|
148
|
-
end
|
149
|
-
|
150
|
-
##
|
151
|
-
# Add writer access to a group.
|
152
|
-
def add_writer_group email
|
153
|
-
add_access_role_scope_value :writer, :group, email
|
154
|
-
end
|
155
|
-
|
156
|
-
##
|
157
|
-
# Add writer access to a domain.
|
158
|
-
def add_writer_domain domain
|
159
|
-
add_access_role_scope_value :writer, :domain, domain
|
160
|
-
end
|
161
|
-
|
162
|
-
##
|
163
|
-
# Add writer access to a special group.
|
164
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
165
|
-
def add_writer_special group
|
166
|
-
add_access_role_scope_value :writer, :special, group
|
167
|
-
end
|
168
|
-
|
169
|
-
##
|
170
|
-
# Add owner access to a user.
|
171
|
-
def add_owner_user email
|
172
|
-
add_access_role_scope_value :owner, :user, email
|
173
|
-
end
|
174
|
-
|
175
|
-
##
|
176
|
-
# Add owner access to a group.
|
177
|
-
def add_owner_group email
|
178
|
-
add_access_role_scope_value :owner, :group, email
|
179
|
-
end
|
180
|
-
|
181
|
-
##
|
182
|
-
# Add owner access to a domain.
|
183
|
-
def add_owner_domain domain
|
184
|
-
add_access_role_scope_value :owner, :domain, domain
|
185
|
-
end
|
186
|
-
|
187
|
-
##
|
188
|
-
# Add owner access to a special group.
|
189
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
190
|
-
def add_owner_special group
|
191
|
-
add_access_role_scope_value :owner, :special, group
|
192
|
-
end
|
193
|
-
|
194
|
-
##
|
195
|
-
# Remove reader access from a user.
|
196
|
-
def remove_reader_user email
|
197
|
-
remove_access_role_scope_value :reader, :user, email
|
198
|
-
end
|
199
|
-
|
200
|
-
##
|
201
|
-
# Remove reader access from a group.
|
202
|
-
def remove_reader_group email
|
203
|
-
remove_access_role_scope_value :reader, :group, email
|
204
|
-
end
|
205
|
-
|
206
|
-
##
|
207
|
-
# Remove reader access from a domain.
|
208
|
-
def remove_reader_domain domain
|
209
|
-
remove_access_role_scope_value :reader, :domain, domain
|
210
|
-
end
|
211
|
-
|
212
|
-
##
|
213
|
-
# Remove reader access from a special group.
|
214
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
215
|
-
def remove_reader_special group
|
216
|
-
remove_access_role_scope_value :reader, :special, group
|
217
|
-
end
|
218
|
-
|
219
|
-
##
|
220
|
-
# Remove reader access from a view.
|
221
|
-
# The view can be a Gcloud::Bigquery::View object,
|
222
|
-
# or a string identifier as specified by the
|
223
|
-
# [Query
|
224
|
-
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
225
|
-
# +project_name:datasetId.tableId+.
|
226
|
-
def remove_reader_view view
|
227
|
-
remove_access_view view
|
228
|
-
end
|
229
|
-
|
230
|
-
##
|
231
|
-
# Remove writer access from a user.
|
232
|
-
def remove_writer_user email
|
233
|
-
remove_access_role_scope_value :writer, :user, email
|
234
|
-
end
|
235
|
-
|
236
|
-
##
|
237
|
-
# Remove writer access from a group.
|
238
|
-
def remove_writer_group email
|
239
|
-
remove_access_role_scope_value :writer, :group, email
|
240
|
-
end
|
241
|
-
|
242
|
-
##
|
243
|
-
# Remove writer access from a domain.
|
244
|
-
def remove_writer_domain domain
|
245
|
-
remove_access_role_scope_value :writer, :domain, domain
|
246
|
-
end
|
247
|
-
|
248
|
-
##
|
249
|
-
# Remove writer access from a special group.
|
250
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
251
|
-
def remove_writer_special group
|
252
|
-
remove_access_role_scope_value :writer, :special, group
|
253
|
-
end
|
254
|
-
|
255
|
-
##
|
256
|
-
# Remove owner access from a user.
|
257
|
-
def remove_owner_user email
|
258
|
-
remove_access_role_scope_value :owner, :user, email
|
259
|
-
end
|
260
|
-
|
261
|
-
##
|
262
|
-
# Remove owner access from a group.
|
263
|
-
def remove_owner_group email
|
264
|
-
remove_access_role_scope_value :owner, :group, email
|
265
|
-
end
|
266
|
-
|
267
|
-
##
|
268
|
-
# Remove owner access from a domain.
|
269
|
-
def remove_owner_domain domain
|
270
|
-
remove_access_role_scope_value :owner, :domain, domain
|
271
|
-
end
|
272
|
-
|
273
|
-
##
|
274
|
-
# Remove owner access from a special group.
|
275
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
276
|
-
def remove_owner_special group
|
277
|
-
remove_access_role_scope_value :owner, :special, group
|
278
|
-
end
|
279
|
-
|
280
|
-
##
|
281
|
-
# Checks reader access for a user.
|
282
|
-
def reader_user? email
|
283
|
-
lookup_access_role_scope_value :reader, :user, email
|
284
|
-
end
|
285
|
-
|
286
|
-
##
|
287
|
-
# Checks reader access for a group.
|
288
|
-
def reader_group? email
|
289
|
-
lookup_access_role_scope_value :reader, :group, email
|
290
|
-
end
|
291
|
-
|
292
|
-
##
|
293
|
-
# Checks reader access for a domain.
|
294
|
-
def reader_domain? domain
|
295
|
-
lookup_access_role_scope_value :reader, :domain, domain
|
296
|
-
end
|
297
|
-
|
298
|
-
##
|
299
|
-
# Checks reader access for a special group.
|
300
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
301
|
-
def reader_special? group
|
302
|
-
lookup_access_role_scope_value :reader, :special, group
|
303
|
-
end
|
304
|
-
|
305
|
-
##
|
306
|
-
# Checks reader access for a view.
|
307
|
-
# The view can be a Gcloud::Bigquery::View object,
|
308
|
-
# or a string identifier as specified by the
|
309
|
-
# [Query
|
310
|
-
# Reference](https://cloud.google.com/bigquery/query-reference#from):
|
311
|
-
# +project_name:datasetId.tableId+.
|
312
|
-
def reader_view? view
|
313
|
-
lookup_access_view view
|
314
|
-
end
|
315
|
-
|
316
|
-
##
|
317
|
-
# Checks writer access for a user.
|
318
|
-
def writer_user? email
|
319
|
-
lookup_access_role_scope_value :writer, :user, email
|
320
|
-
end
|
321
|
-
|
322
|
-
##
|
323
|
-
# Checks writer access for a group.
|
324
|
-
def writer_group? email
|
325
|
-
lookup_access_role_scope_value :writer, :group, email
|
326
|
-
end
|
327
|
-
|
328
|
-
##
|
329
|
-
# Checks writer access for a domain.
|
330
|
-
def writer_domain? domain
|
331
|
-
lookup_access_role_scope_value :writer, :domain, domain
|
332
|
-
end
|
333
|
-
|
334
|
-
##
|
335
|
-
# Checks writer access for a special group.
|
336
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
337
|
-
def writer_special? group
|
338
|
-
lookup_access_role_scope_value :writer, :special, group
|
339
|
-
end
|
340
|
-
|
341
|
-
##
|
342
|
-
# Checks owner access for a user.
|
343
|
-
def owner_user? email
|
344
|
-
lookup_access_role_scope_value :owner, :user, email
|
345
|
-
end
|
346
|
-
|
347
|
-
##
|
348
|
-
# Checks owner access for a group.
|
349
|
-
def owner_group? email
|
350
|
-
lookup_access_role_scope_value :owner, :group, email
|
351
|
-
end
|
352
|
-
|
353
|
-
##
|
354
|
-
# Checks owner access for a domain.
|
355
|
-
def owner_domain? domain
|
356
|
-
lookup_access_role_scope_value :owner, :domain, domain
|
357
|
-
end
|
358
|
-
|
359
|
-
##
|
360
|
-
# Checks owner access for a special group.
|
361
|
-
# Accepted values are `owners`, `writers`, `readers`, and `all`.
|
362
|
-
def owner_special? group
|
363
|
-
lookup_access_role_scope_value :owner, :special, group
|
364
|
-
end
|
365
|
-
|
366
|
-
# @private
|
367
|
-
def self.from_gapi gapi
|
368
|
-
rules = Array gapi.access
|
369
|
-
new.tap do |s|
|
370
|
-
s.instance_variable_set :@rules, rules
|
371
|
-
s.instance_variable_set :@original_rules_hashes,
|
372
|
-
rules.map(&:to_h)
|
373
|
-
s.instance_variable_set :@dataset_reference,
|
374
|
-
gapi.dataset_reference
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
# @private
|
379
|
-
def to_gapi
|
380
|
-
@rules
|
381
|
-
end
|
382
|
-
|
383
|
-
protected
|
384
|
-
|
385
|
-
# @private
|
386
|
-
def validate_role role
|
387
|
-
good_role = ROLES[role.to_s]
|
388
|
-
if good_role.nil?
|
389
|
-
fail ArgumentError "Unable to determine role for #{role}"
|
390
|
-
end
|
391
|
-
good_role
|
392
|
-
end
|
393
|
-
|
394
|
-
# @private
|
395
|
-
def validate_scope scope
|
396
|
-
good_scope = SCOPES[scope.to_s]
|
397
|
-
if good_scope.nil?
|
398
|
-
fail ArgumentError "Unable to determine scope for #{scope}"
|
399
|
-
end
|
400
|
-
good_scope
|
401
|
-
end
|
402
|
-
|
403
|
-
# @private
|
404
|
-
def validate_special_group value
|
405
|
-
good_value = GROUPS[value.to_s]
|
406
|
-
return good_value unless good_value.nil?
|
407
|
-
value
|
408
|
-
end
|
409
|
-
|
410
|
-
# @private
|
411
|
-
def validate_view view
|
412
|
-
if view.respond_to? :table_ref
|
413
|
-
view.table_ref
|
414
|
-
else
|
415
|
-
Service.table_ref_from_s view, @dataset_reference
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
# @private
|
420
|
-
def add_access_role_scope_value role, scope, value
|
421
|
-
role = validate_role(role)
|
422
|
-
scope = validate_scope scope
|
423
|
-
# If scope is special group, make sure value is in the list
|
424
|
-
value = validate_special_group(value) if scope == :special_group
|
425
|
-
# Remove any rules of this scope and value
|
426
|
-
@rules.reject!(&find_by_scope_and_value(scope, value))
|
427
|
-
# Add new rule for this role, scope, and value
|
428
|
-
opts = { role: role, scope => value }
|
429
|
-
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
430
|
-
end
|
431
|
-
|
432
|
-
# @private
|
433
|
-
def add_access_view value
|
434
|
-
# scope is view, make sure value is in the right format
|
435
|
-
value = validate_view(value)
|
436
|
-
# Remove existing view rule, if any
|
437
|
-
@rules.reject!(&find_view(value))
|
438
|
-
# Add new rule for this role, scope, and value
|
439
|
-
opts = { view: value }
|
440
|
-
@rules << Google::Apis::BigqueryV2::Dataset::Access.new(opts)
|
441
|
-
end
|
442
|
-
|
443
|
-
# @private
|
444
|
-
def remove_access_role_scope_value role, scope, value
|
445
|
-
role = validate_role(role)
|
446
|
-
scope = validate_scope scope
|
447
|
-
# If scope is special group, make sure value is in the list
|
448
|
-
value = validate_special_group(value) if scope == :special_group
|
449
|
-
# Remove any rules of this role, scope, and value
|
450
|
-
@rules.reject!(
|
451
|
-
&find_by_role_and_scope_and_value(role, scope, value))
|
452
|
-
end
|
453
|
-
|
454
|
-
# @private
|
455
|
-
def remove_access_view value
|
456
|
-
# scope is view, make sure value is in the right format
|
457
|
-
value = validate_view(value)
|
458
|
-
# Remove existing view rule, if any
|
459
|
-
@rules.reject!(&find_view(value))
|
460
|
-
end
|
461
|
-
|
462
|
-
# @private
|
463
|
-
def lookup_access_role_scope_value role, scope, value
|
464
|
-
role = validate_role(role)
|
465
|
-
scope = validate_scope scope
|
466
|
-
# If scope is special group, make sure value is in the list
|
467
|
-
value = validate_special_group(value) if scope == :special_group
|
468
|
-
# Detect any rules of this role, scope, and value
|
469
|
-
!(!@rules.detect(
|
470
|
-
&find_by_role_and_scope_and_value(role, scope, value)))
|
471
|
-
end
|
472
|
-
|
473
|
-
# @private
|
474
|
-
def lookup_access_view value
|
475
|
-
# scope is view, make sure value is in the right format
|
476
|
-
value = validate_view(value)
|
477
|
-
# Detect view rule, if any
|
478
|
-
!(!@rules.detect(&find_view(value)))
|
479
|
-
end
|
480
|
-
|
481
|
-
# @private
|
482
|
-
def find_by_role_and_scope_and_value role, scope, value
|
483
|
-
lambda do |a|
|
484
|
-
h = a.to_h
|
485
|
-
h[:role] == role && h[scope] == value
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
# @private
|
490
|
-
def find_by_scope_and_value scope, value
|
491
|
-
lambda do |a|
|
492
|
-
h = a.to_h
|
493
|
-
h[scope] == value
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
# @private
|
498
|
-
def find_view value
|
499
|
-
lambda do |a|
|
500
|
-
h = a.to_h
|
501
|
-
h[:view].to_h == value.to_h
|
502
|
-
end
|
503
|
-
end
|
504
|
-
end
|
505
|
-
end
|
506
|
-
end
|
507
|
-
end
|