gcloud 0.12.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +5 -13
  2. data/lib/gcloud.rb +27 -456
  3. data/lib/gcloud/bigquery.rb +2 -382
  4. data/lib/gcloud/datastore.rb +2 -576
  5. data/lib/gcloud/dns.rb +2 -321
  6. data/lib/gcloud/logging.rb +1 -322
  7. data/lib/gcloud/pubsub.rb +2 -476
  8. data/lib/gcloud/resource_manager.rb +2 -273
  9. data/lib/gcloud/storage.rb +2 -440
  10. data/lib/gcloud/translate.rb +1 -250
  11. data/lib/gcloud/version.rb +2 -2
  12. data/lib/gcloud/vision.rb +1 -501
  13. metadata +36 -332
  14. data/AUTHENTICATION.md +0 -75
  15. data/CHANGELOG.md +0 -382
  16. data/OVERVIEW.md +0 -259
  17. data/lib/gcloud/backoff.rb +0 -150
  18. data/lib/gcloud/bigquery/copy_job.rb +0 -97
  19. data/lib/gcloud/bigquery/credentials.rb +0 -29
  20. data/lib/gcloud/bigquery/data.rb +0 -239
  21. data/lib/gcloud/bigquery/dataset.rb +0 -753
  22. data/lib/gcloud/bigquery/dataset/access.rb +0 -507
  23. data/lib/gcloud/bigquery/dataset/list.rb +0 -169
  24. data/lib/gcloud/bigquery/extract_job.rb +0 -117
  25. data/lib/gcloud/bigquery/insert_response.rb +0 -81
  26. data/lib/gcloud/bigquery/job.rb +0 -299
  27. data/lib/gcloud/bigquery/job/list.rb +0 -172
  28. data/lib/gcloud/bigquery/load_job.rb +0 -202
  29. data/lib/gcloud/bigquery/project.rb +0 -475
  30. data/lib/gcloud/bigquery/query_data.rb +0 -234
  31. data/lib/gcloud/bigquery/query_job.rb +0 -137
  32. data/lib/gcloud/bigquery/schema.rb +0 -359
  33. data/lib/gcloud/bigquery/service.rb +0 -506
  34. data/lib/gcloud/bigquery/table.rb +0 -1141
  35. data/lib/gcloud/bigquery/table/list.rb +0 -180
  36. data/lib/gcloud/bigquery/view.rb +0 -475
  37. data/lib/gcloud/credentials.rb +0 -129
  38. data/lib/gcloud/datastore/commit.rb +0 -148
  39. data/lib/gcloud/datastore/credentials.rb +0 -35
  40. data/lib/gcloud/datastore/cursor.rb +0 -76
  41. data/lib/gcloud/datastore/dataset.rb +0 -660
  42. data/lib/gcloud/datastore/dataset/lookup_results.rb +0 -219
  43. data/lib/gcloud/datastore/dataset/query_results.rb +0 -386
  44. data/lib/gcloud/datastore/entity.rb +0 -449
  45. data/lib/gcloud/datastore/errors.rb +0 -41
  46. data/lib/gcloud/datastore/gql_query.rb +0 -211
  47. data/lib/gcloud/datastore/grpc_utils.rb +0 -132
  48. data/lib/gcloud/datastore/key.rb +0 -281
  49. data/lib/gcloud/datastore/properties.rb +0 -128
  50. data/lib/gcloud/datastore/query.rb +0 -348
  51. data/lib/gcloud/datastore/service.rb +0 -167
  52. data/lib/gcloud/datastore/transaction.rb +0 -362
  53. data/lib/gcloud/dns/change.rb +0 -158
  54. data/lib/gcloud/dns/change/list.rb +0 -173
  55. data/lib/gcloud/dns/credentials.rb +0 -29
  56. data/lib/gcloud/dns/importer.rb +0 -183
  57. data/lib/gcloud/dns/project.rb +0 -247
  58. data/lib/gcloud/dns/record.rb +0 -170
  59. data/lib/gcloud/dns/record/list.rb +0 -174
  60. data/lib/gcloud/dns/service.rb +0 -167
  61. data/lib/gcloud/dns/zone.rb +0 -759
  62. data/lib/gcloud/dns/zone/list.rb +0 -168
  63. data/lib/gcloud/dns/zone/transaction.rb +0 -176
  64. data/lib/gcloud/errors.rb +0 -206
  65. data/lib/gcloud/gce.rb +0 -56
  66. data/lib/gcloud/grpc_utils.rb +0 -87
  67. data/lib/gcloud/logging/credentials.rb +0 -29
  68. data/lib/gcloud/logging/entry.rb +0 -465
  69. data/lib/gcloud/logging/entry/http_request.rb +0 -141
  70. data/lib/gcloud/logging/entry/list.rb +0 -177
  71. data/lib/gcloud/logging/entry/operation.rb +0 -90
  72. data/lib/gcloud/logging/logger.rb +0 -307
  73. data/lib/gcloud/logging/metric.rb +0 -169
  74. data/lib/gcloud/logging/metric/list.rb +0 -172
  75. data/lib/gcloud/logging/project.rb +0 -642
  76. data/lib/gcloud/logging/resource.rb +0 -84
  77. data/lib/gcloud/logging/resource_descriptor.rb +0 -137
  78. data/lib/gcloud/logging/resource_descriptor/list.rb +0 -174
  79. data/lib/gcloud/logging/service.rb +0 -267
  80. data/lib/gcloud/logging/sink.rb +0 -227
  81. data/lib/gcloud/logging/sink/list.rb +0 -171
  82. data/lib/gcloud/pubsub/credentials.rb +0 -29
  83. data/lib/gcloud/pubsub/message.rb +0 -94
  84. data/lib/gcloud/pubsub/policy.rb +0 -204
  85. data/lib/gcloud/pubsub/project.rb +0 -482
  86. data/lib/gcloud/pubsub/received_message.rb +0 -160
  87. data/lib/gcloud/pubsub/service.rb +0 -334
  88. data/lib/gcloud/pubsub/subscription.rb +0 -565
  89. data/lib/gcloud/pubsub/subscription/list.rb +0 -208
  90. data/lib/gcloud/pubsub/topic.rb +0 -511
  91. data/lib/gcloud/pubsub/topic/list.rb +0 -174
  92. data/lib/gcloud/pubsub/topic/publisher.rb +0 -85
  93. data/lib/gcloud/resource_manager/credentials.rb +0 -30
  94. data/lib/gcloud/resource_manager/manager.rb +0 -266
  95. data/lib/gcloud/resource_manager/policy.rb +0 -211
  96. data/lib/gcloud/resource_manager/project.rb +0 -484
  97. data/lib/gcloud/resource_manager/project/list.rb +0 -167
  98. data/lib/gcloud/resource_manager/project/updater.rb +0 -130
  99. data/lib/gcloud/resource_manager/service.rb +0 -127
  100. data/lib/gcloud/storage/bucket.rb +0 -775
  101. data/lib/gcloud/storage/bucket/acl.rb +0 -810
  102. data/lib/gcloud/storage/bucket/cors.rb +0 -153
  103. data/lib/gcloud/storage/bucket/list.rb +0 -172
  104. data/lib/gcloud/storage/credentials.rb +0 -29
  105. data/lib/gcloud/storage/errors.rb +0 -65
  106. data/lib/gcloud/storage/file.rb +0 -842
  107. data/lib/gcloud/storage/file/acl.rb +0 -425
  108. data/lib/gcloud/storage/file/list.rb +0 -191
  109. data/lib/gcloud/storage/file/verifier.rb +0 -67
  110. data/lib/gcloud/storage/project.rb +0 -316
  111. data/lib/gcloud/storage/service.rb +0 -347
  112. data/lib/gcloud/translate/api.rb +0 -241
  113. data/lib/gcloud/translate/detection.rb +0 -137
  114. data/lib/gcloud/translate/language.rb +0 -69
  115. data/lib/gcloud/translate/service.rb +0 -80
  116. data/lib/gcloud/translate/translation.rb +0 -112
  117. data/lib/gcloud/vision/annotate.rb +0 -224
  118. data/lib/gcloud/vision/annotation.rb +0 -455
  119. data/lib/gcloud/vision/annotation/entity.rb +0 -234
  120. data/lib/gcloud/vision/annotation/face.rb +0 -1750
  121. data/lib/gcloud/vision/annotation/properties.rb +0 -245
  122. data/lib/gcloud/vision/annotation/safe_search.rb +0 -161
  123. data/lib/gcloud/vision/annotation/text.rb +0 -236
  124. data/lib/gcloud/vision/annotation/vertex.rb +0 -108
  125. data/lib/gcloud/vision/credentials.rb +0 -29
  126. data/lib/gcloud/vision/image.rb +0 -590
  127. data/lib/gcloud/vision/location.rb +0 -115
  128. data/lib/gcloud/vision/project.rb +0 -278
  129. data/lib/gcloud/vision/service.rb +0 -66
  130. data/lib/google/api/annotations.rb +0 -14
  131. data/lib/google/api/http.rb +0 -30
  132. data/lib/google/api/label.rb +0 -24
  133. data/lib/google/api/monitored_resource.rb +0 -25
  134. data/lib/google/datastore/v1beta3/datastore.rb +0 -115
  135. data/lib/google/datastore/v1beta3/datastore_services.rb +0 -33
  136. data/lib/google/datastore/v1beta3/entity.rb +0 -63
  137. data/lib/google/datastore/v1beta3/query.rb +0 -128
  138. data/lib/google/devtools/cloudtrace/v1/trace.rb +0 -78
  139. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +0 -32
  140. data/lib/google/example/library/v1/library.rb +0 -91
  141. data/lib/google/example/library/v1/library_services.rb +0 -40
  142. data/lib/google/iam/v1/iam_policy.rb +0 -33
  143. data/lib/google/iam/v1/iam_policy_services.rb +0 -30
  144. data/lib/google/iam/v1/policy.rb +0 -25
  145. data/lib/google/logging/type/http_request.rb +0 -28
  146. data/lib/google/logging/type/log_severity.rb +0 -27
  147. data/lib/google/logging/v2/log_entry.rb +0 -44
  148. data/lib/google/logging/v2/logging.rb +0 -56
  149. data/lib/google/logging/v2/logging_config.rb +0 -59
  150. data/lib/google/logging/v2/logging_config_services.rb +0 -32
  151. data/lib/google/logging/v2/logging_metrics.rb +0 -51
  152. data/lib/google/logging/v2/logging_metrics_services.rb +0 -32
  153. data/lib/google/logging/v2/logging_services.rb +0 -31
  154. data/lib/google/longrunning/operations.rb +0 -50
  155. data/lib/google/longrunning/operations_services.rb +0 -29
  156. data/lib/google/protobuf/descriptor.rb +0 -0
  157. data/lib/google/pubsub/v1/pubsub.rb +0 -129
  158. data/lib/google/pubsub/v1/pubsub_services.rb +0 -56
  159. data/lib/google/pubsub/v1beta2/pubsub.rb +0 -126
  160. data/lib/google/pubsub/v1beta2/pubsub_services.rb +0 -56
  161. data/lib/google/rpc/code.rb +0 -32
  162. data/lib/google/rpc/error_details.rb +0 -61
  163. data/lib/google/rpc/status.rb +0 -19
  164. data/lib/google/type/color.rb +0 -20
  165. data/lib/google/type/date.rb +0 -18
  166. data/lib/google/type/dayofweek.rb +0 -23
  167. data/lib/google/type/latlng.rb +0 -17
  168. data/lib/google/type/money.rb +0 -18
  169. 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