gcloud 0.6.3 → 0.7.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 (175) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +13 -9
  3. data/CHANGELOG.md +8 -3
  4. data/OVERVIEW.md +46 -8
  5. data/lib/gcloud.rb +123 -117
  6. data/lib/gcloud/backoff.rb +43 -15
  7. data/lib/gcloud/bigquery.rb +211 -195
  8. data/lib/gcloud/bigquery/connection.rb +9 -9
  9. data/lib/gcloud/bigquery/copy_job.rb +15 -16
  10. data/lib/gcloud/bigquery/credentials.rb +3 -3
  11. data/lib/gcloud/bigquery/data.rb +12 -11
  12. data/lib/gcloud/bigquery/dataset.rb +162 -216
  13. data/lib/gcloud/bigquery/dataset/access.rb +59 -43
  14. data/lib/gcloud/bigquery/dataset/list.rb +3 -3
  15. data/lib/gcloud/bigquery/errors.rb +9 -5
  16. data/lib/gcloud/bigquery/extract_job.rb +18 -18
  17. data/lib/gcloud/bigquery/insert_response.rb +7 -4
  18. data/lib/gcloud/bigquery/job.rb +48 -44
  19. data/lib/gcloud/bigquery/job/list.rb +3 -3
  20. data/lib/gcloud/bigquery/load_job.rb +24 -25
  21. data/lib/gcloud/bigquery/project.rb +145 -204
  22. data/lib/gcloud/bigquery/query_data.rb +10 -9
  23. data/lib/gcloud/bigquery/query_job.rb +23 -32
  24. data/lib/gcloud/bigquery/table.rb +238 -280
  25. data/lib/gcloud/bigquery/table/list.rb +3 -3
  26. data/lib/gcloud/bigquery/table/schema.rb +79 -87
  27. data/lib/gcloud/bigquery/view.rb +69 -82
  28. data/lib/gcloud/credentials.rb +3 -9
  29. data/lib/gcloud/datastore.rb +194 -170
  30. data/lib/gcloud/datastore/connection.rb +12 -8
  31. data/lib/gcloud/datastore/credentials.rb +6 -4
  32. data/lib/gcloud/datastore/dataset.rb +74 -141
  33. data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
  34. data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
  35. data/lib/gcloud/datastore/entity.rb +81 -76
  36. data/lib/gcloud/datastore/errors.rb +10 -8
  37. data/lib/gcloud/datastore/key.rb +41 -77
  38. data/lib/gcloud/datastore/properties.rb +3 -3
  39. data/lib/gcloud/datastore/proto.rb +7 -4
  40. data/lib/gcloud/datastore/query.rb +26 -3
  41. data/lib/gcloud/datastore/transaction.rb +12 -8
  42. data/lib/gcloud/dns.rb +180 -152
  43. data/lib/gcloud/dns/change.rb +16 -16
  44. data/lib/gcloud/dns/change/list.rb +3 -3
  45. data/lib/gcloud/dns/connection.rb +9 -10
  46. data/lib/gcloud/dns/credentials.rb +3 -3
  47. data/lib/gcloud/dns/errors.rb +9 -5
  48. data/lib/gcloud/dns/importer.rb +17 -23
  49. data/lib/gcloud/dns/project.rb +42 -64
  50. data/lib/gcloud/dns/record.rb +58 -46
  51. data/lib/gcloud/dns/record/list.rb +6 -7
  52. data/lib/gcloud/dns/zone.rb +198 -289
  53. data/lib/gcloud/dns/zone/list.rb +3 -3
  54. data/lib/gcloud/dns/zone/transaction.rb +56 -72
  55. data/lib/gcloud/errors.rb +174 -3
  56. data/lib/gcloud/gce.rb +3 -4
  57. data/lib/gcloud/grpc_utils.rb +76 -0
  58. data/lib/gcloud/logging.rb +308 -0
  59. data/lib/gcloud/logging/credentials.rb +29 -0
  60. data/lib/gcloud/logging/entry.rb +303 -0
  61. data/lib/gcloud/logging/entry/http_request.rb +141 -0
  62. data/lib/gcloud/logging/entry/list.rb +111 -0
  63. data/lib/gcloud/logging/entry/operation.rb +90 -0
  64. data/lib/gcloud/logging/logger.rb +307 -0
  65. data/lib/gcloud/logging/metric.rb +175 -0
  66. data/lib/gcloud/logging/metric/list.rb +98 -0
  67. data/lib/gcloud/logging/project.rb +650 -0
  68. data/lib/gcloud/logging/resource.rb +95 -0
  69. data/lib/gcloud/logging/resource_descriptor.rb +140 -0
  70. data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
  71. data/lib/gcloud/logging/service.rb +258 -0
  72. data/lib/gcloud/logging/sink.rb +233 -0
  73. data/lib/gcloud/logging/sink/list.rb +97 -0
  74. data/lib/gcloud/pubsub.rb +241 -199
  75. data/lib/gcloud/pubsub/credentials.rb +3 -3
  76. data/lib/gcloud/pubsub/message.rb +26 -20
  77. data/lib/gcloud/pubsub/project.rb +166 -233
  78. data/lib/gcloud/pubsub/received_message.rb +28 -38
  79. data/lib/gcloud/pubsub/service.rb +323 -0
  80. data/lib/gcloud/pubsub/subscription.rb +172 -242
  81. data/lib/gcloud/pubsub/subscription/list.rb +11 -9
  82. data/lib/gcloud/pubsub/topic.rb +152 -271
  83. data/lib/gcloud/pubsub/topic/batch.rb +66 -0
  84. data/lib/gcloud/pubsub/topic/list.rb +9 -7
  85. data/lib/gcloud/resource_manager.rb +158 -138
  86. data/lib/gcloud/resource_manager/connection.rb +6 -5
  87. data/lib/gcloud/resource_manager/credentials.rb +3 -3
  88. data/lib/gcloud/resource_manager/errors.rb +9 -5
  89. data/lib/gcloud/resource_manager/manager.rb +54 -86
  90. data/lib/gcloud/resource_manager/project.rb +69 -88
  91. data/lib/gcloud/resource_manager/project/list.rb +4 -5
  92. data/lib/gcloud/resource_manager/project/updater.rb +12 -14
  93. data/lib/gcloud/search.rb +158 -135
  94. data/lib/gcloud/search/api_client.rb +7 -7
  95. data/lib/gcloud/search/connection.rb +8 -8
  96. data/lib/gcloud/search/credentials.rb +3 -3
  97. data/lib/gcloud/search/document.rb +64 -87
  98. data/lib/gcloud/search/document/list.rb +5 -5
  99. data/lib/gcloud/search/errors.rb +9 -5
  100. data/lib/gcloud/search/field_value.rb +32 -38
  101. data/lib/gcloud/search/field_values.rb +50 -80
  102. data/lib/gcloud/search/fields.rb +44 -65
  103. data/lib/gcloud/search/index.rb +163 -204
  104. data/lib/gcloud/search/index/list.rb +5 -5
  105. data/lib/gcloud/search/project.rb +31 -47
  106. data/lib/gcloud/search/result.rb +27 -31
  107. data/lib/gcloud/search/result/list.rb +6 -6
  108. data/lib/gcloud/storage.rb +224 -190
  109. data/lib/gcloud/storage/bucket.rb +202 -227
  110. data/lib/gcloud/storage/bucket/acl.rb +83 -170
  111. data/lib/gcloud/storage/bucket/cors.rb +31 -34
  112. data/lib/gcloud/storage/bucket/list.rb +3 -3
  113. data/lib/gcloud/storage/connection.rb +11 -7
  114. data/lib/gcloud/storage/credentials.rb +3 -3
  115. data/lib/gcloud/storage/errors.rb +11 -8
  116. data/lib/gcloud/storage/file.rb +129 -171
  117. data/lib/gcloud/storage/file/acl.rb +51 -99
  118. data/lib/gcloud/storage/file/list.rb +3 -3
  119. data/lib/gcloud/storage/file/verifier.rb +3 -2
  120. data/lib/gcloud/storage/project.rb +111 -132
  121. data/lib/gcloud/upload.rb +4 -7
  122. data/lib/gcloud/version.rb +2 -4
  123. data/lib/google/api/annotations.rb +14 -0
  124. data/lib/google/api/http.rb +30 -0
  125. data/lib/google/api/label.rb +24 -0
  126. data/lib/google/api/monitored_resource.rb +25 -0
  127. data/lib/google/datastore/v1beta3/datastore.rb +115 -0
  128. data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
  129. data/lib/google/datastore/v1beta3/entity.rb +63 -0
  130. data/lib/google/datastore/v1beta3/query.rb +128 -0
  131. data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
  132. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
  133. data/lib/google/example/library/v1/library.rb +91 -0
  134. data/lib/google/example/library/v1/library_services.rb +40 -0
  135. data/lib/google/iam/v1/iam_policy.rb +33 -0
  136. data/lib/google/iam/v1/iam_policy_services.rb +30 -0
  137. data/lib/google/iam/v1/policy.rb +25 -0
  138. data/lib/google/logging/type/http_request.rb +28 -0
  139. data/lib/google/logging/type/log_severity.rb +27 -0
  140. data/lib/google/logging/v2/log_entry.rb +44 -0
  141. data/lib/google/logging/v2/logging.rb +56 -0
  142. data/lib/google/logging/v2/logging_config.rb +59 -0
  143. data/lib/google/logging/v2/logging_config_services.rb +32 -0
  144. data/lib/google/logging/v2/logging_metrics.rb +51 -0
  145. data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
  146. data/lib/google/logging/v2/logging_services.rb +31 -0
  147. data/lib/google/longrunning/operations.rb +50 -0
  148. data/lib/google/longrunning/operations_services.rb +29 -0
  149. data/lib/google/protobuf/any.rb +17 -0
  150. data/lib/google/protobuf/api.rb +31 -0
  151. data/lib/google/protobuf/descriptor.rb +0 -0
  152. data/lib/google/protobuf/duration.rb +17 -0
  153. data/lib/google/protobuf/empty.rb +15 -0
  154. data/lib/google/protobuf/field_mask.rb +16 -0
  155. data/lib/google/protobuf/source_context.rb +16 -0
  156. data/lib/google/protobuf/struct.rb +35 -0
  157. data/lib/google/protobuf/timestamp.rb +17 -0
  158. data/lib/google/protobuf/type.rb +79 -0
  159. data/lib/google/protobuf/wrappers.rb +48 -0
  160. data/lib/google/pubsub/v1/pubsub.rb +129 -0
  161. data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
  162. data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
  163. data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
  164. data/lib/google/rpc/code.rb +32 -0
  165. data/lib/google/rpc/error_details.rb +61 -0
  166. data/lib/google/rpc/status.rb +19 -0
  167. data/lib/google/type/color.rb +20 -0
  168. data/lib/google/type/date.rb +18 -0
  169. data/lib/google/type/dayofweek.rb +23 -0
  170. data/lib/google/type/latlng.rb +17 -0
  171. data/lib/google/type/money.rb +18 -0
  172. data/lib/google/type/timeofday.rb +19 -0
  173. metadata +101 -4
  174. data/lib/gcloud/pubsub/connection.rb +0 -295
  175. data/lib/gcloud/pubsub/errors.rb +0 -93
