lib/google/cloud/compute/v1/instance_group_managers/rest/client.rb in google-cloud-compute-v1-2.14.0 vs lib/google/cloud/compute/v1/instance_group_managers/rest/client.rb in google-cloud-compute-v1-2.15.0
- old
+ new
@@ -115,14 +115,22 @@
default_config.rpcs.recreate_instances.timeout = 600.0
default_config.rpcs.resize.timeout = 600.0
+ default_config.rpcs.resume_instances.timeout = 600.0
+
default_config.rpcs.set_instance_template.timeout = 600.0
default_config.rpcs.set_target_pools.timeout = 600.0
+ default_config.rpcs.start_instances.timeout = 600.0
+
+ default_config.rpcs.stop_instances.timeout = 600.0
+
+ default_config.rpcs.suspend_instances.timeout = 600.0
+
default_config.rpcs.update_per_instance_configs.timeout = 600.0
default_config
end
yield @configure if block_given?
@@ -206,21 +214,41 @@
@instance_group_managers_stub = ::Google::Cloud::Compute::V1::InstanceGroupManagers::Rest::ServiceStub.new(
endpoint: @config.endpoint,
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
universe_domain: @config.universe_domain,
- credentials: credentials
+ credentials: credentials,
+ logger: @config.logger
)
+
+ @instance_group_managers_stub.logger(stub: true)&.info do |entry|
+ entry.set_system_name
+ entry.set_service
+ entry.message = "Created client for #{entry.service}"
+ entry.set_credentials_fields credentials
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
+ end
end
##
# Get the associated client for long-running operations via ZoneOperations.
#
# @return [::Google::Cloud::Compute::V1::ZoneOperations::Rest::Client]
#
attr_reader :zone_operations
+ ##
+ # The logger used for request/response debug logging.
+ #
+ # @return [Logger]
+ #
+ def logger
+ @instance_group_managers_stub.logger
+ end
+
# Service calls
##
# Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
#
@@ -309,11 +337,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -403,11 +431,11 @@
retry_policy: @config.retry_policy
@instance_group_managers_stub.aggregated_list request, options do |result, operation|
result = ::Gapic::Rest::PagedEnumerable.new @instance_group_managers_stub, :aggregated_list, "items", request, result, options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -497,11 +525,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -593,11 +621,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -687,11 +715,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -783,11 +811,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -877,11 +905,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -960,11 +988,10 @@
metadata: @config.metadata,
retry_policy: @config.retry_policy
@instance_group_managers_stub.get request, options do |result, operation|
yield result, operation if block_given?
- return result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1054,11 +1081,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1146,11 +1173,11 @@
retry_policy: @config.retry_policy
@instance_group_managers_stub.list request, options do |result, operation|
result = ::Gapic::Rest::PagedEnumerable.new @instance_group_managers_stub, :list, "items", request, result, options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1240,11 +1267,11 @@
retry_policy: @config.retry_policy
@instance_group_managers_stub.list_errors request, options do |result, operation|
result = ::Gapic::Rest::PagedEnumerable.new @instance_group_managers_stub, :list_errors, "items", request, result, options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1334,11 +1361,11 @@
retry_policy: @config.retry_policy
@instance_group_managers_stub.list_managed_instances request, options do |result, operation|
result = ::Gapic::Rest::PagedEnumerable.new @instance_group_managers_stub, :list_managed_instances, "managed_instances", request, result, options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1428,11 +1455,11 @@
retry_policy: @config.retry_policy
@instance_group_managers_stub.list_per_instance_configs request, options do |result, operation|
result = ::Gapic::Rest::PagedEnumerable.new @instance_group_managers_stub, :list_per_instance_configs, "items", request, result, options
yield result, operation if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1524,11 +1551,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1620,11 +1647,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1716,11 +1743,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -1812,17 +1839,113 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
##
+ # Flags the specified instances in the managed instance group to be resumed. This method increases the targetSize and decreases the targetSuspendedSize of the managed instance group by the number of instances that you resume. The resumeInstances operation is marked DONE if the resumeInstances request is successful. The underlying actions take additional time. You must separately verify the status of the RESUMING action with the listmanagedinstances method. In this request, you can only specify instances that are suspended. For example, if an instance was previously suspended using the suspendInstances method, it can be resumed using the resumeInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are resumed. You can specify a maximum of 1000 instances with this method per request.
+ #
+ # @overload resume_instances(request, options = nil)
+ # Pass arguments to `resume_instances` via a request object, either of type
+ # {::Google::Cloud::Compute::V1::ResumeInstancesInstanceGroupManagerRequest} or an equivalent Hash.
+ #
+ # @param request [::Google::Cloud::Compute::V1::ResumeInstancesInstanceGroupManagerRequest, ::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 resume_instances(instance_group_manager: nil, instance_group_managers_resume_instances_request_resource: nil, project: nil, request_id: nil, zone: nil)
+ # Pass arguments to `resume_instances` 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 instance_group_manager [::String]
+ # The name of the managed instance group.
+ # @param instance_group_managers_resume_instances_request_resource [::Google::Cloud::Compute::V1::InstanceGroupManagersResumeInstancesRequest, ::Hash]
+ # The body resource for this request
+ # @param project [::String]
+ # Project ID 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).
+ # @param zone [::String]
+ # The name of the zone where the managed instance group is located.
+ # @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::InstanceGroupManagers::Rest::Client.new
+ #
+ # # Create a request. To set request fields, pass in keyword arguments.
+ # request = Google::Cloud::Compute::V1::ResumeInstancesInstanceGroupManagerRequest.new
+ #
+ # # Call the resume_instances method.
+ # result = client.resume_instances request
+ #
+ # # The returned object is of type Google::Cloud::Compute::V1::Operation.
+ # p result
+ #
+ def resume_instances request, options = nil
+ raise ::ArgumentError, "request must be provided" if request.nil?
+
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::ResumeInstancesInstanceGroupManagerRequest
+
+ # 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.resume_instances.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.resume_instances.timeout,
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.resume_instances.retry_policy
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
+
+ @instance_group_managers_stub.resume_instances 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
+
+ ##
# Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE.
#
# @overload set_instance_template(request, options = nil)
# Pass arguments to `set_instance_template` via a request object, either of type
# {::Google::Cloud::Compute::V1::SetInstanceTemplateInstanceGroupManagerRequest} or an equivalent Hash.
@@ -1908,11 +2031,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -2004,17 +2127,305 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
##
+ # Flags the specified instances in the managed instance group to be started. This method increases the targetSize and decreases the targetStoppedSize of the managed instance group by the number of instances that you start. The startInstances operation is marked DONE if the startInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STARTING action with the listmanagedinstances method. In this request, you can only specify instances that are stopped. For example, if an instance was previously stopped using the stopInstances method, it can be started using the startInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are started. You can specify a maximum of 1000 instances with this method per request.
+ #
+ # @overload start_instances(request, options = nil)
+ # Pass arguments to `start_instances` via a request object, either of type
+ # {::Google::Cloud::Compute::V1::StartInstancesInstanceGroupManagerRequest} or an equivalent Hash.
+ #
+ # @param request [::Google::Cloud::Compute::V1::StartInstancesInstanceGroupManagerRequest, ::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 start_instances(instance_group_manager: nil, instance_group_managers_start_instances_request_resource: nil, project: nil, request_id: nil, zone: nil)
+ # Pass arguments to `start_instances` 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 instance_group_manager [::String]
+ # The name of the managed instance group.
+ # @param instance_group_managers_start_instances_request_resource [::Google::Cloud::Compute::V1::InstanceGroupManagersStartInstancesRequest, ::Hash]
+ # The body resource for this request
+ # @param project [::String]
+ # Project ID 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).
+ # @param zone [::String]
+ # The name of the zone where the managed instance group is located.
+ # @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::InstanceGroupManagers::Rest::Client.new
+ #
+ # # Create a request. To set request fields, pass in keyword arguments.
+ # request = Google::Cloud::Compute::V1::StartInstancesInstanceGroupManagerRequest.new
+ #
+ # # Call the start_instances method.
+ # result = client.start_instances request
+ #
+ # # The returned object is of type Google::Cloud::Compute::V1::Operation.
+ # p result
+ #
+ def start_instances request, options = nil
+ raise ::ArgumentError, "request must be provided" if request.nil?
+
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::StartInstancesInstanceGroupManagerRequest
+
+ # 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.start_instances.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.start_instances.timeout,
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.start_instances.retry_policy
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
+
+ @instance_group_managers_stub.start_instances 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
+
+ ##
+ # Flags the specified instances in the managed instance group to be immediately stopped. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetStoppedSize of the managed instance group by the number of instances that you stop. The stopInstances operation is marked DONE if the stopInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STOPPING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays stopping the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is stopped. Stopped instances can be started using the startInstances method. You can specify a maximum of 1000 instances with this method per request.
+ #
+ # @overload stop_instances(request, options = nil)
+ # Pass arguments to `stop_instances` via a request object, either of type
+ # {::Google::Cloud::Compute::V1::StopInstancesInstanceGroupManagerRequest} or an equivalent Hash.
+ #
+ # @param request [::Google::Cloud::Compute::V1::StopInstancesInstanceGroupManagerRequest, ::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 stop_instances(instance_group_manager: nil, instance_group_managers_stop_instances_request_resource: nil, project: nil, request_id: nil, zone: nil)
+ # Pass arguments to `stop_instances` 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 instance_group_manager [::String]
+ # The name of the managed instance group.
+ # @param instance_group_managers_stop_instances_request_resource [::Google::Cloud::Compute::V1::InstanceGroupManagersStopInstancesRequest, ::Hash]
+ # The body resource for this request
+ # @param project [::String]
+ # Project ID 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).
+ # @param zone [::String]
+ # The name of the zone where the managed instance group is located.
+ # @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::InstanceGroupManagers::Rest::Client.new
+ #
+ # # Create a request. To set request fields, pass in keyword arguments.
+ # request = Google::Cloud::Compute::V1::StopInstancesInstanceGroupManagerRequest.new
+ #
+ # # Call the stop_instances method.
+ # result = client.stop_instances request
+ #
+ # # The returned object is of type Google::Cloud::Compute::V1::Operation.
+ # p result
+ #
+ def stop_instances request, options = nil
+ raise ::ArgumentError, "request must be provided" if request.nil?
+
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::StopInstancesInstanceGroupManagerRequest
+
+ # 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.stop_instances.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.stop_instances.timeout,
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.stop_instances.retry_policy
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
+
+ @instance_group_managers_stub.stop_instances 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
+
+ ##
+ # Flags the specified instances in the managed instance group to be immediately suspended. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetSuspendedSize of the managed instance group by the number of instances that you suspend. The suspendInstances operation is marked DONE if the suspendInstances request is successful. The underlying actions take additional time. You must separately verify the status of the SUSPENDING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays suspension of the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is suspended. Suspended instances can be resumed using the resumeInstances method. You can specify a maximum of 1000 instances with this method per request.
+ #
+ # @overload suspend_instances(request, options = nil)
+ # Pass arguments to `suspend_instances` via a request object, either of type
+ # {::Google::Cloud::Compute::V1::SuspendInstancesInstanceGroupManagerRequest} or an equivalent Hash.
+ #
+ # @param request [::Google::Cloud::Compute::V1::SuspendInstancesInstanceGroupManagerRequest, ::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 suspend_instances(instance_group_manager: nil, instance_group_managers_suspend_instances_request_resource: nil, project: nil, request_id: nil, zone: nil)
+ # Pass arguments to `suspend_instances` 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 instance_group_manager [::String]
+ # The name of the managed instance group.
+ # @param instance_group_managers_suspend_instances_request_resource [::Google::Cloud::Compute::V1::InstanceGroupManagersSuspendInstancesRequest, ::Hash]
+ # The body resource for this request
+ # @param project [::String]
+ # Project ID 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).
+ # @param zone [::String]
+ # The name of the zone where the managed instance group is located.
+ # @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::InstanceGroupManagers::Rest::Client.new
+ #
+ # # Create a request. To set request fields, pass in keyword arguments.
+ # request = Google::Cloud::Compute::V1::SuspendInstancesInstanceGroupManagerRequest.new
+ #
+ # # Call the suspend_instances method.
+ # result = client.suspend_instances request
+ #
+ # # The returned object is of type Google::Cloud::Compute::V1::Operation.
+ # p result
+ #
+ def suspend_instances request, options = nil
+ raise ::ArgumentError, "request must be provided" if request.nil?
+
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::SuspendInstancesInstanceGroupManagerRequest
+
+ # 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.suspend_instances.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.suspend_instances.timeout,
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.suspend_instances.retry_policy
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
+
+ @instance_group_managers_stub.suspend_instances 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
+
+ ##
# Inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch.
#
# @overload update_per_instance_configs(request, options = nil)
# Pass arguments to `update_per_instance_configs` via a request object, either of type
# {::Google::Cloud::Compute::V1::UpdatePerInstanceConfigsInstanceGroupManagerRequest} or an equivalent Hash.
@@ -2100,11 +2511,11 @@
"zone" => request.zone
},
options: options
)
yield result, response if block_given?
- return result
+ throw :response, result
end
rescue ::Gapic::Rest::Error => e
raise ::Google::Cloud::Error.from_error(e)
end
@@ -2180,10 +2591,15 @@
# @!attribute [rw] universe_domain
# The universe domain within which to make requests. This determines the
# default endpoint URL. The default value of nil uses the environment
# universe (usually the default "googleapis.com" universe).
# @return [::String,nil]
+ # @!attribute [rw] logger
+ # A custom logger to use for request/response debug logging, or the value
+ # `:default` (the default) to construct a default logger, or `nil` to
+ # explicitly disable logging.
+ # @return [::Logger,:default,nil]
#
class Configuration
extend ::Gapic::Config
# @private
@@ -2201,10 +2617,11 @@
config_attr :timeout, nil, ::Numeric, nil
config_attr :metadata, nil, ::Hash, nil
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
config_attr :quota_project, nil, ::String, nil
config_attr :universe_domain, nil, ::String, nil
+ config_attr :logger, :default, ::Logger, nil, :default
# @private
def initialize parent_config = nil
@parent_config = parent_config unless parent_config.nil?
@@ -2325,20 +2742,40 @@
# RPC-specific configuration for `resize`
# @return [::Gapic::Config::Method]
#
attr_reader :resize
##
+ # RPC-specific configuration for `resume_instances`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :resume_instances
+ ##
# RPC-specific configuration for `set_instance_template`
# @return [::Gapic::Config::Method]
#
attr_reader :set_instance_template
##
# RPC-specific configuration for `set_target_pools`
# @return [::Gapic::Config::Method]
#
attr_reader :set_target_pools
##
+ # RPC-specific configuration for `start_instances`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :start_instances
+ ##
+ # RPC-specific configuration for `stop_instances`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :stop_instances
+ ##
+ # RPC-specific configuration for `suspend_instances`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :suspend_instances
+ ##
# RPC-specific configuration for `update_per_instance_configs`
# @return [::Gapic::Config::Method]
#
attr_reader :update_per_instance_configs
@@ -2376,13 +2813,21 @@
@patch_per_instance_configs = ::Gapic::Config::Method.new patch_per_instance_configs_config
recreate_instances_config = parent_rpcs.recreate_instances if parent_rpcs.respond_to? :recreate_instances
@recreate_instances = ::Gapic::Config::Method.new recreate_instances_config
resize_config = parent_rpcs.resize if parent_rpcs.respond_to? :resize
@resize = ::Gapic::Config::Method.new resize_config
+ resume_instances_config = parent_rpcs.resume_instances if parent_rpcs.respond_to? :resume_instances
+ @resume_instances = ::Gapic::Config::Method.new resume_instances_config
set_instance_template_config = parent_rpcs.set_instance_template if parent_rpcs.respond_to? :set_instance_template
@set_instance_template = ::Gapic::Config::Method.new set_instance_template_config
set_target_pools_config = parent_rpcs.set_target_pools if parent_rpcs.respond_to? :set_target_pools
@set_target_pools = ::Gapic::Config::Method.new set_target_pools_config
+ start_instances_config = parent_rpcs.start_instances if parent_rpcs.respond_to? :start_instances
+ @start_instances = ::Gapic::Config::Method.new start_instances_config
+ stop_instances_config = parent_rpcs.stop_instances if parent_rpcs.respond_to? :stop_instances
+ @stop_instances = ::Gapic::Config::Method.new stop_instances_config
+ suspend_instances_config = parent_rpcs.suspend_instances if parent_rpcs.respond_to? :suspend_instances
+ @suspend_instances = ::Gapic::Config::Method.new suspend_instances_config
update_per_instance_configs_config = parent_rpcs.update_per_instance_configs if parent_rpcs.respond_to? :update_per_instance_configs
@update_per_instance_configs = ::Gapic::Config::Method.new update_per_instance_configs_config
yield self if block_given?
end