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/resource.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, Resource

Constant Summary collapse

VERSION =
"0.38.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.



106
107
108
109
110
# File 'lib/google/cloud/resource_manager.rb', line 106

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, endpoint: 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) (defaults to: nil)

    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>) (defaults to: nil)

    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) (defaults to: nil)

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

  • timeout (Integer) (defaults to: nil)

    Default timeout to use in requests. Optional.

  • endpoint (String) (defaults to: nil)

    Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.

  • keyfile (String) (defaults to: nil)

    Alias for the credentials argument. Deprecated.

Returns:



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

def self.new credentials: nil, scope: nil, retries: nil, timeout: nil,
             endpoint: nil, keyfile: nil
  scope ||= configure.scope
  retries ||= configure.retries
  timeout ||= configure.timeout
  endpoint ||= configure.endpoint
  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, host: endpoint, quota_project: configure.quota_project
    )
  )
end