class Google::Cloud::Compute::V1::RegionInstances::Rest::Client

REST client for the RegionInstances service.

The RegionInstances API.

Attributes

region_instances_stub[R]

@private

Public Class Methods

configure() { |configure| ... } click to toggle source

Configure the RegionInstances Client class.

See {::Google::Cloud::Compute::V1::RegionInstances::Rest::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all RegionInstances clients
::Google::Cloud::Compute::V1::RegionInstances::Rest::Client.configure do |config|
  config.timeout = 10.0
end

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/compute/v1/region_instances/rest/client.rb, line 56
def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Compute", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.bulk_insert.timeout = 600.0

    default_config
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new RegionInstances REST client object.

@example

# Create a client using the default configuration
client = ::Google::Cloud::Compute::V1::RegionInstances::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Compute::V1::RegionInstances::Rest::Client.new do |config|
  config.timeout = 10.0
end

@yield [config] Configure the RegionInstances client. @yieldparam config [Client::Configuration]

# File lib/google/cloud/compute/v1/region_instances/rest/client.rb, line 111
def initialize
  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  credentials ||= Credentials.default scope: @config.scope
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @region_instances_stub = ::Google::Cloud::Compute::V1::RegionInstances::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
end

Public Instance Methods

bulk_insert(request, options = nil) { |result, response| ... } click to toggle source

Creates multiple instances in a given region. Count specifies the number of instances to create.

@overload bulk_insert(request, options = nil)

Pass arguments to `bulk_insert` via a request object, either of type
{::Google::Cloud::Compute::V1::BulkInsertRegionInstanceRequest} or an equivalent Hash.

@param request [::Google::Cloud::Compute::V1::BulkInsertRegionInstanceRequest, ::Hash]
  A request object representing the call parameters. Required. To specify no
  parameters, or to keep all the default parameter values, pass an empty Hash.
@param options [::Gapic::CallOptions, ::Hash]
  Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
  Note: currently retry functionality is not implemented. While it is possible
  to set it using ::Gapic::CallOptions, it will not be applied

@overload bulk_insert(bulk_insert_instance_resource_resource: nil, project: nil, region: nil, request_id: nil)

Pass arguments to `bulk_insert` via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).

@param bulk_insert_instance_resource_resource [::Google::Cloud::Compute::V1::BulkInsertInstanceResource, ::Hash]
  The body resource for this request
@param project [::String]
  Project ID for this request.
@param region [::String]
  The name of the region for this request.
@param request_id [::String]
  An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed.

  For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.

  The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).

@yield [result, response] Access the result along with the Faraday response object @yieldparam result [::Gapic::Rest::BaseOperation] @yieldparam response [::Faraday::Response]

@return [::Gapic::Rest::BaseOperation]

@raise [::Google::Cloud::Error] if the REST call is aborted.

# File lib/google/cloud/compute/v1/region_instances/rest/client.rb, line 169
def bulk_insert request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::BulkInsertRegionInstanceRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
  call_metadata = @config.rpcs.bulk_insert.metadata.to_h

  # Set x-goog-api-client header
  call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Compute::V1::VERSION,
    transports_version_send: [:rest]

  options.apply_defaults timeout:      @config.rpcs.bulk_insert.timeout,
                         metadata:     call_metadata

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata

  @region_instances_stub.bulk_insert request, options do |result, response|
    result = ::Gapic::Rest::BaseOperation.new result
    yield result, response if block_given?
    return result
  end
rescue ::Faraday::Error => e
  gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
  raise ::Google::Cloud::Error.from_error(gapic_error)
end
configure() { |config| ... } click to toggle source

Configure the RegionInstances Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on {Client.configure}.

See {::Google::Cloud::Compute::V1::RegionInstances::Rest::Client::Configuration} for a description of the configuration fields.

@yield [config] Configure the Client client. @yieldparam config [Client::Configuration]

@return [Client::Configuration]

# File lib/google/cloud/compute/v1/region_instances/rest/client.rb, line 90
def configure
  yield @config if block_given?
  @config
end