Class: Google::Cloud::ResourceManager::V3::Organizations::Rest::Client
- Inherits:
-
Object
- Object
- Google::Cloud::ResourceManager::V3::Organizations::Rest::Client
- Includes:
- Paths
- Defined in:
- lib/google/cloud/resource_manager/v3/organizations/rest/client.rb
Overview
REST client for the Organizations service.
Allows users to manage their organization resources.
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the Organizations Client class.
Instance Method Summary collapse
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the Organizations Client instance.
-
#get_iam_policy(request, options = nil) {|result, operation| ... } ⇒ ::Google::Iam::V1::Policy
Gets the access control policy for an organization resource.
-
#get_organization(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::ResourceManager::V3::Organization
Fetches an organization resource identified by the specified resource name.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new Organizations REST client object.
-
#search_organizations(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::ResourceManager::V3::Organization>
Searches organization resources that are visible to the user and satisfy the specified filter.
-
#set_iam_policy(request, options = nil) {|result, operation| ... } ⇒ ::Google::Iam::V1::Policy
Sets the access control policy on an organization resource.
-
#test_iam_permissions(request, options = nil) {|result, operation| ... } ⇒ ::Google::Iam::V1::TestIamPermissionsResponse
Returns the permissions that a caller has on the specified organization.
Methods included from Paths
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new Organizations REST client object.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 125 def initialize # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @organizations_stub = ::Google::Cloud::ResourceManager::V3::Organizations::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the Organizations Client class.
See Configuration for a description of the configuration fields.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 58 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "ResourceManager", "V3"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.rpcs.get_organization.timeout = 60.0 default_config.rpcs.get_organization.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.search_organizations.timeout = 60.0 default_config.rpcs.get_iam_policy.timeout = 60.0 default_config.rpcs.get_iam_policy.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14] } default_config.rpcs.set_iam_policy.timeout = 60.0 default_config end yield @configure if block_given? @configure end |
Instance Method Details
#configure {|config| ... } ⇒ Client::Configuration
Configure the Organizations Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.
See Configuration for a description of the configuration fields.
104 105 106 107 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 104 def configure yield @config if block_given? @config end |
#get_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy #get_iam_policy(resource: nil, options: nil) ⇒ ::Google::Iam::V1::Policy
Gets the access control policy for an organization resource. The policy may
be empty if no such policy or resource exists. The resource
field should
be the organization's resource name, for example: "organizations/123".
Authorization requires the IAM permission
resourcemanager.organizations.getIamPolicy
on the specified organization.
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 346 def get_iam_policy request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_iam_policy..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::ResourceManager::V3::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_iam_policy.timeout, metadata: , retry_policy: @config.rpcs.get_iam_policy.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @organizations_stub.get_iam_policy request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#get_organization(request, options = nil) ⇒ ::Google::Cloud::ResourceManager::V3::Organization #get_organization(name: nil) ⇒ ::Google::Cloud::ResourceManager::V3::Organization
Fetches an organization resource identified by the specified resource name.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 181 def get_organization request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ResourceManager::V3::GetOrganizationRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_organization..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::ResourceManager::V3::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_organization.timeout, metadata: , retry_policy: @config.rpcs.get_organization.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @organizations_stub.get_organization request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#search_organizations(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::ResourceManager::V3::Organization> #search_organizations(page_size: nil, page_token: nil, query: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::ResourceManager::V3::Organization>
Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations in an unspecified order. New organizations do not necessarily appear at the end of the results, and may take a small amount of time to appear.
Search will only return organizations on which the user has the permission
resourcemanager.organizations.get
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 274 def search_organizations request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ResourceManager::V3::SearchOrganizationsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.search_organizations..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::ResourceManager::V3::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.search_organizations.timeout, metadata: , retry_policy: @config.rpcs.search_organizations.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @organizations_stub.search_organizations request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @organizations_stub, :search_organizations, "organizations", request, result, yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#set_iam_policy(request, options = nil) ⇒ ::Google::Iam::V1::Policy #set_iam_policy(resource: nil, policy: nil, update_mask: nil) ⇒ ::Google::Iam::V1::Policy
Sets the access control policy on an organization resource. Replaces any
existing policy. The resource
field should be the organization's resource
name, for example: "organizations/123".
Authorization requires the IAM permission
resourcemanager.organizations.setIamPolicy
on the specified organization.
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 425 def set_iam_policy request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.set_iam_policy..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::ResourceManager::V3::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.set_iam_policy.timeout, metadata: , retry_policy: @config.rpcs.set_iam_policy.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @organizations_stub.set_iam_policy request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#test_iam_permissions(request, options = nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse #test_iam_permissions(resource: nil, permissions: nil) ⇒ ::Google::Iam::V1::TestIamPermissionsResponse
Returns the permissions that a caller has on the specified organization.
The resource
field should be the organization's resource name,
for example: "organizations/123".
There are no permissions required for making this API call.
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/google/cloud/resource_manager/v3/organizations/rest/client.rb', line 497 def request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs...to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::ResourceManager::V3::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs..timeout, metadata: , retry_policy: @config.rpcs..retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @organizations_stub. request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |