gcloud 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +15 -0
  3. data/OVERVIEW.md +38 -5
  4. data/lib/gcloud.rb +55 -4
  5. data/lib/gcloud/bigquery/data.rb +2 -0
  6. data/lib/gcloud/bigquery/dataset.rb +1 -1
  7. data/lib/gcloud/bigquery/dataset/list.rb +2 -0
  8. data/lib/gcloud/bigquery/job/list.rb +2 -0
  9. data/lib/gcloud/bigquery/project.rb +2 -9
  10. data/lib/gcloud/bigquery/table/list.rb +2 -0
  11. data/lib/gcloud/datastore.rb +23 -28
  12. data/lib/gcloud/datastore/connection.rb +3 -1
  13. data/lib/gcloud/datastore/dataset.rb +167 -22
  14. data/lib/gcloud/datastore/dataset/lookup_results.rb +2 -0
  15. data/lib/gcloud/datastore/dataset/query_results.rb +2 -0
  16. data/lib/gcloud/datastore/entity.rb +11 -11
  17. data/lib/gcloud/datastore/key.rb +33 -16
  18. data/lib/gcloud/dns/change/list.rb +2 -0
  19. data/lib/gcloud/dns/project.rb +1 -1
  20. data/lib/gcloud/dns/record/list.rb +2 -0
  21. data/lib/gcloud/dns/zone.rb +2 -2
  22. data/lib/gcloud/dns/zone/list.rb +2 -0
  23. data/lib/gcloud/gce.rb +0 -5
  24. data/lib/gcloud/pubsub.rb +65 -62
  25. data/lib/gcloud/pubsub/connection.rb +20 -2
  26. data/lib/gcloud/pubsub/project.rb +233 -72
  27. data/lib/gcloud/pubsub/subscription.rb +45 -13
  28. data/lib/gcloud/pubsub/subscription/list.rb +2 -0
  29. data/lib/gcloud/pubsub/topic.rb +66 -85
  30. data/lib/gcloud/pubsub/topic/list.rb +2 -0
  31. data/lib/gcloud/resource_manager.rb +244 -0
  32. data/lib/gcloud/resource_manager/connection.rb +124 -0
  33. data/lib/gcloud/resource_manager/credentials.rb +30 -0
  34. data/lib/gcloud/resource_manager/errors.rb +64 -0
  35. data/lib/gcloud/resource_manager/manager.rb +319 -0
  36. data/lib/gcloud/resource_manager/project.rb +529 -0
  37. data/lib/gcloud/resource_manager/project/list.rb +91 -0
  38. data/lib/gcloud/resource_manager/project/updater.rb +137 -0
  39. data/lib/gcloud/storage/bucket.rb +1 -1
  40. data/lib/gcloud/storage/bucket/cors.rb +2 -0
  41. data/lib/gcloud/storage/bucket/list.rb +2 -0
  42. data/lib/gcloud/storage/file/list.rb +2 -0
  43. data/lib/gcloud/storage/project.rb +1 -1
  44. data/lib/gcloud/version.rb +1 -1
  45. metadata +10 -2
@@ -90,9 +90,7 @@ module Gcloud
90
90
  #
91
91
  def topic
92
92
  ensure_gapi!
93
- # Always disable autocreate, we don't want to recreate a topic that
94
- # was intentionally deleted.
95
- Topic.new_lazy @gapi["topic"], connection, autocreate: false
93
+ Topic.new_lazy @gapi["topic"], connection
96
94
  end
97
95
 
98
96
  ##
@@ -193,9 +191,6 @@ module Gcloud
193
191
  end
194
192
  end
195
193
 
196
- # rubocop:disable Metrics/MethodLength
197
- # Disabled rubocop because these lines are needed.
198
-
199
194
  ##
200
195
  # Pulls messages from the server. Returns an empty list if there are no
201
196
  # messages available in the backlog. Raises an ApiError with status
@@ -271,8 +266,6 @@ module Gcloud
271
266
  []
272
267
  end
273
268
 
274
- # rubocop:enable Metrics/MethodLength
275
-
276
269
  ##
277
270
  # Pulls from the server while waiting for messages to become available.
278
271
  # This is the same as:
@@ -476,11 +469,11 @@ module Gcloud
476
469
  # A hash that conforms to the following structure:
477
470
  #
478
471
  # {
472
+ # "etag"=>"CAE=",
479
473
  # "bindings" => [{
