Skip to content

Commit d154efb

Browse files
feat(compute-v1): Update the API to revision 20250302, including the report_host_as_faulty call (googleapis#29350)
1 parent 0313c4d commit d154efb

5 files changed

Lines changed: 453 additions & 2 deletions

File tree

google-cloud-compute-v1/lib/google/cloud/compute/v1/compute_pb.rb

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

google-cloud-compute-v1/lib/google/cloud/compute/v1/instances/rest/client.rb

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ def self.configure
141141

142142
default_config.rpcs.remove_resource_policies.timeout = 600.0
143143

144+
default_config.rpcs.report_host_as_faulty.timeout = 600.0
145+
144146
default_config.rpcs.reset.timeout = 600.0
145147

146148
default_config.rpcs.resume.timeout = 600.0
@@ -2143,6 +2145,102 @@ def remove_resource_policies request, options = nil
21432145
raise ::Google::Cloud::Error.from_error(e)
21442146
end
21452147

2148+
##
2149+
# Mark the host as faulty and try to restart the instance on a new host.
2150+
#
2151+
# @overload report_host_as_faulty(request, options = nil)
2152+
# Pass arguments to `report_host_as_faulty` via a request object, either of type
2153+
# {::Google::Cloud::Compute::V1::ReportHostAsFaultyInstanceRequest} or an equivalent Hash.
2154+
#
2155+
# @param request [::Google::Cloud::Compute::V1::ReportHostAsFaultyInstanceRequest, ::Hash]
2156+
# A request object representing the call parameters. Required. To specify no
2157+
# parameters, or to keep all the default parameter values, pass an empty Hash.
2158+
# @param options [::Gapic::CallOptions, ::Hash]
2159+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
2160+
#
2161+
# @overload report_host_as_faulty(instance: nil, instances_report_host_as_faulty_request_resource: nil, project: nil, request_id: nil, zone: nil)
2162+
# Pass arguments to `report_host_as_faulty` via keyword arguments. Note that at
2163+
# least one keyword argument is required. To specify no parameters, or to keep all
2164+
# the default parameter values, pass an empty Hash as a request object (see above).
2165+
#
2166+
# @param instance [::String]
2167+
# Name of the instance scoping this request.
2168+
# @param instances_report_host_as_faulty_request_resource [::Google::Cloud::Compute::V1::InstancesReportHostAsFaultyRequest, ::Hash]
2169+
# The body resource for this request
2170+
# @param project [::String]
2171+
# Project ID for this request.
2172+
# @param request_id [::String]
2173+
# 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).
2174+
# @param zone [::String]
2175+
# The name of the zone for this request.
2176+
# @yield [result, operation] Access the result along with the TransportOperation object
2177+
# @yieldparam result [::Gapic::GenericLRO::Operation]
2178+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
2179+
#
2180+
# @return [::Gapic::GenericLRO::Operation]
2181+
#
2182+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
2183+
#
2184+
# @example Basic example
2185+
# require "google/cloud/compute/v1"
2186+
#
2187+
# # Create a client object. The client can be reused for multiple calls.
2188+
# client = Google::Cloud::Compute::V1::Instances::Rest::Client.new
2189+
#
2190+
# # Create a request. To set request fields, pass in keyword arguments.
2191+
# request = Google::Cloud::Compute::V1::ReportHostAsFaultyInstanceRequest.new
2192+
#
2193+
# # Call the report_host_as_faulty method.
2194+
# result = client.report_host_as_faulty request
2195+
#
2196+
# # The returned object is of type Google::Cloud::Compute::V1::Operation.
2197+
# p result
2198+
#
2199+
def report_host_as_faulty request, options = nil
2200+
raise ::ArgumentError, "request must be provided" if request.nil?
2201+
2202+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::ReportHostAsFaultyInstanceRequest
2203+
2204+
# Converts hash and nil to an options object
2205+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2206+
2207+
# Customize the options with defaults
2208+
call_metadata = @config.rpcs.report_host_as_faulty.metadata.to_h
2209+
2210+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
2211+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2212+
lib_name: @config.lib_name, lib_version: @config.lib_version,
2213+
gapic_version: ::Google::Cloud::Compute::V1::VERSION,
2214+
transports_version_send: [:rest]
2215+
2216+
call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
2217+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2218+
2219+
options.apply_defaults timeout: @config.rpcs.report_host_as_faulty.timeout,
2220+
metadata: call_metadata,
2221+
retry_policy: @config.rpcs.report_host_as_faulty.retry_policy
2222+
2223+
options.apply_defaults timeout: @config.timeout,
2224+
metadata: @config.metadata,
2225+
retry_policy: @config.retry_policy
2226+
2227+
@instances_stub.report_host_as_faulty request, options do |result, response|
2228+
result = ::Google::Cloud::Compute::V1::ZoneOperations::Rest::NonstandardLro.create_operation(
2229+
operation: result,
2230+
client: zone_operations,
2231+
request_values: {
2232+
"project" => request.project,
2233+
"zone" => request.zone
2234+
},
2235+
options: options
2236+
)
2237+
yield result, response if block_given?
2238+
throw :response, result
2239+
end
2240+
rescue ::Gapic::Rest::Error => e
2241+
raise ::Google::Cloud::Error.from_error(e)
2242+
end
2243+
21462244
##
21472245
# Performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.
21482246
#
@@ -5046,6 +5144,11 @@ class Rpcs
50465144
#
50475145
attr_reader :remove_resource_policies
50485146
##
5147+
# RPC-specific configuration for `report_host_as_faulty`
5148+
# @return [::Gapic::Config::Method]
5149+
#
5150+
attr_reader :report_host_as_faulty
5151+
##
50495152
# RPC-specific configuration for `reset`
50505153
# @return [::Gapic::Config::Method]
50515154
#
@@ -5228,6 +5331,8 @@ def initialize parent_rpcs = nil
52285331
@perform_maintenance = ::Gapic::Config::Method.new perform_maintenance_config
52295332
remove_resource_policies_config = parent_rpcs.remove_resource_policies if parent_rpcs.respond_to? :remove_resource_policies
52305333
@remove_resource_policies = ::Gapic::Config::Method.new remove_resource_policies_config
5334+
report_host_as_faulty_config = parent_rpcs.report_host_as_faulty if parent_rpcs.respond_to? :report_host_as_faulty
5335+
@report_host_as_faulty = ::Gapic::Config::Method.new report_host_as_faulty_config
52315336
reset_config = parent_rpcs.reset if parent_rpcs.respond_to? :reset
52325337
@reset = ::Gapic::Config::Method.new reset_config
52335338
resume_config = parent_rpcs.resume if parent_rpcs.respond_to? :resume

google-cloud-compute-v1/lib/google/cloud/compute/v1/instances/rest/service_stub.rb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,46 @@ def remove_resource_policies request_pb, options = nil
873873
end
874874
end
875875

876+
##
877+
# Baseline implementation for the report_host_as_faulty REST call
878+
#
879+
# @param request_pb [::Google::Cloud::Compute::V1::ReportHostAsFaultyInstanceRequest]
880+
# A request object representing the call parameters. Required.
881+
# @param options [::Gapic::CallOptions]
882+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
883+
#
884+
# @yield [result, operation] Access the result along with the TransportOperation object
885+
# @yieldparam result [::Google::Cloud::Compute::V1::Operation]
886+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
887+
#
888+
# @return [::Google::Cloud::Compute::V1::Operation]
889+
# A result object deserialized from the server's reply
890+
def report_host_as_faulty request_pb, options = nil
891+
raise ::ArgumentError, "request must be provided" if request_pb.nil?
892+
893+
verb, uri, query_string_params, body = ServiceStub.transcode_report_host_as_faulty_request request_pb
894+
query_string_params = if query_string_params.any?
895+
query_string_params.to_h { |p| p.split "=", 2 }
896+
else
897+
{}
898+
end
899+
900+
response = @client_stub.make_http_request(
901+
verb,
902+
uri: uri,
903+
body: body || "",
904+
params: query_string_params,
905+
method_name: "report_host_as_faulty",
906+
options: options
907+
)
908+
operation = ::Gapic::Rest::TransportOperation.new response
909+
result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
910+
catch :response do
911+
yield result, operation if block_given?
912+
result
913+
end
914+
end
915+
876916
##
877917
# Baseline implementation for the reset REST call
878918
#
@@ -2454,6 +2494,30 @@ def self.transcode_remove_resource_policies_request request_pb
24542494
transcoder.transcode request_pb
24552495
end
24562496

2497+
##
2498+
# @private
2499+
#
2500+
# GRPC transcoding helper method for the report_host_as_faulty REST call
2501+
#
2502+
# @param request_pb [::Google::Cloud::Compute::V1::ReportHostAsFaultyInstanceRequest]
2503+
# A request object representing the call parameters. Required.
2504+
# @return [Array(String, [String, nil], Hash{String => String})]
2505+
# Uri, Body, Query string parameters
2506+
def self.transcode_report_host_as_faulty_request request_pb
2507+
transcoder = Gapic::Rest::GrpcTranscoder.new
2508+
.with_bindings(
2509+
uri_method: :post,
2510+
uri_template: "/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/reportHostAsFaulty",
2511+
body: "instances_report_host_as_faulty_request_resource",
2512+
matches: [
2513+
["project", %r{^[^/]+/?$}, false],
2514+
["zone", %r{^[^/]+/?$}, false],
2515+
["instance", %r{^[^/]+/?$}, false]
2516+
]
2517+
)
2518+
transcoder.transcode request_pb
2519+
end
2520+
24572521
##
24582522
# @private
24592523
#

0 commit comments

Comments
 (0)