@@ -0,0 +1,66 @@
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 Pubsub
18
+ class Topic
19
+ ##
20
+ # Batch object used to publish multiple messages at once.
21
+ class Batch
22
+ ##
23
+ # @private The messages to publish
24
+ attr_reader :messages
25
+
26
+ ##
27
+ # @private Create a new instance of the object.
28
+ def initialize data = nil, attributes = {}
29
+ @messages = []
30
+ @mode = :batch
31
+ return if data.nil?
32
+ @mode = :single
33
+ publish data, attributes
34
+ end
35
+
36
+ ##
37
+ # Add multiple messages to the topic.
38
+ # All messages added will be published at once.
39
+ # See {Gcloud::Pubsub::Topic#publish}
40
+ def publish data, attributes = {}
41
+ # Convert attributes to strings to match the protobuf definition
42
+ attributes = Hash[attributes.map { |k, v| [String(k), String(v)] }]
43
+ @messages << [data, attributes]
44
+ end
45
+
46
+ ##
47
+ # @private Create Message objects with message ids.
48
+ def to_gcloud_messages message_ids
49
+ msgs = @messages.zip(Array(message_ids)).map do |arr, id|
50
+ Message.from_grpc(Google::Pubsub::V1::PubsubMessage.new(
51
+ data: [arr[0]].pack("m").encode("ASCII-8BIT"),
52
+ attributes: arr[1],
53
+ message_id: id))
54
+ end
55
+ # Return just one Message if a single publish,
56
+ # otherwise return the array of Messages.
57
+ if @mode == :single && msgs.count <= 1
58
+ msgs.first
59
+ else
60
+ msgs
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "delegate"
17
17
 