480
474
  # "role" => "roles/viewer",
481
475
  # "members" => ["serviceAccount:your-service-account"]
482
- # }],
483
- # "rules" => []
476
+ # }]
484
477
  # }
485
478
  #
486
479
  # === Examples
@@ -513,7 +506,7 @@ module Gcloud
513
506
  @policy ||= begin
514
507
  ensure_connection!
515
508
  resp = connection.get_subscription_policy name
516
- policy = resp.data["policy"]
509
+ policy = resp.data
517
510
  policy = policy.to_hash if policy.respond_to? :to_hash
518
511
  policy
519
512
  end
@@ -531,8 +524,7 @@ module Gcloud
531
524
  # "bindings" => [{
532
525
  # "role" => "roles/viewer",
533
526
  # "members" => ["serviceAccount:your-service-account"]
534
- # }],
535
- # "rules" => []
527
+ # }]
536
528
  # }
537
529
  #
538
530
  # === Example
@@ -562,6 +554,46 @@ module Gcloud
562
554
  end
563
555
  end
564
556
 
557
+ ##
558
+ # Tests the specified permissions against the {Cloud
559
+ # IAM}[https://cloud.google.com/iam/] access control policy. See
560
+ # {Managing Policies}[https://cloud.google.com/iam/docs/managing-policies]
561
+ # for more information.
562
+ #
563
+ # === Parameters
564
+ #
565
+ # +permissions+::
566
+ # The set of permissions to check access for. Permissions with wildcards
567
+ # (such as +*+ or +storage.*+) are not allowed.
568
+ # (String or Array of Strings)
569
+ #
570
+ # === Returns
571
+ #
572
+ # The permissions that have access. (Array of Strings)
573
+ #
574
+ # === Example
575
+ #
576
+ # require "gcloud"
577
+ #
578
+ # gcloud = Gcloud.new
579
+ # pubsub = gcloud.pubsub
580
+ # sub = pubsub.subscription "my-subscription"
581
+ # perms = sub.test_permissions "projects.subscriptions.list",
582
+ # "projects.subscriptions.pull"
583
+ # perms.include? "projects.subscriptions.list" #=> true
584
+ # perms.include? "projects.subscriptions.pull" #=> false
585
+ #
586
+ def test_permissions *permissions
587
+ permissions = Array(permissions).flatten
588
+ ensure_connection!
589
+ resp = connection.test_subscription_permissions name, permissions
590
+ if resp.success?
591
+ Array(resp.data["permissions"])
592
+ else
593
+ fail ApiError.from_response(resp)
594
+ end
595
+ end
596
+
565
597
  ##
566
598
  # New Subscription from a Google API Client object.
567
599
  def self.from_gapi gapi, conn #:nodoc:
@@ -13,6 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ require "delegate"
17
+
16
18
  module Gcloud
17
19
  module Pubsub
18
20
  class Subscription
@@ -48,20 +48,17 @@ module Gcloud
48
48
  @connection = nil
49
49
  @gapi = {}
50
50
  @name = nil
51
- @autocreate = nil
52
51
  @exists = nil
53
52
  end
54
53
 
55
54
  ##
56
55
  # New lazy Topic object without making an HTTP request.
57
56
  def self.new_lazy name, conn, options = {} #:nodoc:
58
- options[:autocreate] = true if options[:autocreate].nil?
59
57
  new.tap do |t|
60
58
  t.gapi = nil
61
59
  t.connection = conn
62
60
  t.instance_eval do
63
61
  @name = conn.topic_path(name, options)
64
- @autocreate = options[:autocreate]
65
62
  end
66
63
  end
67
64
  end
@@ -167,27 +164,28 @@ module Gcloud
167
164
  else
168
165
  fail ApiError.from_response(resp)
169
166
  end
170
- rescue Gcloud::Pubsub::NotFoundError => e
171
- retry if lazily_create_topic!
172
- raise e
173
167
  end
174
168
  alias_method :create_subscription, :subscribe
175
169
  alias_method :new_subscription, :subscribe
176
170
 
177
171
  ##
178
172
  # Retrieves subscription by name.
179
- # The difference between this method and Topic#get_subscription is
180
- # that this method does not make an API call to Pub/Sub to verify the
181
- # subscription exists.
182
173
  #
183
174
  # === Parameters
184
175
  #
