Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def self.configure
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
}

default_config.rpcs.get_health.timeout = 600.0

default_config.rpcs.get_version.timeout = 600.0

default_config.rpcs.list.timeout = 600.0
Expand Down Expand Up @@ -289,6 +291,105 @@ def get request, options = nil
raise ::Google::Cloud::Error.from_error(e)
end

##
# Get health info on a reservation slot.
#
# @overload get_health(request, options = nil)
# Pass arguments to `get_health` via a request object, either of type
# {::Google::Cloud::Compute::V1::GetHealthReservationSlotRequest} or an equivalent Hash.
#
# @param request [::Google::Cloud::Compute::V1::GetHealthReservationSlotRequest, ::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.
#
# @overload get_health(parent_name: nil, project: nil, request_id: nil, reservation_slot: nil, zone: nil)
# Pass arguments to `get_health` 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 parent_name [::String]
# The name of the parent reservation, parent block and parent sub-block. In
# the format of
# reservations/\\{reservation_name}/reservationBlocks/\\{reservation_block_name}/reservationSubBlocks/\\{reservation_sub_block_name}
# @param project [::String]
# Project ID for this request.
# @param request_id [::String]
# An optional request ID to identify requests.
# @param reservation_slot [::String]
# The name of the reservation slot.
# Name should conform to RFC1035 or be a resource ID.
# @param zone [::String]
# Name of the zone for this request. Zone name should conform to RFC1035.
# @yield [result, operation] Access the result along with the TransportOperation object
# @yieldparam result [::Gapic::GenericLRO::Operation]
# @yieldparam operation [::Gapic::Rest::TransportOperation]
#
# @return [::Gapic::GenericLRO::Operation]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
#
# @example Basic example
# require "google/cloud/compute/v1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Cloud::Compute::V1::ReservationSlots::Rest::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Cloud::Compute::V1::GetHealthReservationSlotRequest.new
#
# # Call the get_health method.
# result = client.get_health request
#
# # The returned object is of type Google::Cloud::Compute::V1::Operation.
# p result
#
def get_health request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?

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

# 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.get_health.metadata.to_h

# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
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]

call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id

options.apply_defaults timeout: @config.rpcs.get_health.timeout,
metadata: call_metadata,
retry_policy: @config.rpcs.get_health.retry_policy

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

@reservation_slots_stub.get_health request, options do |result, response|
result = ::Google::Cloud::Compute::V1::ZoneOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: zone_operations,
request_values: {
"project" => request.project,
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end

##
# Allows customers to get SBOM versions of a reservation slot.
#
Expand Down Expand Up @@ -826,6 +927,11 @@ class Rpcs
#
attr_reader :get
##
# RPC-specific configuration for `get_health`
# @return [::Gapic::Config::Method]
#
attr_reader :get_health
##
# RPC-specific configuration for `get_version`
# @return [::Gapic::Config::Method]
#
Expand All @@ -845,6 +951,8 @@ class Rpcs
def initialize parent_rpcs = nil
get_config = parent_rpcs.get if parent_rpcs.respond_to? :get
@get = ::Gapic::Config::Method.new get_config
get_health_config = parent_rpcs.get_health if parent_rpcs.respond_to? :get_health
@get_health = ::Gapic::Config::Method.new get_health_config
get_version_config = parent_rpcs.get_version if parent_rpcs.respond_to? :get_version
@get_version = ::Gapic::Config::Method.new get_version_config
list_config = parent_rpcs.list if parent_rpcs.respond_to? :list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,46 @@ def get request_pb, options = nil
end
end

##
# Baseline implementation for the get_health REST call
#
# @param request_pb [::Google::Cloud::Compute::V1::GetHealthReservationSlotRequest]
# A request object representing the call parameters. Required.
# @param options [::Gapic::CallOptions]
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
#
# @yield [result, operation] Access the result along with the TransportOperation object
# @yieldparam result [::Google::Cloud::Compute::V1::Operation]
# @yieldparam operation [::Gapic::Rest::TransportOperation]
#
# @return [::Google::Cloud::Compute::V1::Operation]
# A result object deserialized from the server's reply
def get_health request_pb, options = nil
raise ::ArgumentError, "request must be provided" if request_pb.nil?

verb, uri, query_string_params, body = ServiceStub.transcode_get_health_request request_pb
query_string_params = if query_string_params.any?
query_string_params.to_h { |p| p.split "=", 2 }
else
{}
end

response = @client_stub.make_http_request(
verb,
uri: uri,
body: body || "",
params: query_string_params,
method_name: "get_health",
options: options
)
operation = ::Gapic::Rest::TransportOperation.new response
result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
catch :response do
yield result, operation if block_given?
result
end
end

##
# Baseline implementation for the get_version REST call
#
Expand Down Expand Up @@ -257,6 +297,30 @@ def self.transcode_get_request request_pb
transcoder.transcode request_pb
end

##
# @private
#
# GRPC transcoding helper method for the get_health REST call
#
# @param request_pb [::Google::Cloud::Compute::V1::GetHealthReservationSlotRequest]
# A request object representing the call parameters. Required.
# @return [Array(String, [String, nil], Hash{String => String})]
# Uri, Body, Query string parameters
def self.transcode_get_health_request request_pb
transcoder = Gapic::Rest::GrpcTranscoder.new
.with_bindings(
uri_method: :post,
uri_template: "/compute/v1/projects/{project}/zones/{zone}/{parent_name}/reservationSlots/{reservation_slot}/getHealth",
matches: [
["project", %r{^[^/]+/?$}, false],
["zone", %r{^[^/]+/?$}, false],
["parent_name", %r{^reservations/[^/]+/reservationBlocks/[^/]+/reservationSubBlocks/[^/]+/?$}, false],
["reservation_slot", %r{^[^/]+/?$}, false]
]
)
transcoder.transcode request_pb
end

##
# @private
#
Expand Down
Loading
Loading