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/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

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>) (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.

Returns:



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

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>) (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.

Returns:



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

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