185
176
  # +subscription_name+::
186
177
  # Name of a subscription. (+String+)
178
+ # +options+::
179
+ # An optional Hash for controlling additional behavior. (+Hash+)
180
+ # <code>options[:skip_lookup]</code>::
181
+ # Optionally create a Subscription object without verifying the
182
+ # subscription resource exists on the Pub/Sub service. Calls made on
183
+ # this object will raise errors if the service resource does not exist.
184
+ # Default is +false+. (+Boolean+)
187
185
  #
188
186
  # === Returns
189
187
  #
190
- # Gcloud::Pubsub::Subscription
188
+ # Gcloud::Pubsub::Subscription or nil if subscription does not exist
191
189
  #
192
190
  # === Example
193
191
  #
@@ -200,48 +198,30 @@ module Gcloud
200
198
  # subscription = topic.subscription "my-topic-subscription"
201
199
  # puts subscription.name
202
200
  #
203
- def subscription subscription_name
204
- ensure_connection!
205
-
206
- Subscription.new_lazy subscription_name, connection
207
- end
208
-
209
- ##
210
- # Retrieves a subscription by name.
211
- # The difference between this method and Topic#subscription is that
212
- # this method makes an API call to Pub/Sub to verify the subscription
213
- # exists.
214
- #
215
- # === Parameters
216
- #
217
- # +subscription_name+::
218
- # Name of a subscription. (+String+)
219
- #
220
- # === Returns
221
- #
222
- # Gcloud::Pubsub::Subscription or nil if subscription does not exist
223
- #
224
- # === Example
201
+ # The lookup against the Pub/Sub service can be skipped using the
202
+ # +skip_lookup+ option:
225
203
  #
226
204
  # require "gcloud"
227
205
  #
228
206
  # gcloud = Gcloud.new
229
207
  # pubsub = gcloud.pubsub
230
208
  #
231
- # topic = pubsub.topic "my-topic"
232
- # subscription = topic.get_subscription "my-topic-subscription"
209
+ # # No API call is made to retrieve the subscription information.
210
+ # subscription = pubsub.subscription "my-sub", skip_lookup: true
233
211
  # puts subscription.name
234
212
  #
235
- def get_subscription subscription_name
213
+ def subscription subscription_name, options = {}
236
214
  ensure_connection!
237
- resp = connection.get_subscription subscription_name
238
- if resp.success?
239
- Subscription.from_gapi resp.data, connection
240
- else
241
- nil
215
+ if options[:skip_lookup]
216
+ return Subscription.new_lazy(subscription_name, connection, options)
242
217
  end
218
+ resp = connection.get_subscription subscription_name
219
+ return Subscription.from_gapi(resp.data, connection) if resp.success?
220
+ return nil if resp.status == 404
221
+ fail ApiError.from_response(resp)
243
222
  end
244
- alias_method :find_subscription, :get_subscription
223
+ alias_method :get_subscription, :subscription
224
+ alias_method :find_subscription, :subscription
245
225
 
246
226
  ##
247
227
  # Retrieves a list of subscription names for the given project.
@@ -259,7 +239,7 @@ module Gcloud
259
239
  #
260
240
  # === Returns
261
241
  #
262
- # Array of Subscription objects (Subscription::List)
242
+ # Array of Subscription objects (See Subscription::List)
263
243
  #
264
244
  # === Examples
265
245
  #
@@ -364,9 +344,6 @@ module Gcloud
364
344
  yield batch if block_given?
365
345
  return nil if batch.messages.count.zero?
366
346
  publish_batch_messages batch
367
- rescue Gcloud::Pubsub::NotFoundError => e
368
- retry if lazily_create_topic!
369
- raise e
370
347
  end
371
348
 
372
349
  ##
@@ -387,11 +364,11 @@ module Gcloud
387
364
  # A hash that conforms to the following structure:
388
365
  #
389
366
  # {
367
+ # "etag"=>"CAE=",
390
368
  # "bindings" => [{
391
369
  # "role" => "roles/viewer",
392
370
  # "members" => ["serviceAccount:your-service-account"]
393
- # }],
394
- # "rules" => []
371
+ # }]
395
372
  # }
396
373
  #
397
374
  # === Examples
@@ -424,7 +401,7 @@ module Gcloud
424
401
  @policy ||= begin
425
402
  ensure_connection!
426
403
  resp = connection.get_topic_policy name
