google-cloud-resource_manager 0.39.0 → 1.0.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/.yardopts +5 -9
- data/AUTHENTICATION.md +81 -141
- data/LICENSE.md +201 -0
- data/MIGRATING.md +194 -0
- data/README.md +131 -0
- data/lib/google/cloud/resource_manager/version.rb +6 -2
- data/lib/google/cloud/resource_manager.rb +546 -84
- data/lib/google-cloud-resource_manager.rb +5 -120
- metadata +14 -49
- data/CHANGELOG.md +0 -175
- data/CODE_OF_CONDUCT.md +0 -40
- data/CONTRIBUTING.md +0 -189
- data/LICENSE +0 -201
- data/LOGGING.md +0 -27
- data/OVERVIEW.md +0 -188
- data/TROUBLESHOOTING.md +0 -31
- data/lib/google/cloud/resource_manager/credentials.rb +0 -53
- data/lib/google/cloud/resource_manager/manager.rb +0 -300
- data/lib/google/cloud/resource_manager/policy.rb +0 -191
- data/lib/google/cloud/resource_manager/project/list.rb +0 -166
- data/lib/google/cloud/resource_manager/project/updater.rb +0 -151
- data/lib/google/cloud/resource_manager/project.rb +0 -502
- data/lib/google/cloud/resource_manager/resource.rb +0 -119
- data/lib/google/cloud/resource_manager/service.rb +0 -139
@@ -1,119 +0,0 @@
|
|
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
|
@@ -1,139 +0,0 @@
|
|
1
|
-
# Copyright 2016 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
|
-
require "google/cloud/errors"
|
17
|
-
require "google/cloud/resource_manager/version"
|
18
|
-
require "google/apis/cloudresourcemanager_v1"
|
19
|
-
|
20
|
-
module Google
|
21
|
-
module Cloud
|
22
|
-
module ResourceManager
|
23
|
-
##
|
24
|
-
# @private
|
25
|
-
# Represents the service to Resource Manager, as well as expose the API
|
26
|
-
# calls.
|
27
|
-
class Service
|
28
|
-
##
|
29
|
-
# Alias to the Google Client API module
|
30
|
-
API = Google::Apis::CloudresourcemanagerV1
|
31
|
-
|
32
|
-
attr_accessor :credentials
|
33
|
-
|
34
|
-
##
|
35
|
-
# Creates a new Service instance.
|
36
|
-
def initialize credentials, retries: nil, timeout: nil, host: nil, quota_project: nil
|
37
|
-
@credentials = credentials
|
38
|
-
@service = API::CloudResourceManagerService.new
|
39
|
-
@service.client_options.application_name = "gcloud-ruby"
|
40
|
-
@service.client_options.application_version = Google::Cloud::ResourceManager::VERSION
|
41
|
-
@service.client_options.open_timeout_sec = timeout
|
42
|
-
@service.client_options.read_timeout_sec = timeout
|
43
|
-
@service.client_options.send_timeout_sec = timeout
|
44
|
-
@service.request_options.retries = retries || 3
|
45
|
-
@service.request_options.header ||= {}
|
46
|
-
@service.request_options.header["x-goog-api-client"] =
|
47
|
-
"gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::ResourceManager::VERSION}"
|
48
|
-
@service.request_options.quota_project = quota_project if quota_project
|
49
|
-
@service.authorization = @credentials.client
|
50
|
-
@service.root_url = host if host
|
51
|
-
end
|
52
|
-
|
53
|
-
def service
|
54
|
-
return mocked_service if mocked_service
|
55
|
-
@service
|
56
|
-
end
|
57
|
-
attr_accessor :mocked_service
|
58
|
-
|
59
|
-
##
|
60
|
-
# Returns API::ListProjectsResponse
|
61
|
-
def list_project filter: nil, token: nil, max: nil
|
62
|
-
execute do
|
63
|
-
service.list_projects page_token: token, page_size: max,
|
64
|
-
filter: filter
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
##
|
69
|
-
# Returns API::Project
|
70
|
-
def get_project project_id
|
71
|
-
execute { service.get_project project_id }
|
72
|
-
end
|
73
|
-
|
74
|
-
##
|
75
|
-
# Returns API::Project
|
76
|
-
def create_project project_id, name, labels, parent
|
77
|
-
parent = parent.to_gapi unless parent.nil?
|
78
|
-
project_attrs = {
|
79
|
-
project_id: project_id, name: name, labels: labels, parent: parent
|
80
|
-
}.compact
|
81
|
-
execute { service.create_project API::Project.new(**project_attrs) }
|
82
|
-
end
|
83
|
-
|
84
|
-
##
|
85
|
-
# Updated the project, given a API::Project.
|
86
|
-
# Returns API::Project
|
87
|
-
def update_project project_gapi
|
88
|
-
execute do
|
89
|
-
service.update_project project_gapi.project_id, project_gapi
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def delete_project project_id
|
94
|
-
execute { service.delete_project project_id }
|
95
|
-
end
|
96
|
-
|
97
|
-
def undelete_project project_id
|
98
|
-
execute { service.undelete_project project_id }
|
99
|
-
end
|
100
|
-
|
101
|
-
##
|
102
|
-
# Returns API::Policy
|
103
|
-
def get_policy project_id
|
104
|
-
execute { service.get_project_iam_policy project_id }
|
105
|
-
end
|
106
|
-
|
107
|
-
##
|
108
|
-
# Returns API::Policy
|
109
|
-
def set_policy project_id, new_policy
|
110
|
-
req = API::SetIamPolicyRequest.new policy: new_policy
|
111
|
-
execute do
|
112
|
-
service.set_project_iam_policy project_id, req
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
##
|
117
|
-
# Returns API::TestIamPermissionsResponse
|
118
|
-
def test_permissions project_id, permissions
|
119
|
-
req = API::TestIamPermissionsRequest.new permissions: permissions
|
120
|
-
execute do
|
121
|
-
service.test_project_iam_permissions project_id, req
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def inspect
|
126
|
-
self.class.to_s
|
127
|
-
end
|
128
|
-
|
129
|
-
protected
|
130
|
-
|
131
|
-
def execute
|
132
|
-
yield
|
133
|
-
rescue Google::Apis::Error => e
|
134
|
-
raise Google::Cloud::Error.from_error(e)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|