18
18
  module Gcloud
@@ -24,7 +24,7 @@ module Gcloud
24
24
  ##
25
25
  # If not empty, indicates that there are more topics
26
26
  # that match the request and this value should be passed to
27
- # the next Gcloud::PubSub::Project#topics to continue.
27
+ # the next {Gcloud::Pubsub::Project#topics} to continue.
28
28
  attr_accessor :token
29
29
 
30
30
  ##
@@ -32,15 +32,17 @@ module Gcloud
32
32
  def initialize arr = [], token = nil
33
33
  super arr
34
34
  @token = token
35
+ @token = nil if @token == ""
35
36
  end
36
37
 
37
38
  ##
38
- # New Topic::List from a response object.
39
- def self.from_response resp, conn #:nodoc:
40
- topics = Array(resp.data["topics"]).map do |gapi_object|
41
- Topic.from_gapi gapi_object, conn
39
+ # @private New Topic::List from a Google::Pubsub::V1::ListTopicsResponse
40
+ # object.
41
+ def self.from_grpc grpc_list, service
42
+ topics = Array(grpc_list.topics).map do |grpc|
43
+ Topic.from_grpc grpc, service
42
44
  end
43
- new topics, resp.data["nextPageToken"]
45
+ new topics, grpc_list.next_page_token
44
46
  end
45
47
  end
46
48
  end
@@ -12,37 +12,32 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  require "gcloud"
16
17
  require "gcloud/resource_manager/manager"
17
18
 
18
- #--
19
- # Google Cloud Resource Manager
20
19
  module Gcloud
21
20
  ##
22
- # Creates a new +Project+ instance connected to the Resource Manager service.
21
+ # Creates a new `Project` instance connected to the Resource Manager service.
23
22
  # Each call creates a new connection.
24
23
  #
25
- # === Parameters
24
+ # For more information on connecting to Google Cloud see the [Authentication
25
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
26
  #
27
- # +keyfile+::
28
- # Keyfile downloaded from Google Cloud. If file path the file must be
29
- # readable. (+String+ or +Hash+)
30
- # +scope+::
31
- # The OAuth 2.0 scopes controlling the set of resources and operations that
32
- # the connection can access. See {Using OAuth 2.0 to Access Google
33
- # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
34
- # or +Array+)
27
+ # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
28
+ # path the file must be readable.
29
+ # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
30
+ # set of resources and operations that the connection can access. See [Using
31
+ # OAuth 2.0 to Access Google
32
+ # APIs](https://developers.google.com/identity/protocols/OAuth2).
35
33
  #
36
34
  # The default scope is:
37
35
  #
38
- # * +https://www.googleapis.com/auth/cloud-platform+
39
- #
40
- # === Returns
41
- #
42
- # Gcloud::ResourceManager::Manager
36
+ # * `https://www.googleapis.com/auth/cloud-platform`
43
37
  #
44
- # === Example
38
+ # @return [Gcloud::ResourceManager::Manager]
45
39
  #
40
+ # @example
46
41
  # require "gcloud/resource_manager"
47
42
  #
48
43
  # resource_manager = Gcloud.resource_manager
@@ -60,16 +55,13 @@ module Gcloud
60
55
  Gcloud::ResourceManager::Manager.new credentials
61
56
  end
62
57
 
63
- # rubocop:disable Metrics/LineLength
64
- # Disabled because there are links in the docs that are long.
65
-
66
58
  ##
67
- # = Google Cloud Resource Manager
59
+ # # Google Cloud Resource Manager
68
60
  #
69
61
  # The Resource Manager API provides methods that you can use to
70
62
  # programmatically manage your projects in the Google Cloud Platform. You may
