Module: Google::Cloud

Defined in:
lib/google-cloud-resource_manager.rb,
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

Defined Under Namespace

Modules: ResourceManager

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resource_manager(keyfile = nil, scope: nil, retries: nil, timeout: 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.resource_manager
resource_manager.projects.each do |project|
  puts projects.project_id
end

Parameters:

  • keyfile (String, Hash) (defaults to: nil)

    Keyfile downloaded from Google Cloud. If file path the file must be readable.

  • 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.

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/google-cloud-resource_manager.rb', line 101

def self.resource_manager keyfile = nil, scope: nil, retries: nil,
                          timeout: nil
  require "google/cloud/resource_manager"
  if keyfile.nil?
    credentials = Google::Cloud::ResourceManager::Credentials.default(
      scope: scope)
  else
    credentials = Google::Cloud::ResourceManager::Credentials.new(
      keyfile, scope: scope)
  end
  Google::Cloud::ResourceManager::Manager.new(
    Google::Cloud::ResourceManager::Service.new(
      credentials, retries: retries, timeout: timeout))
end

Instance Method Details

#resource_manager(scope: nil, retries: nil, timeout: nil) ⇒ Google::Cloud::ResourceManager::Manager

Creates a new object for connecting 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"

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

The default scope can be overridden with the scope option:

require "google/cloud"

gcloud  = Google::Cloud.new
readonly_scope = \
  "https://www.googleapis.com/auth/cloudresourcemanager.readonly"
resource_manager = gcloud.resource_manager scope: readonly_scope

Parameters:

  • 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.

Returns:



64
65
66
67
68
# File 'lib/google-cloud-resource_manager.rb', line 64

def resource_manager scope: nil, retries: nil, timeout: nil
  Google::Cloud.resource_manager @keyfile, scope: scope,
                                           retries: (retries || @retries),
                                           timeout: (timeout || @timeout)
end