Module: Google::Cloud::ResourceManager

Defined in:
lib/google/cloud/resource_manager.rb,
lib/google/cloud/resource_manager/policy.rb,
lib/google/cloud/resource_manager/manager.rb,
lib/google/cloud/resource_manager/project.rb,
lib/google/cloud/resource_manager/service.rb,
lib/google/cloud/resource_manager/version.rb,
lib/google/cloud/resource_manager/credentials.rb,
lib/google/cloud/resource_manager/project/list.rb,
lib/google/cloud/resource_manager/project/updater.rb

Overview

Google Cloud Resource Manager

The Resource Manager API provides methods that you can use to programmatically manage your projects in the Google Cloud Platform.

See Resource Manager Overview.

Defined Under Namespace

Classes: Credentials, Manager, Policy, Project

Constant Summary collapse

VERSION =
"0.30.0".freeze

Class Method Summary collapse

Class Method Details

.configure {|Google::Cloud.configure.resource_manager| ... } ⇒ Google::Cloud::Config

Configure the Google Cloud Resource Manager library.

The following Resource Manager configuration parameters are supported:

  • credentials - (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials) (The parameter keyfile is also available but deprecated.)
  • scope - (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access.
  • retries - (Integer) Number of times to retry requests on server error.
  • timeout - (Integer) Default timeout to use in requests.

Yields:

Returns:

  • (Google::Cloud::Config)

    The configuration object the Google::Cloud::ResourceManager library uses.



104
105
106
107
108
# File 'lib/google/cloud/resource_manager.rb', line 104

def self.configure
  yield Google::Cloud.configure.resource_manager if block_given?

  Google::Cloud.configure.resource_manager
end

.new(credentials: nil, scope: nil, retries: nil, timeout: nil, keyfile: nil) ⇒ Google::Cloud::ResourceManager::Manager

Creates a new Project instance connected to the Resource Manager service. Each call creates a new connection.

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud/resource_manager"

resource_manager = Google::Cloud::ResourceManager.new
resource_manager.projects.each do |project|
  puts projects.project_id
end

Parameters:

  • credentials (String, Hash, Google::Auth::Credentials)

    The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials)

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/cloud-platform
  • retries (Integer)

    Number of times to retry requests on server error. The default value is 3. Optional.

  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • keyfile (String)

    Alias for the credentials argument. Deprecated.

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/google/cloud/resource_manager.rb', line 67

def self.new credentials: nil, scope: nil, retries: nil, timeout: nil,
             keyfile: nil
  scope ||= configure.scope
  retries ||= configure.retries
  timeout ||= configure.timeout
  credentials ||= keyfile
  credentials ||= default_credentials(scope: scope)
  unless credentials.is_a? Google::Auth::Credentials
    credentials = ResourceManager::Credentials.new credentials,
                                                   scope: scope
  end

  ResourceManager::Manager.new(
    ResourceManager::Service.new(
      credentials, retries: retries, timeout: timeout
    )
  )
end