71
- # be familiar with managing projects in the {Developers
72
- # Console}[https://developers.google.com/console/help/new/]. With this API you
63
+ # be familiar with managing projects in the [Developers
64
+ # Console](https://developers.google.com/console/help/new/). With this API you
73
65
  # can do the following:
74
66
  #
75
67
  # * Get a list of all projects associated with an account
@@ -81,163 +73,191 @@ module Gcloud
81
73
  # The Resource Manager API is a Beta release and is not covered by any SLA or
82
74
  # deprecation policy and may be subject to backward-incompatible changes.
83
75
  #
84
- # == Accessing the Service
76
+ # ## Accessing the Service
85
77
  #
86
78
  # Currently, the full functionality of the Resource Manager API is available
87
79
  # only to whitelisted users. (Contact your account manager or a member of the
88
80
  # Google Cloud sales team if you are interested in access.) Read-only methods
89
- # such as ResourceManager::Manager#projects and
90
- # ResourceManager::Manager#project are accessible to any user who enables the
91
- # Resource Manager API in the {Developers
92
- # Console}[https://console.developers.google.com].
81
+ # such as {ResourceManager::Manager#projects} and
82
+ # {ResourceManager::Manager#project} are accessible to any user who enables
83
+ # the Resource Manager API in the [Developers
84
+ # Console](https://console.developers.google.com).
93
85
  #
94
- # == Authentication
86
+ # ## Authentication
95
87
  #
96
- # The Resource Manager API currently requires authentication of a {User
97
- # Account}[https://developers.google.com/identity/protocols/OAuth2], and
98
- # cannot currently be accessed with a {Service
99
- # Account}[https://developers.google.com/identity/protocols/OAuth2ServiceAccount].
100
- # To use a User Account install the {Google Cloud
101
- # SDK}[http://cloud.google.com/sdk] and authenticate with the following:
88
+ # The Resource Manager API currently requires authentication of a [User
89
+ # Account](https://developers.google.com/identity/protocols/OAuth2), and
90
+ # cannot currently be accessed with a [Service
91
+ # Account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).
92
+ # To use a User Account install the [Google Cloud
93
+ # SDK](http://cloud.google.com/sdk) and authenticate with the following:
102
94
  #
103
- # $ gcloud auth login
95
+ # ```
96
+ # $ gcloud auth login
97
+ # ```
104
98
  #
105
- # Also make sure all +GCLOUD+ environment variables are cleared of any service
99
+ # Also make sure all `GCLOUD` environment variables are cleared of any service
106
100
  # accounts. Then gcloud will be able to detect the user authentication and
107
101
  # connect with those credentials.
108
102
  #
109
- # require "gcloud"
103
+ # ```ruby
104
+ # require "gcloud"
110
105
  #
111
- # gcloud = Gcloud.new
112
- # resource_manager = gcloud.resource_manager
106
+ # gcloud = Gcloud.new
107
+ # resource_manager = gcloud.resource_manager
108
+ # ```
113
109
  #
114
- # == Listing Projects
110
+ # ## Listing Projects
115
111
  #
116
112
  # Project is a collection of settings, credentials, and metadata about the
117
113
  # application or applications you're working on. You can retrieve and inspect
118
- # all projects that you have permissions to. (See Manager#projects)
114
+ # all projects that you have permissions to. (See
115
+ # {Gcloud::ResourceManager::Manager#projects})
119
116
  #
120
- # require "gcloud"
117
+ # ```ruby
118
+ # require "gcloud"
121
119
  #
122
- # gcloud = Gcloud.new
123
- # resource_manager = gcloud.resource_manager
124
- # resource_manager.projects.each do |project|
125
- # puts projects.project_id
126
- # end
120
+ # gcloud = Gcloud.new
121
+ # resource_manager = gcloud.resource_manager
122
+ # resource_manager.projects.each do |project|
123
+ # puts projects.project_id
124
+ # end
125
+ # ```
127
126
  #
128
- # == Managing Projects with Labels
127
+ # ## Managing Projects with Labels
129
128
  #
130
- # Labels can be added to or removed from projects. (See Project#labels)
129
+ # Labels can be added to or removed from projects. (See
130
+ # {Gcloud::ResourceManager::Project#labels})
131
131
  #
132
- # require "gcloud"
132
+ # ```ruby
133
+ # require "gcloud"
133
134
  #
