google-cloud-resource_manager 0.30.3 → 0.31.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/google/cloud/resource_manager/manager.rb +41 -2
- data/lib/google/cloud/resource_manager/project.rb +48 -0
- data/lib/google/cloud/resource_manager/project/updater.rb +26 -0
- data/lib/google/cloud/resource_manager/resource.rb +119 -0
- data/lib/google/cloud/resource_manager/service.rb +5 -3
- data/lib/google/cloud/resource_manager/version.rb +1 -1
- metadata +14 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b2b524b149206b6776eb5dd65e24833d2bd1ff1643af4d37229bebc2bd42ecd
|
|
4
|
+
data.tar.gz: 4b8556c72c3182be9f3ba256786945d263c838c6b687b37a7dbe3731cd697e92
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ef341093f4fd54a886d916c528ef32091f259feb2778861cb60459d14c6f2ca920002b96a2eb49def80a15dc24a3fe1d48fc2d4d8ea347fef57e148cd8a7e15
|
|
7
|
+
data.tar.gz: 4e66a0d717be7f176b3b807b9ec30e74875efb06a525c726dd832fc09a44a494406f2eb3ef95ce6677d18253aa0233ca3a7396bde59c245edad67f73cf61cb8b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 0.31.0 / 2019-02-12
|
|
4
|
+
|
|
5
|
+
* Add parent resoure to `Project`:
|
|
6
|
+
* Add `Project#parent`.
|
|
7
|
+
* Add `parent` optional named argument to `Manager#create_project`.
|
|
8
|
+
* Add `Resource` class.
|
|
9
|
+
* Add `Manager#resource` convenience method.
|
|
10
|
+
|
|
3
11
|
### 0.30.3 / 2018-09-20
|
|
4
12
|
|
|
5
13
|
* Update documentation.
|
|
@@ -17,6 +17,7 @@ require "google/cloud/errors"
|
|
|
17
17
|
require "google/cloud/resource_manager/credentials"
|
|
18
18
|
require "google/cloud/resource_manager/service"
|
|
19
19
|
require "google/cloud/resource_manager/project"
|
|
20
|
+
require "google/cloud/resource_manager/resource"
|
|
20
21
|
|
|
21
22
|
module Google
|
|
22
23
|
module Cloud
|
|
@@ -166,6 +167,15 @@ module Google
|
|
|
166
167
|
# <code>([a-z]([-a-z0-9]*[a-z0-9])?)?</code>.
|
|
167
168
|
#
|
|
168
169
|
# No more than 256 labels can be associated with a given resource.
|
|
170
|
+
# @param [Resource] parent A parent Resource. Optional.
|
|
171
|
+
#
|
|
172
|
+
# Supported parent types include "organization" and "folder". Once
|
|
173
|
+
# set, the parent can be updated but cannot be cleared.
|
|
174
|
+
#
|
|
175
|
+
# The end user must have the `resourcemanager.projects.create`
|
|
176
|
+
# permission on the parent.
|
|
177
|
+
#
|
|
178
|
+
# (See {#resource} and {Resource}.)
|
|
169
179
|
#
|
|
170
180
|
# @return [Google::Cloud::ResourceManager::Project]
|
|
171
181
|
#
|
|
@@ -182,8 +192,16 @@ module Google
|
|
|
182
192
|
# project = resource_manager.create_project "tokyo-rain-123",
|
|
183
193
|
# name: "Todos Development", labels: {env: :development}
|
|
184
194
|
#
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
# @example A project can also be created with a `name` and `parent`:
|
|
196
|
+
# require "google/cloud/resource_manager"
|
|
197
|
+
#
|
|
198
|
+
# resource_manager = Google::Cloud::ResourceManager.new
|
|
199
|
+
# folder = resource_manager.resource "folder", "1234"
|
|
200
|
+
# project = resource_manager.create_project "tokyo-rain-123",
|
|
201
|
+
# name: "Todos Development", parent: folder
|
|
202
|
+
#
|
|
203
|
+
def create_project project_id, name: nil, labels: nil, parent: nil
|
|
204
|
+
gapi = service.create_project project_id, name, labels, parent
|
|
187
205
|
Project.from_gapi gapi, service
|
|
188
206
|
end
|
|
189
207
|
|
|
@@ -241,6 +259,27 @@ module Google
|
|
|
241
259
|
true
|
|
242
260
|
end
|
|
243
261
|
|
|
262
|
+
##
|
|
263
|
+
# Create a Resource object. (See {Resource}.)
|
|
264
|
+
#
|
|
265
|
+
# @param [String] type The resource type this id is for. At present, the
|
|
266
|
+
# valid types are: "organization" and "folder".
|
|
267
|
+
# @param [String] id The type-specific id. This should correspond to the
|
|
268
|
+
# id used in the type-specific API's.
|
|
269
|
+
# @return [resource]
|
|
270
|
+
#
|
|
271
|
+
# @example
|
|
272
|
+
# require "google/cloud/resource_manager"
|
|
273
|
+
#
|
|
274
|
+
# resource_manager = Google::Cloud::ResourceManager.new
|
|
275
|
+
# project = resource_manager.project "tokyo-rain-123"
|
|
276
|
+
# folder = resource_manager.resource "folder", "1234"
|
|
277
|
+
# project.parent = folder
|
|
278
|
+
#
|
|
279
|
+
def resource type, id
|
|
280
|
+
Resource.new type, id
|
|
281
|
+
end
|
|
282
|
+
|
|
244
283
|
protected
|
|
245
284
|
|
|
246
285
|
##
|
|
@@ -17,6 +17,7 @@ require "time"
|
|
|
17
17
|
require "google/cloud/resource_manager/project/list"
|
|
18
18
|
require "google/cloud/resource_manager/project/updater"
|
|
19
19
|
require "google/cloud/resource_manager/policy"
|
|
20
|
+
require "google/cloud/resource_manager/resource"
|
|
20
21
|
|
|
21
22
|
module Google
|
|
22
23
|
module Cloud
|
|
@@ -164,6 +165,51 @@ module Google
|
|
|
164
165
|
@gapi = service.update_project @gapi
|
|
165
166
|
end
|
|
166
167
|
|
|
168
|
+
##
|
|
169
|
+
# An optional reference to a parent Resource.
|
|
170
|
+
#
|
|
171
|
+
# Supported parent types include "organization" and "folder". Once set,
|
|
172
|
+
# the parent can be updated but cannot be cleared.
|
|
173
|
+
#
|
|
174
|
+
# The resource object returned is read-only and cannot be changed. A new
|
|
175
|
+
# resource object can be set using the `#parent=` or `#update` methods.
|
|
176
|
+
# (See {Resource} and {Manager#resource}.)
|
|
177
|
+
#
|
|
178
|
+
# @return [nil, Resource] the reference to a parent Resource (read-only)
|
|
179
|
+
#
|
|
180
|
+
def parent
|
|
181
|
+
return nil if @gapi.parent.nil?
|
|
182
|
+
Resource.from_gapi(@gapi.parent).freeze
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
##
|
|
186
|
+
# Updates the reference to a parent with a new Resource.
|
|
187
|
+
#
|
|
188
|
+
# Supported parent types include "organization" and "folder". Once set,
|
|
189
|
+
# the parent can be updated but cannot be cleared.
|
|
190
|
+
#
|
|
191
|
+
# The end user must have the `resourcemanager.projects.create`
|
|
192
|
+
# permission on the parent.
|
|
193
|
+
#
|
|
194
|
+
# (See {Resource} and {Manager#resource}.)
|
|
195
|
+
#
|
|
196
|
+
# @param [Resource] new_parent A new parent Resource.
|
|
197
|
+
#
|
|
198
|
+
# @example
|
|
199
|
+
# require "google/cloud/resource_manager"
|
|
200
|
+
#
|
|
201
|
+
# resource_manager = Google::Cloud::ResourceManager.new
|
|
202
|
+
# project = resource_manager.project "tokyo-rain-123"
|
|
203
|
+
# folder = resource_manager.resource "folder", "1234"
|
|
204
|
+
# project.parent = folder
|
|
205
|
+
#
|
|
206
|
+
def parent= new_parent
|
|
207
|
+
raise ArgumentError, "new_parent is required" if new_parent.nil?
|
|
208
|
+
ensure_service!
|
|
209
|
+
@gapi.parent = new_parent.to_gapi
|
|
210
|
+
@gapi = service.update_project @gapi
|
|
211
|
+
end
|
|
212
|
+
|
|
167
213
|
##
|
|
168
214
|
# The time that this project was created.
|
|
169
215
|
#
|
|
@@ -230,8 +276,10 @@ module Google
|
|
|
230
276
|
#
|
|
231
277
|
# resource_manager = Google::Cloud::ResourceManager.new
|
|
232
278
|
# project = resource_manager.project "tokyo-rain-123"
|
|
279
|
+
# folder = resource_manager.resource "folder", "1234"
|
|
233
280
|
# project.update do |p|
|
|
234
281
|
# p.name = "My Project"
|
|
282
|
+
# p.parent = folder
|
|
235
283
|
# p.labels["env"] = "production"
|
|
236
284
|
# end
|
|
237
285
|
#
|
|
@@ -117,6 +117,32 @@ module Google
|
|
|
117
117
|
gapi.labels = new_labels
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
##
|
|
121
|
+
# Updates the reference to a parent with a new Resource.
|
|
122
|
+
#
|
|
123
|
+
# Supported parent types include "organization" and "folder". Once
|
|
124
|
+
# set, the parent can be updated but cannot be cleared.
|
|
125
|
+
#
|
|
126
|
+
# The end user must have the `resourcemanager.projects.create`
|
|
127
|
+
# permission on the parent.
|
|
128
|
+
#
|
|
129
|
+
# (See {Resource} and {Manager#resource}.)
|
|
130
|
+
#
|
|
131
|
+
# @param [Resource] new_parent A new parent Resource.
|
|
132
|
+
#
|
|
133
|
+
# @example
|
|
134
|
+
# require "google/cloud/resource_manager"
|
|
135
|
+
#
|
|
136
|
+
# resource_manager = Google::Cloud::ResourceManager.new
|
|
137
|
+
# project = resource_manager.project "tokyo-rain-123"
|
|
138
|
+
# folder = resource_manager.resource "folder", "1234"
|
|
139
|
+
# project.parent = folder
|
|
140
|
+
#
|
|
141
|
+
def parent= new_parent
|
|
142
|
+
raise ArgumentError, "new_parent is required" if new_parent.nil?
|
|
143
|
+
gapi.parent = new_parent.to_gapi
|
|
144
|
+
end
|
|
145
|
+
|
|
120
146
|
##
|
|
121
147
|
# @private Create an Updater object.
|
|
122
148
|
def self.from_project project
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Copyright 2019 Google LLC
|
|
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
|
+
# https://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 Google
|
|
17
|
+
module Cloud
|
|
18
|
+
module ResourceManager
|
|
19
|
+
##
|
|
20
|
+
# # Resource
|
|
21
|
+
#
|
|
22
|
+
# A container to reference an id for any resource type. A `resource` in
|
|
23
|
+
# Google Cloud Platform is a generic term for something a developer may
|
|
24
|
+
# want to interact with through an API. Some examples are an App Engine
|
|
25
|
+
# app, a Compute Engine instance, a Cloud SQL database, and so on. (See
|
|
26
|
+
# {Manager#resource}.)
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# require "google/cloud/resource_manager"
|
|
30
|
+
#
|
|
31
|
+
# resource_manager = Google::Cloud::ResourceManager.new
|
|
32
|
+
# project = resource_manager.project "tokyo-rain-123"
|
|
33
|
+
# folder = Google::Cloud::ResourceManager::Resource.new "folder", "1234"
|
|
34
|
+
# project.parent = folder
|
|
35
|
+
#
|
|
36
|
+
class Resource
|
|
37
|
+
##
|
|
38
|
+
# Create a Resource object.
|
|
39
|
+
#
|
|
40
|
+
# @param [String] type The resource type this id is for. At present, the
|
|
41
|
+
# valid types are: "organization" and "folder".
|
|
42
|
+
# @param [String] id The type-specific id. This should correspond to the
|
|
43
|
+
# id used in the type-specific API's.
|
|
44
|
+
def initialize type, id
|
|
45
|
+
raise ArgumentError, "type is required" if type.nil?
|
|
46
|
+
raise ArgumentError, "id is required" if id.nil?
|
|
47
|
+
|
|
48
|
+
@type = type
|
|
49
|
+
@id = id
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Required field representing the resource type this id is for. At
|
|
54
|
+
# present, the valid types are: "organization" and "folder".
|
|
55
|
+
# @return [String]
|
|
56
|
+
attr_accessor :type
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# Required field for the type-specific id. This should correspond to the
|
|
60
|
+
# id used in the type-specific API's.
|
|
61
|
+
# @return [String]
|
|
62
|
+
attr_accessor :id
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# Checks if the type is `folder`.
|
|
66
|
+
# @return [Boolean]
|
|
67
|
+
def folder?
|
|
68
|
+
return false if type.nil?
|
|
69
|
+
"folder".casecmp(type).zero?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
##
|
|
73
|
+
# Checks if the type is `organization`.
|
|
74
|
+
# @return [Boolean]
|
|
75
|
+
def organization?
|
|
76
|
+
return false if type.nil?
|
|
77
|
+
"organization".casecmp(type).zero?
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# Create a Resource object with type `folder`.
|
|
82
|
+
#
|
|
83
|
+
# @param [String] id The type-specific id. This should correspond to the
|
|
84
|
+
# id used in the type-specific API's.
|
|
85
|
+
# @return [Resource]
|
|
86
|
+
def self.folder id
|
|
87
|
+
new "folder", id
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
# Create a Resource object with type `organization`.
|
|
92
|
+
#
|
|
93
|
+
# @param [String] id The type-specific id. This should correspond to the
|
|
94
|
+
# id used in the type-specific API's.
|
|
95
|
+
# @return [Resource]
|
|
96
|
+
def self.organization id
|
|
97
|
+
new "organization", id
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# @private Convert the Resource to a Google API Client ResourceId
|
|
102
|
+
# object.
|
|
103
|
+
def to_gapi
|
|
104
|
+
Google::Apis::CloudresourcemanagerV1::ResourceId.new(
|
|
105
|
+
type: type,
|
|
106
|
+
id: id
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# @private Create new Resource from a Google API Client ResourceId
|
|
112
|
+
# object.
|
|
113
|
+
def self.from_gapi gapi
|
|
114
|
+
new gapi.type, gapi.id
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -74,9 +74,11 @@ module Google
|
|
|
74
74
|
|
|
75
75
|
##
|
|
76
76
|
# Returns API::Project
|
|
77
|
-
def create_project project_id, name, labels
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
def create_project project_id, name, labels, parent
|
|
78
|
+
parent = parent.to_gapi unless parent.nil?
|
|
79
|
+
project_attrs = {
|
|
80
|
+
project_id: project_id, name: name, labels: labels, parent: parent
|
|
81
|
+
}.delete_if { |_, v| v.nil? }
|
|
80
82
|
execute { service.create_project API::Project.new(project_attrs) }
|
|
81
83
|
end
|
|
82
84
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: google-cloud-resource_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.31.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Moore
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: google-cloud-core
|
|
@@ -43,16 +43,22 @@ dependencies:
|
|
|
43
43
|
name: googleauth
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
|
-
- - "
|
|
46
|
+
- - ">="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
48
|
version: 0.6.2
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: 0.10.0
|
|
49
52
|
type: :runtime
|
|
50
53
|
prerelease: false
|
|
51
54
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
55
|
requirements:
|
|
53
|
-
- - "
|
|
56
|
+
- - ">="
|
|
54
57
|
- !ruby/object:Gem::Version
|
|
55
58
|
version: 0.6.2
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.10.0
|
|
56
62
|
- !ruby/object:Gem::Dependency
|
|
57
63
|
name: minitest
|
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -143,14 +149,14 @@ dependencies:
|
|
|
143
149
|
requirements:
|
|
144
150
|
- - "~>"
|
|
145
151
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: 0.
|
|
152
|
+
version: 0.61.0
|
|
147
153
|
type: :development
|
|
148
154
|
prerelease: false
|
|
149
155
|
version_requirements: !ruby/object:Gem::Requirement
|
|
150
156
|
requirements:
|
|
151
157
|
- - "~>"
|
|
152
158
|
- !ruby/object:Gem::Version
|
|
153
|
-
version: 0.
|
|
159
|
+
version: 0.61.0
|
|
154
160
|
- !ruby/object:Gem::Dependency
|
|
155
161
|
name: simplecov
|
|
156
162
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -219,6 +225,7 @@ files:
|
|
|
219
225
|
- lib/google/cloud/resource_manager/project.rb
|
|
220
226
|
- lib/google/cloud/resource_manager/project/list.rb
|
|
221
227
|
- lib/google/cloud/resource_manager/project/updater.rb
|
|
228
|
+
- lib/google/cloud/resource_manager/resource.rb
|
|
222
229
|
- lib/google/cloud/resource_manager/service.rb
|
|
223
230
|
- lib/google/cloud/resource_manager/version.rb
|
|
224
231
|
homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-resource_manager
|
|
@@ -241,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
241
248
|
version: '0'
|
|
242
249
|
requirements: []
|
|
243
250
|
rubyforge_project:
|
|
244
|
-
rubygems_version: 2.7.
|
|
251
|
+
rubygems_version: 2.7.6
|
|
245
252
|
signing_key:
|
|
246
253
|
specification_version: 4
|
|
247
254
|
summary: API Client library for Google Cloud Resource Manager
|