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.
- checksums.yaml +8 -8
- data/AUTHENTICATION.md +13 -9
- data/CHANGELOG.md +8 -3
- data/OVERVIEW.md +46 -8
- data/lib/gcloud.rb +123 -117
- data/lib/gcloud/backoff.rb +43 -15
- data/lib/gcloud/bigquery.rb +211 -195
- data/lib/gcloud/bigquery/connection.rb +9 -9
- data/lib/gcloud/bigquery/copy_job.rb +15 -16
- data/lib/gcloud/bigquery/credentials.rb +3 -3
- data/lib/gcloud/bigquery/data.rb +12 -11
- data/lib/gcloud/bigquery/dataset.rb +162 -216
- data/lib/gcloud/bigquery/dataset/access.rb +59 -43
- data/lib/gcloud/bigquery/dataset/list.rb +3 -3
- data/lib/gcloud/bigquery/errors.rb +9 -5
- data/lib/gcloud/bigquery/extract_job.rb +18 -18
- data/lib/gcloud/bigquery/insert_response.rb +7 -4
- data/lib/gcloud/bigquery/job.rb +48 -44
- data/lib/gcloud/bigquery/job/list.rb +3 -3
- data/lib/gcloud/bigquery/load_job.rb +24 -25
- data/lib/gcloud/bigquery/project.rb +145 -204
- data/lib/gcloud/bigquery/query_data.rb +10 -9
- data/lib/gcloud/bigquery/query_job.rb +23 -32
- data/lib/gcloud/bigquery/table.rb +238 -280
- data/lib/gcloud/bigquery/table/list.rb +3 -3
- data/lib/gcloud/bigquery/table/schema.rb +79 -87
- data/lib/gcloud/bigquery/view.rb +69 -82
- data/lib/gcloud/credentials.rb +3 -9
- data/lib/gcloud/datastore.rb +194 -170
- data/lib/gcloud/datastore/connection.rb +12 -8
- data/lib/gcloud/datastore/credentials.rb +6 -4
- data/lib/gcloud/datastore/dataset.rb +74 -141
- data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
- data/lib/gcloud/datastore/entity.rb +81 -76
- data/lib/gcloud/datastore/errors.rb +10 -8
- data/lib/gcloud/datastore/key.rb +41 -77
- data/lib/gcloud/datastore/properties.rb +3 -3
- data/lib/gcloud/datastore/proto.rb +7 -4
- data/lib/gcloud/datastore/query.rb +26 -3
- data/lib/gcloud/datastore/transaction.rb +12 -8
- data/lib/gcloud/dns.rb +180 -152
- data/lib/gcloud/dns/change.rb +16 -16
- data/lib/gcloud/dns/change/list.rb +3 -3
- data/lib/gcloud/dns/connection.rb +9 -10
- data/lib/gcloud/dns/credentials.rb +3 -3
- data/lib/gcloud/dns/errors.rb +9 -5
- data/lib/gcloud/dns/importer.rb +17 -23
- data/lib/gcloud/dns/project.rb +42 -64
- data/lib/gcloud/dns/record.rb +58 -46
- data/lib/gcloud/dns/record/list.rb +6 -7
- data/lib/gcloud/dns/zone.rb +198 -289
- data/lib/gcloud/dns/zone/list.rb +3 -3
- data/lib/gcloud/dns/zone/transaction.rb +56 -72
- data/lib/gcloud/errors.rb +174 -3
- data/lib/gcloud/gce.rb +3 -4
- data/lib/gcloud/grpc_utils.rb +76 -0
- data/lib/gcloud/logging.rb +308 -0
- data/lib/gcloud/logging/credentials.rb +29 -0
- data/lib/gcloud/logging/entry.rb +303 -0
- data/lib/gcloud/logging/entry/http_request.rb +141 -0
- data/lib/gcloud/logging/entry/list.rb +111 -0
- data/lib/gcloud/logging/entry/operation.rb +90 -0
- data/lib/gcloud/logging/logger.rb +307 -0
- data/lib/gcloud/logging/metric.rb +175 -0
- data/lib/gcloud/logging/metric/list.rb +98 -0
- data/lib/gcloud/logging/project.rb +650 -0
- data/lib/gcloud/logging/resource.rb +95 -0
- data/lib/gcloud/logging/resource_descriptor.rb +140 -0
- data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
- data/lib/gcloud/logging/service.rb +258 -0
- data/lib/gcloud/logging/sink.rb +233 -0
- data/lib/gcloud/logging/sink/list.rb +97 -0
- data/lib/gcloud/pubsub.rb +241 -199
- data/lib/gcloud/pubsub/credentials.rb +3 -3
- data/lib/gcloud/pubsub/message.rb +26 -20
- data/lib/gcloud/pubsub/project.rb +166 -233
- data/lib/gcloud/pubsub/received_message.rb +28 -38
- data/lib/gcloud/pubsub/service.rb +323 -0
- data/lib/gcloud/pubsub/subscription.rb +172 -242
- data/lib/gcloud/pubsub/subscription/list.rb +11 -9
- data/lib/gcloud/pubsub/topic.rb +152 -271
- data/lib/gcloud/pubsub/topic/batch.rb +66 -0
- data/lib/gcloud/pubsub/topic/list.rb +9 -7
- data/lib/gcloud/resource_manager.rb +158 -138
- data/lib/gcloud/resource_manager/connection.rb +6 -5
- data/lib/gcloud/resource_manager/credentials.rb +3 -3
- data/lib/gcloud/resource_manager/errors.rb +9 -5
- data/lib/gcloud/resource_manager/manager.rb +54 -86
- data/lib/gcloud/resource_manager/project.rb +69 -88
- data/lib/gcloud/resource_manager/project/list.rb +4 -5
- data/lib/gcloud/resource_manager/project/updater.rb +12 -14
- data/lib/gcloud/search.rb +158 -135
- data/lib/gcloud/search/api_client.rb +7 -7
- data/lib/gcloud/search/connection.rb +8 -8
- data/lib/gcloud/search/credentials.rb +3 -3
- data/lib/gcloud/search/document.rb +64 -87
- data/lib/gcloud/search/document/list.rb +5 -5
- data/lib/gcloud/search/errors.rb +9 -5
- data/lib/gcloud/search/field_value.rb +32 -38
- data/lib/gcloud/search/field_values.rb +50 -80
- data/lib/gcloud/search/fields.rb +44 -65
- data/lib/gcloud/search/index.rb +163 -204
- data/lib/gcloud/search/index/list.rb +5 -5
- data/lib/gcloud/search/project.rb +31 -47
- data/lib/gcloud/search/result.rb +27 -31
- data/lib/gcloud/search/result/list.rb +6 -6
- data/lib/gcloud/storage.rb +224 -190
- data/lib/gcloud/storage/bucket.rb +202 -227
- data/lib/gcloud/storage/bucket/acl.rb +83 -170
- data/lib/gcloud/storage/bucket/cors.rb +31 -34
- data/lib/gcloud/storage/bucket/list.rb +3 -3
- data/lib/gcloud/storage/connection.rb +11 -7
- data/lib/gcloud/storage/credentials.rb +3 -3
- data/lib/gcloud/storage/errors.rb +11 -8
- data/lib/gcloud/storage/file.rb +129 -171
- data/lib/gcloud/storage/file/acl.rb +51 -99
- data/lib/gcloud/storage/file/list.rb +3 -3
- data/lib/gcloud/storage/file/verifier.rb +3 -2
- data/lib/gcloud/storage/project.rb +111 -132
- data/lib/gcloud/upload.rb +4 -7
- data/lib/gcloud/version.rb +2 -4
- data/lib/google/api/annotations.rb +14 -0
- data/lib/google/api/http.rb +30 -0
- data/lib/google/api/label.rb +24 -0
- data/lib/google/api/monitored_resource.rb +25 -0
- data/lib/google/datastore/v1beta3/datastore.rb +115 -0
- data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
- data/lib/google/datastore/v1beta3/entity.rb +63 -0
- data/lib/google/datastore/v1beta3/query.rb +128 -0
- data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
- data/lib/google/example/library/v1/library.rb +91 -0
- data/lib/google/example/library/v1/library_services.rb +40 -0
- data/lib/google/iam/v1/iam_policy.rb +33 -0
- data/lib/google/iam/v1/iam_policy_services.rb +30 -0
- data/lib/google/iam/v1/policy.rb +25 -0
- data/lib/google/logging/type/http_request.rb +28 -0
- data/lib/google/logging/type/log_severity.rb +27 -0
- data/lib/google/logging/v2/log_entry.rb +44 -0
- data/lib/google/logging/v2/logging.rb +56 -0
- data/lib/google/logging/v2/logging_config.rb +59 -0
- data/lib/google/logging/v2/logging_config_services.rb +32 -0
- data/lib/google/logging/v2/logging_metrics.rb +51 -0
- data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
- data/lib/google/logging/v2/logging_services.rb +31 -0
- data/lib/google/longrunning/operations.rb +50 -0
- data/lib/google/longrunning/operations_services.rb +29 -0
- data/lib/google/protobuf/any.rb +17 -0
- data/lib/google/protobuf/api.rb +31 -0
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/protobuf/duration.rb +17 -0
- data/lib/google/protobuf/empty.rb +15 -0
- data/lib/google/protobuf/field_mask.rb +16 -0
- data/lib/google/protobuf/source_context.rb +16 -0
- data/lib/google/protobuf/struct.rb +35 -0
- data/lib/google/protobuf/timestamp.rb +17 -0
- data/lib/google/protobuf/type.rb +79 -0
- data/lib/google/protobuf/wrappers.rb +48 -0
- data/lib/google/pubsub/v1/pubsub.rb +129 -0
- data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
- data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
- data/lib/google/rpc/code.rb +32 -0
- data/lib/google/rpc/error_details.rb +61 -0
- data/lib/google/rpc/status.rb +19 -0
- data/lib/google/type/color.rb +20 -0
- data/lib/google/type/date.rb +18 -0
- data/lib/google/type/dayofweek.rb +23 -0
- data/lib/google/type/latlng.rb +17 -0
- data/lib/google/type/money.rb +18 -0
- data/lib/google/type/timeofday.rb +19 -0
- metadata +101 -4
- data/lib/gcloud/pubsub/connection.rb +0 -295
- 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::
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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,
|
|
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
|
|
21
|
+
# Creates a new `Project` instance connected to the Resource Manager service.
|
|
23
22
|
# Each call creates a new connection.
|
|
24
23
|
#
|
|
25
|
-
#
|
|
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
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
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
|
-
# *
|
|
39
|
-
#
|
|
40
|
-
# === Returns
|
|
41
|
-
#
|
|
42
|
-
# Gcloud::ResourceManager::Manager
|
|
36
|
+
# * `https://www.googleapis.com/auth/cloud-platform`
|
|
43
37
|
#
|
|
44
|
-
#
|
|
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
|
-
#
|
|
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
|
|
72
|
-
# Console
|
|
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
|
-
#
|
|
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
|
|
91
|
-
# Resource Manager API in the
|
|
92
|
-
# Console
|
|
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
|
-
#
|
|
86
|
+
# ## Authentication
|
|
95
87
|
#
|
|
96
|
-
# The Resource Manager API currently requires authentication of a
|
|
97
|
-
# Account
|
|
98
|
-
# cannot currently be accessed with a
|
|
99
|
-
# Account
|
|
100
|
-
# To use a User Account install the
|
|
101
|
-
# SDK
|
|
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
|
-
#
|
|
95
|
+
# ```
|
|
96
|
+
# $ gcloud auth login
|
|
97
|
+
# ```
|
|
104
98
|
#
|
|
105
|
-
# Also make sure all
|
|
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
|
-
#
|
|
103
|
+
# ```ruby
|
|
104
|
+
# require "gcloud"
|
|
110
105
|
#
|
|
111
|
-
#
|
|
112
|
-
#
|
|
106
|
+
# gcloud = Gcloud.new
|
|
107
|
+
# resource_manager = gcloud.resource_manager
|
|
108
|
+
# ```
|
|
113
109
|
#
|
|
114
|
-
#
|
|
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
|
|
114
|
+
# all projects that you have permissions to. (See
|
|
115
|
+
# {Gcloud::ResourceManager::Manager#projects})
|
|
119
116
|
#
|
|
120
|
-
#
|
|
117
|
+
# ```ruby
|
|
118
|
+
# require "gcloud"
|
|
121
119
|
#
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
#
|
|
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
|
-
#
|
|
127
|
+
# ## Managing Projects with Labels
|
|
129
128
|
#
|
|
130
|
-
# Labels can be added to or removed from projects. (See
|
|
129
|
+
# Labels can be added to or removed from projects. (See
|
|
130
|
+
# {Gcloud::ResourceManager::Project#labels})
|
|
131
131
|
#
|
|
132
|
-
#
|
|
132
|
+
# ```ruby
|
|
133
|
+
# require "gcloud"
|
|
133
134
|
#
|
|
134
|
-
#
|
|
135
|
-
#
|
|
136
|
-
#
|
|
137
|
-
#
|
|
138
|
-
#
|
|
139
|
-
#
|
|
140
|
-
#
|
|
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
|
|
144
|
+
# Projects can then be filtered by labels. (See
|
|
145
|
+
# {Gcloud::ResourceManager::Manager#projects})
|
|
143
146
|
#
|
|
144
|
-
#
|
|
147
|
+
# ```ruby
|
|
148
|
+
# require "gcloud"
|
|
145
149
|
#
|
|
146
|
-
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
#
|
|
152
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
164
|
+
# ```ruby
|
|
165
|
+
# require "gcloud"
|
|
160
166
|
#
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
#
|
|
164
|
-
#
|
|
165
|
-
#
|
|
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
|
-
#
|
|
174
|
+
# ## Deleting a Project
|
|
168
175
|
#
|
|
169
176
|
# You can delete projects when they are no longer needed. (See
|
|
170
|
-
# Manager#delete and
|
|
177
|
+
# {Gcloud::ResourceManager::Manager#delete} and
|
|
178
|
+
# {Gcloud::ResourceManager::Project#delete})
|
|
171
179
|
#
|
|
172
|
-
#
|
|
180
|
+
# ```ruby
|
|
181
|
+
# require "gcloud"
|
|
173
182
|
#
|
|
174
|
-
#
|
|
175
|
-
#
|
|
176
|
-
#
|
|
183
|
+
# gcloud = Gcloud.new
|
|
184
|
+
# resource_manager = gcloud.resource_manager
|
|
185
|
+
# resource_manager.delete "tokyo-rain-123"
|
|
186
|
+
# ```
|
|
177
187
|
#
|
|
178
|
-
#
|
|
188
|
+
# ## Undeleting a Project
|
|
179
189
|
#
|
|
180
|
-
# You can also restore a deleted project within the waiting period that
|
|
181
|
-
#
|
|
182
|
-
#
|
|
183
|
-
#
|
|
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
|
-
#
|
|
196
|
+
# ```ruby
|
|
197
|
+
# require "gcloud"
|
|
186
198
|
#
|
|
187
|
-
#
|
|
188
|
-
#
|
|
189
|
-
#
|
|
199
|
+
# gcloud = Gcloud.new
|
|
200
|
+
# resource_manager = gcloud.resource_manager
|
|
201
|
+
# resource_manager.undelete "tokyo-rain-123"
|
|
202
|
+
# ```
|
|
190
203
|
#
|
|
191
|
-
#
|
|
204
|
+
# ## Managing IAM Policies
|
|
192
205
|
#
|
|
193
|
-
# Google Cloud Identity and Access Management (
|
|
194
|
-
# IAM
|
|
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
|
|
197
|
-
# Overview
|
|
198
|
-
#
|
|
199
|
-
# A project's access control policy can be retrieved. (See
|
|
200
|
-
#
|
|
201
|
-
#
|
|
202
|
-
#
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
210
|
-
#
|
|
211
|
-
#
|
|
212
|
-
#
|
|
213
|
-
#
|
|
214
|
-
#
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
219
|
-
#
|
|
220
|
-
#
|
|
221
|
-
#
|
|
222
|
-
#
|
|
223
|
-
#
|
|
224
|
-
#
|
|
225
|
-
#
|
|
226
|
-
#
|
|
227
|
-
#
|
|
228
|
-
#
|
|
229
|
-
#
|
|
230
|
-
#
|
|
231
|
-
#
|
|
232
|
-
#
|
|
233
|
-
#
|
|
234
|
-
#
|
|
235
|
-
#
|
|
236
|
-
#
|
|
237
|
-
#
|
|
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
|