134
- # gcloud = Gcloud.new
135
- # resource_manager = gcloud.resource_manager
136
- # project = resource_manager.project "tokyo-rain-123"
137
- # # Label the project as production
138
- # project.update do |p|
139
- # p.labels["env"] = "production"
140
- # end
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
+ # ```
141
143
  #
142
- # Projects can then be filtered by labels. (See Manager#projects)
144
+ # Projects can then be filtered by labels. (See
145
+ # {Gcloud::ResourceManager::Manager#projects})
143
146
  #
144
- # require "gcloud"
147
+ # ```ruby
148
+ # require "gcloud"
145
149
  #
146
- # gcloud = Gcloud.new
147
- # resource_manager = gcloud.resource_manager
148
- # # Find only the productions projects
149
- # projects = resource_manager.projects filter: "labels.env:production"
150
- # projects.each do |project|
151
- # puts project.project_id
152
- # end
150
+ # gcloud = Gcloud.new
151
+ # resource_manager = gcloud.resource_manager
152
+ # # Find only the productions projects
153
+ # projects = resource_manager.projects filter: "labels.env:production"
154
+ # projects.each do |project|
155
+ # puts project.project_id
156
+ # end
157
+ # ```
153
158
  #
154
- # == Creating a Project
159
+ # ## Creating a Project
155
160
  #
156
161
  # You can also use the API to create new projects. (See
157
- # Manager#create_project)
162
+ # {Gcloud::ResourceManager::Manager#create_project})
158
163
  #
159
- # require "gcloud"
164
+ # ```ruby
165
+ # require "gcloud"
160
166
  #
161
- # gcloud = Gcloud.new
162
- # resource_manager = gcloud.resource_manager
163
- # project = resource_manager.create_project "tokyo-rain-123",
164
- # name: "Todos Development",
165
- # labels: {env: :development}
167
+ # gcloud = Gcloud.new
168
+ # resource_manager = gcloud.resource_manager
169
+ # project = resource_manager.create_project "tokyo-rain-123",
170
+ # name: "Todos Development",
171
+ # labels: {env: :development}
172
+ # ```
166
173
  #
167
- # == Deleting a Project
174
+ # ## Deleting a Project
168
175
  #
169
176
  # You can delete projects when they are no longer needed. (See
170
- # Manager#delete and Project#delete)
177
+ # {Gcloud::ResourceManager::Manager#delete} and
178
+ # {Gcloud::ResourceManager::Project#delete})
171
179
  #
172
- # require "gcloud"
180
+ # ```ruby
181
+ # require "gcloud"
173
182
  #
174
- # gcloud = Gcloud.new
175
- # resource_manager = gcloud.resource_manager
176
- # resource_manager.delete "tokyo-rain-123"
183
+ # gcloud = Gcloud.new
184
+ # resource_manager = gcloud.resource_manager
185
+ # resource_manager.delete "tokyo-rain-123"
186
+ # ```
177
187
  #
178
- # == Undeleting a Project
188
+ # ## Undeleting a Project
179
189
  #
180
- # You can also restore a deleted project within the waiting period that
181
- # starts when the project was deleted. Restoring a project returns it to the
182
- # state it was in prior to being deleted. (See Manager#undelete and
183
- # Project#undelete)
190
+ # You can also restore a deleted project within the waiting period that starts
191
+ # when the project was deleted. Restoring a project returns it to the state it
192
+ # was in prior to being deleted. (See
193
+ # {Gcloud::ResourceManager::Manager#undelete} and
194
+ # {Gcloud::ResourceManager::Project#undelete})
184
195
  #
185
- # require "gcloud"
196
+ # ```ruby
197
+ # require "gcloud"
186
198
  #
187
- # gcloud = Gcloud.new
188
- # resource_manager = gcloud.resource_manager
189
- # resource_manager.undelete "tokyo-rain-123"
199
+ # gcloud = Gcloud.new
200
+ # resource_manager = gcloud.resource_manager
201
+ # resource_manager.undelete "tokyo-rain-123"
202
+ # ```
190
203
  #
191
- # == Managing IAM Policies
204
+ # ## Managing IAM Policies
192
205
  #