427
- policy = resp.data["policy"]
404
+ policy = resp.data
428
405
  policy = policy.to_hash if policy.respond_to? :to_hash
429
406
  policy
430
407
  end
@@ -442,8 +419,7 @@ module Gcloud
442
419
  # "bindings" => [{
443
420
  # "role" => "roles/viewer",
444
421
  # "members" => ["serviceAccount:your-service-account"]
445
- # }],
446
- # "rules" => []
422
+ # }]
447
423
  # }
448
424
  #
449
425
  # === Example
@@ -473,6 +449,46 @@ module Gcloud
473
449
  end
474
450
  end
475
451
 
452
+ ##
453
+ # Tests the specified permissions against the {Cloud
454
+ # IAM}[https://cloud.google.com/iam/] access control policy. See
455
+ # {Managing Policies}[https://cloud.google.com/iam/docs/managing-policies]
456
+ # for more information.
457
+ #
458
+ # === Parameters
459
+ #
460
+ # +permissions+::
461
+ # The set of permissions to check access for. Permissions with wildcards
462
+ # (such as +*+ or +storage.*+) are not allowed.
463
+ # (String or Array of Strings)
464
+ #
465
+ # === Returns
466
+ #
467
+ # The permissions that have access. (Array of Strings)
468
+ #
469
+ # === Example
470
+ #
471
+ # require "gcloud"
472
+ #
473
+ # gcloud = Gcloud.new
474
+ # pubsub = gcloud.pubsub
475
+ # topic = pubsub.topic "my-topic"
476
+ # perms = topic.test_permissions "projects.topic.list",
477
+ # "projects.topic.publish"
478
+ # perms.include? "projects.topic.list" #=> true
479
+ # perms.include? "projects.topic.publish" #=> false
480
+ #
481
+ def test_permissions *permissions
482
+ permissions = Array(permissions).flatten
483
+ ensure_connection!
484
+ resp = connection.test_topic_permissions name, permissions
485
+ if resp.success?
486
+ Array(resp.data["permissions"])
487
+ else
488
+ fail ApiError.from_response(resp)
489
+ end
490
+ end
491
+
476
492
  ##
477
493
  # Determines whether the topic exists in the Pub/Sub service.
478
494
  #
@@ -512,29 +528,6 @@ module Gcloud
512
528
  @gapi.nil?
513
529
  end
514
530
 
515
- # rubocop:disable Style/TrivialAccessors
516
- # Disabled rubocop because you can't use "?" in an attr.
517
-
518
- ##
519
- # Determines whether the lazy topic object should create a topic on the
520
- # Pub/Sub service.
521
- #
522
- # === Example
523
- #
524
- # require "gcloud"
525
- #
526
- # gcloud = Gcloud.new
527
- # pubsub = gcloud.pubsub
528
- #
529
- # topic = pubsub.topic "my-topic"
530
- # topic.autocreate? #=> true
531
- #
532
- def autocreate? #:nodoc:
533
- @autocreate
534
- end
535
-
536
- # rubocop:enable Style/TrivialAccessors
537
-
538
531
  ##
539
532
  # New Topic from a Google API Client object.
540
533
  def self.from_gapi gapi, conn #:nodoc:
@@ -561,18 +554,6 @@ module Gcloud
561
554
  @gapi = resp.data if resp.success?
562
555
  end
563
556
 
564
- ##
565
- def lazily_create_topic!
566
- if lazy? && autocreate?
567
- resp = connection.create_topic name
568
- if resp.success?
569
- @gapi = resp.data
570
- return true
571
- end
572
- end
573
- nil
574
- end
575
-
576
557
  ##
577
558
  # Call the publish API with arrays of data data and attrs.
578
559
  def publish_batch_messages batch
@@ -13,6 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
+ require "delegate"
17
+
16
18
  module Gcloud
17
19
  module Pubsub
18
20
  class Topic
