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(credentials = 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 = Google::Cloud.resource_manager
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 Google::Cloud::ResourceManager::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.

Returns:



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

def self.resource_manager credentials = nil, scope: nil, retries: nil,
                          timeout: nil
  require "google/cloud/resource_manager"
  Google::Cloud::ResourceManager.new credentials: credentials, scope: scope,
                                     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:



67
68
69
70
71
# File 'lib/google-cloud-resource_manager.rb', line 67

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