193
- # Google Cloud Identity and Access Management ({Cloud
194
- # IAM}[https://cloud.google.com/iam/]) access control policies can be managed
206
+ # Google Cloud Identity and Access Management ([Cloud
207
+ # IAM](https://cloud.google.com/iam/)) access control policies can be managed
195
208
  # on projects. These policies allow project owners to manage _who_ (identity)
196
- # has access to _what_ (role). See {Cloud IAM
197
- # Overview}[https://cloud.google.com/iam/docs/overview] for more information.
198
- #
199
- # A project's access control policy can be retrieved. (See Project#policy)
200
- #
201
- # require "gcloud"
202
- #
203
- # gcloud = Gcloud.new
204
- # resource_manager = gcloud.resource_manager
205
- # project = resource_manager.project "tokyo-rain-123"
206
- # policy = project.policy
207
- #
208
- # A project's access control policy can also be set. (See Project#policy=)
209
- #
210
- # require "gcloud"
211
- #
212
- # gcloud = Gcloud.new
213
- # resource_manager = gcloud.resource_manager
214
- # project = resource_manager.project "tokyo-rain-123"
215
- #
216
- # viewer_policy = {
217
- # "bindings" => [{
218
- # "role" => "roles/viewer",
219
- # "members" => ["serviceAccount:your-service-account"]
220
- # }]
221
- # }
222
- # project.policy = viewer_policy
223
- #
224
- # And permissions can be tested on a project. (See Project#test_permissions)
225
- #
226
- # require "gcloud"
227
- #
228
- # gcloud = Gcloud.new
229
- # resource_manager = gcloud.resource_manager
230
- # project = resource_manager.project "tokyo-rain-123"
231
- # perms = project.test_permissions "resourcemanager.projects.get",
232
- # "resourcemanager.projects.delete"
233
- # perms.include? "resourcemanager.projects.get" #=> true
234
- # perms.include? "resourcemanager.projects.delete" #=> false
235
- #
236
- # For more information about using access control policies see {Managing
237
- # Policies}[https://cloud.google.com/iam/docs/managing-policies].
209
+ # has access to _what_ (role). See [Cloud IAM
210
+ # Overview](https://cloud.google.com/iam/docs/overview) for more information.
211
+ #
212
+ # A project's access control policy can be retrieved. (See
213
+ # {Gcloud::ResourceManager::Project#policy})
214
+ #
215
+ # ```ruby
216
+ # require "gcloud"
217
+ #
218
+ # gcloud = Gcloud.new
219
+ # resource_manager = gcloud.resource_manager
220
+ # project = resource_manager.project "tokyo-rain-123"
221
+ # policy = project.policy
222
+ # ```
223
+ #
224
+ # A project's access control policy can also be set. (See
225
+ # {Gcloud::ResourceManager::Project#policy=})
226
+ #
227
+ # ```ruby
228
+ # require "gcloud"
229
+ #
230
+ # gcloud = Gcloud.new
231
+ # resource_manager = gcloud.resource_manager
232
+ # project = resource_manager.project "tokyo-rain-123"
233
+ #
234
+ # viewer_policy = {
235
+ # "bindings" => [{
236
+ # "role" => "roles/viewer",
237
+ # "members" => ["serviceAccount:your-service-account"]
238
+ # }]
239
+ # }
240
+ # project.policy = viewer_policy
241
+ # ```
242
+ #
243
+ # And permissions can be tested on a project. (See
244
+ # {Gcloud::ResourceManager::Project#test_permissions})
245
+ #
246
+ # ```ruby
247
+ # require "gcloud"
248
+ #
249
+ # gcloud = Gcloud.new
250
+ # resource_manager = gcloud.resource_manager
251
+ # project = resource_manager.project "tokyo-rain-123"
252
+ # perms = project.test_permissions "resourcemanager.projects.get",
253
+ # "resourcemanager.projects.delete"
254
+ # perms.include? "resourcemanager.projects.get" #=> true
255
+ # perms.include? "resourcemanager.projects.delete" #=> false
256
+ # ```
257
+ #
258
+ # For more information about using access control policies see [Managing
259
+ # Policies](https://cloud.google.com/iam/docs/managing-policies).
238
260
  #
239
261
  module ResourceManager
240
262
  end
241
-
242
- # rubocop:enable Metrics/LineLength
243
263
  end