@@ -0,0 +1,244 @@
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
+ require "gcloud"
16
+ require "gcloud/resource_manager/manager"
17
+
18
+ #--
19
+ # Google Cloud Resource Manager
20
+ module Gcloud
21
+ ##
22
+ # Creates a new +Project+ instance connected to the Resource Manager service.
23
+ # Each call creates a new connection.
24
+ #
25
+ # === Parameters
26
+ #
27
+ # +keyfile+::
28
+ # Keyfile downloaded from Google Cloud. If file path the file must be
29
+ # readable. (+String+ or +Hash+)
30
+ # +options+::
31
+ # An optional Hash for controlling additional behavior. (+Hash+)
32
+ # <code>options[:scope]</code>::
33
+ # The OAuth 2.0 scopes controlling the set of resources and operations that
34
+ # the connection can access. See {Using OAuth 2.0 to Access Google
35
+ # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
36
+ # or +Array+)
37
+ #
38
+ # The default scope is:
39
+ #
40
+ # * +https://www.googleapis.com/auth/cloud-platform+
41
+ #
42
+ # === Returns
43
+ #
44
+ # Gcloud::ResourceManager::Manager
45
+ #
46
+ # === Example
47
+ #
48
+ # require "gcloud/resource_manager"
49
+ #
50
+ # resource_manager = Gcloud.resource_manager
51
+ # resource_manager.projects.each do |project|
52
+ # puts projects.project_id
53
+ # end
54
+ #
55
+ def self.resource_manager keyfile = nil, options = {}
56
+ if keyfile.nil?
57
+ credentials = Gcloud::ResourceManager::Credentials.default options
58
+ else
59
+ credentials = Gcloud::ResourceManager::Credentials.new keyfile, options
60
+ end
61
+ Gcloud::ResourceManager::Manager.new credentials
62
+ end
63
+
64
+ # rubocop:disable Metrics/LineLength
65
+ # Disabled because there are links in the docs that are long.
66
+
67
+ ##
68
+ # = Google Cloud Resource Manager
69
+ #
70
+ # The Resource Manager API provides methods that you can use to
71
+ # programmatically manage your projects in the Google Cloud Platform. You may
72
+ # be familiar with managing projects in the {Developers
73
+ # Console}[https://developers.google.com/console/help/new/]. With this API you
74
+ # can do the following:
75
+ #
76
+ # * Get a list of all projects associated with an account
77
+ # * Create new projects
78
+ # * Update existing projects
79
+ # * Delete projects
80
+ # * Undelete, or recover, projects that you don't want to delete
81
+ #
82
+ # The Resource Manager API is a Beta release and is not covered by any SLA or
83
+ # deprecation policy and may be subject to backward-incompatible changes.
84
+ #
85
+ # == Accessing the Service
86
+ #
87
+ # Currently, the full functionality of the Resource Manager API is available
88
+ # only to whitelisted users. (Contact your account manager or a member of the
89
+ # Google Cloud sales team if you are interested in access.) Read-only methods
90
+ # such as ResourceManager::Manager#projects and
91
+ # ResourceManager::Manager#project are accessible to any user who enables the
92
+ # Resource Manager API in the {Developers
93
+ # Console}[https://console.developers.google.com].
94
+ #
95
+ # == Authentication
96
+ #
97
+ # The Resource Manager API currently requires authentication of a {User
98
+ # Account}[https://developers.google.com/identity/protocols/OAuth2], and
99
+ # cannot currently be accessed with a {Service
100
+ # Account}[https://developers.google.com/identity/protocols/OAuth2ServiceAccount].
101
+ # To use a User Account install the {Google Cloud
102
+ # SDK}[http://cloud.google.com/sdk] and authenticate with the following:
103
+ #
104
+ # $ gcloud auth login
105
+ #
106
+ # Also make sure all +GCLOUD+ environment variables are cleared of any service
107
+ # accounts. Then gcloud will be able to detect the user authentication and
108
+ # connect with those credentials.
109
+ #
110
+ # require "gcloud"
111
+ #
112
+ # gcloud = Gcloud.new
113
+ # resource_manager = gcloud.resource_manager
114
+ #
115
+ # == Listing Projects
116
+ #
117
+ # Project is a collection of settings, credentials, and metadata about the
118
+ # application or applications you're working on. You can retrieve and inspect
119
+ # all projects that you have permissions to. (See Manager#projects)
120
+ #
121
+ # require "gcloud"
122
+ #
123
+ # gcloud = Gcloud.new
124
+ # resource_manager = gcloud.resource_manager
125
+ # resource_manager.projects.each do |project|
126
+ # puts projects.project_id
127
+ # end
128
+ #
129
+ # == Managing Projects with Labels
130
+ #
131
+ # Labels can be added to or removed from projects. (See Project#labels)
132
+ #
133
+ # require "gcloud"
134
+ #
135
+ # gcloud = Gcloud.new
136
+ # resource_manager = gcloud.resource_manager
137
+ # project = resource_manager.project "tokyo-rain-123"
138
+ # # Label the project as production
139
+ # project.update do |p|
140
+ # p.labels["env"] = "production"
141
+ # end
142
+ #
143
+ # Projects can then be filtered by labels. (See Manager#projects)
144
+ #
145
+ # require "gcloud"
146
+ #
147
+ # gcloud = Gcloud.new
148
+ # resource_manager = gcloud.resource_manager
149
+ # # Find only the productions projects
150
+ # projects = resource_manager.projects filter: "labels.env:production"
151
+ # projects.each do |project|
152
+ # puts project.project_id
153
+ # end
154
+ #
155
+ # == Creating a Project
156
+ #
157
+ # You can also use the API to create new projects. (See
158
+ # Manager#create_project)
159
+ #
160
+ # require "gcloud"
161
+ #
162
+ # gcloud = Gcloud.new
163
+ # resource_manager = gcloud.resource_manager
164
+ # project = resource_manager.create_project "tokyo-rain-123",
165
+ # name: "Todos Development",
166
+ # labels: {env: :development}
167
+ #
168
+ # == Deleting a Project
169
+ #
170
+ # You can delete projects when they are no longer needed. (See
171
+ # Manager#delete and Project#delete)
172
+ #
173
+ # require "gcloud"
174
+ #
175
+ # gcloud = Gcloud.new
176
+ # resource_manager = gcloud.resource_manager
177
+ # resource_manager.delete "tokyo-rain-123"
178
+ #
179
+ # == Undeleting a Project
180
+ #
181
+ # You can also restore a deleted project within the waiting period that
182
+ # starts when the project was deleted. Restoring a project returns it to the
183
+ # state it was in prior to being deleted. (See Manager#undelete and
184
+ # Project#undelete)
185
+ #
186
+ # require "gcloud"
187
+ #
188
+ # gcloud = Gcloud.new
189
+ # resource_manager = gcloud.resource_manager
190
+ # resource_manager.undelete "tokyo-rain-123"
191
+ #
192
+ # == Managing IAM Policies
193
+ #
194
+ # Google Cloud Identity and Access Management ({Cloud
195
+ # IAM}[https://cloud.google.com/iam/]) access control policies can be managed
196
+ # on projects. These policies allow project owners to manage _who_ (identity)
197
+ # has access to _what_ (role). See {Cloud IAM
198
+ # Overview}[https://cloud.google.com/iam/docs/overview] for more information.
199
+ #
200
+ # A project's access control policy can be retrieved. (See Project#policy)
201
+ #
202
+ # require "gcloud"
203
+ #
204
+ # gcloud = Gcloud.new
205
+ # resource_manager = gcloud.resource_manager
206
+ # project = resource_manager.project "tokyo-rain-123"
207
+ # policy = project.policy
208
+ #
209
+ # A project's access control policy can also be set. (See Project#policy=)
210
+ #
211
+ # require "gcloud"
212
+ #
213
+ # gcloud = Gcloud.new
214
+ # resource_manager = gcloud.resource_manager
215
+ # project = resource_manager.project "tokyo-rain-123"
216
+ #
217
+ # viewer_policy = {
218
+ # "bindings" => [{
219
+ # "role" => "roles/viewer",
220
+ # "members" => ["serviceAccount:your-service-account"]
221
+ # }]
222
+ # }
223
+ # project.policy = viewer_policy
224
+ #
225
+ # And permissions can be tested on a project. (See Project#test_permissions)
226
+ #
227
+ # require "gcloud"
228
+ #
229
+ # gcloud = Gcloud.new
230
+ # resource_manager = gcloud.resource_manager
231
+ # project = resource_manager.project "tokyo-rain-123"
232
+ # perms = project.test_permissions "resourcemanager.projects.get",
233
+ # "resourcemanager.projects.delete"
234
+ # perms.include? "resourcemanager.projects.get" #=> true
235
+ # perms.include? "resourcemanager.projects.delete" #=> false
236
+ #
237
+ # For more information about using access control policies see {Managing
238
+ # Policies}[https://cloud.google.com/iam/docs/managing-policies].
239
+ #
240
+ module ResourceManager
241
+ end
242
+
243
+ # rubocop:enable Metrics/LineLength
244
+ end