Class: Google::Cloud::Compute::V1::Instances::Rest::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/compute/v1/instances/rest/client.rb

Overview

REST client for the Instances service.

The Instances API.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new Instances REST client object.

Examples:


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

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

Yields:

  • (config)

    Configure the Instances client.

Yield Parameters:



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 251

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
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @zone_operations = ::Google::Cloud::Compute::V1::ZoneOperations::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @instances_stub = ::Google::Cloud::Compute::V1::Instances::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )
end

Instance Attribute Details

#zone_operations::Google::Cloud::Compute::V1::ZoneOperations::Rest::Client (readonly)

Get the associated client for long-running operations via ZoneOperations.



294
295
296
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 294

def zone_operations
  @zone_operations
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the Instances Client class.

See Configuration for a description of the configuration fields.

Examples:


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

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 63

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.add_access_config.timeout = 600.0

    default_config.rpcs.add_resource_policies.timeout = 600.0

    default_config.rpcs.aggregated_list.timeout = 600.0
    default_config.rpcs.aggregated_list.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.attach_disk.timeout = 600.0

    default_config.rpcs.bulk_insert.timeout = 600.0

    default_config.rpcs.delete.timeout = 600.0

    default_config.rpcs.delete_access_config.timeout = 600.0

    default_config.rpcs.detach_disk.timeout = 600.0

    default_config.rpcs.get.timeout = 600.0
    default_config.rpcs.get.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_effective_firewalls.timeout = 600.0
    default_config.rpcs.get_effective_firewalls.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_guest_attributes.timeout = 600.0
    default_config.rpcs.get_guest_attributes.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_iam_policy.timeout = 600.0
    default_config.rpcs.get_iam_policy.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_screenshot.timeout = 600.0
    default_config.rpcs.get_screenshot.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_serial_port_output.timeout = 600.0
    default_config.rpcs.get_serial_port_output.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_shielded_instance_identity.timeout = 600.0
    default_config.rpcs.get_shielded_instance_identity.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.insert.timeout = 600.0

    default_config.rpcs.list.timeout = 600.0
    default_config.rpcs.list.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.list_referrers.timeout = 600.0
    default_config.rpcs.list_referrers.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.perform_maintenance.timeout = 600.0

    default_config.rpcs.remove_resource_policies.timeout = 600.0

    default_config.rpcs.reset.timeout = 600.0

    default_config.rpcs.resume.timeout = 600.0

    default_config.rpcs.send_diagnostic_interrupt.timeout = 600.0

    default_config.rpcs.set_deletion_protection.timeout = 600.0

    default_config.rpcs.set_disk_auto_delete.timeout = 600.0

    default_config.rpcs.set_iam_policy.timeout = 600.0

    default_config.rpcs.set_labels.timeout = 600.0

    default_config.rpcs.set_machine_resources.timeout = 600.0

    default_config.rpcs.set_machine_type.timeout = 600.0

    default_config.rpcs..timeout = 600.0

    default_config.rpcs.set_min_cpu_platform.timeout = 600.0

    default_config.rpcs.set_name.timeout = 600.0

    default_config.rpcs.set_scheduling.timeout = 600.0

    default_config.rpcs.set_security_policy.timeout = 600.0

    default_config.rpcs..timeout = 600.0

    default_config.rpcs.set_shielded_instance_integrity_policy.timeout = 600.0

    default_config.rpcs.set_tags.timeout = 600.0

    default_config.rpcs.simulate_maintenance_event.timeout = 600.0

    default_config.rpcs.start.timeout = 600.0

    default_config.rpcs.start_with_encryption_key.timeout = 600.0

    default_config.rpcs.stop.timeout = 600.0

    default_config.rpcs.suspend.timeout = 600.0

    default_config.rpcs.test_iam_permissions.timeout = 600.0

    default_config.rpcs.update.timeout = 600.0

    default_config.rpcs.update_access_config.timeout = 600.0

    default_config.rpcs.update_display_device.timeout = 600.0

    default_config.rpcs.update_network_interface.timeout = 600.0

    default_config.rpcs.update_shielded_instance_config.timeout = 600.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#add_access_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #add_access_config(access_config_resource: nil, instance: nil, network_interface: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Adds an access config to an instance's network interface.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::AddAccessConfigInstanceRequest.new

# Call the add_access_config method.
result = client.add_access_config request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #add_access_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to add_access_config via a request object, either of type AddAccessConfigInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::AddAccessConfigInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #add_access_config(access_config_resource: nil, instance: nil, network_interface: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to add_access_config 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).

    Parameters:

    • access_config_resource (::Google::Cloud::Compute::V1::AccessConfig, ::Hash) (defaults to: nil)

      The body resource for this request

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • network_interface (::String) (defaults to: nil)

      The name of the network interface to add to this instance.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 351

def add_access_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.add_access_config..to_h

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

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

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

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

  @instances_stub.add_access_config 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#add_resource_policies(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #add_resource_policies(instance: nil, instances_add_resource_policies_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::AddResourcePoliciesInstanceRequest.new

# Call the add_resource_policies method.
result = client.add_resource_policies request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #add_resource_policies(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to add_resource_policies via a request object, either of type AddResourcePoliciesInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::AddResourcePoliciesInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #add_resource_policies(instance: nil, instances_add_resource_policies_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to add_resource_policies 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • instances_add_resource_policies_request_resource (::Google::Cloud::Compute::V1::InstancesAddResourcePoliciesRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 447

def add_resource_policies request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.add_resource_policies..to_h

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

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

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

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

  @instances_stub.add_resource_policies 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#aggregated_list(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::String, ::Google::Cloud::Compute::V1::InstancesScopedList> #aggregated_list(filter: nil, include_all_scopes: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil, service_project_number: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::String, ::Google::Cloud::Compute::V1::InstancesScopedList>

Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::AggregatedListInstancesRequest.new

# Call the aggregated_list method.
result = client.aggregated_list request

# The returned object is of type Google::Cloud::Compute::V1::InstanceAggregatedList.
p result

Overloads:

  • #aggregated_list(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::String, ::Google::Cloud::Compute::V1::InstancesScopedList>

    Pass arguments to aggregated_list via a request object, either of type AggregatedListInstancesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::AggregatedListInstancesRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #aggregated_list(filter: nil, include_all_scopes: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil, service_project_number: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::String, ::Google::Cloud::Compute::V1::InstancesScopedList>

    Pass arguments to aggregated_list 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).

    Parameters:

    • filter (::String) (defaults to: nil)

      A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. These two types of filter expressions cannot be mixed in one request. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either =, !=, >, <, <=, >= or :. For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. The :* comparison can be used to test whether a key has been defined. For example, to find all objects with owner label use: labels.owner:* You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example: (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) If you want to use a regular expression, use the eq (equal) or ne (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: fieldname eq unquoted literal fieldname eq 'single quoted literal' fieldname eq "double quoted literal" (fieldname1 eq literal) (fieldname2 ne "literal") The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use name ne .*instance. You cannot combine constraints on multiple fields using regular expressions.

    • include_all_scopes (::Boolean) (defaults to: nil)

      Indicates whether every visible scope for each scope type (zone, region, global) should be included in the response. For new resource types added after this field, the flag has no effect as new resource types will always include every visible scope for each scope type in response. For resource types which predate this field, if this flag is omitted or false, only scopes of the scope types where the resource type is expected to be found will be included.

    • max_results (::Integer) (defaults to: nil)

      The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500)

    • order_by (::String) (defaults to: nil)

      Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by name or creationTimestamp desc is supported.

    • page_token (::String) (defaults to: nil)

      Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • return_partial_success (::Boolean) (defaults to: nil)

      Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code.

    • service_project_number (::Integer) (defaults to: nil)

      The Shared VPC service project id or service project number for which aggregated list request is invoked for subnetworks list-usable api.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 549

def aggregated_list request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.aggregated_list..to_h

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

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

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

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

  @instances_stub.aggregated_list request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @instances_stub, :aggregated_list, "items", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#attach_disk(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #attach_disk(attached_disk_resource: nil, force_attach: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::AttachDiskInstanceRequest.new

# Call the attach_disk method.
result = client.attach_disk request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #attach_disk(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to attach_disk via a request object, either of type AttachDiskInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::AttachDiskInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #attach_disk(attached_disk_resource: nil, force_attach: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to attach_disk 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).

    Parameters:

    • attached_disk_resource (::Google::Cloud::Compute::V1::AttachedDisk, ::Hash) (defaults to: nil)

      The body resource for this request

    • force_attach (::Boolean) (defaults to: nil)

      Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error.

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 639

def attach_disk request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.attach_disk..to_h

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

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

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

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

  @instances_stub.attach_disk 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#bulk_insert(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #bulk_insert(bulk_insert_instance_resource_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::BulkInsertInstanceRequest.new

# Call the bulk_insert method.
result = client.bulk_insert request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #bulk_insert(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to bulk_insert via a request object, either of type BulkInsertInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::BulkInsertInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #bulk_insert(bulk_insert_instance_resource_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

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

    Parameters:

    • bulk_insert_instance_resource_resource (::Google::Cloud::Compute::V1::BulkInsertInstanceResource, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 733

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::BulkInsertInstanceRequest

  # 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
   = @config.rpcs.bulk_insert..to_h

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

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

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

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

  @instances_stub.bulk_insert 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the Instances 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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



221
222
223
224
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 221

def configure
  yield @config if block_given?
  @config
end

#delete(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #delete(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Deletes the specified Instance resource. For more information, see Deleting an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::DeleteInstanceRequest.new

# Call the delete method.
result = client.delete request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #delete(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to delete via a request object, either of type DeleteInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::DeleteInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to delete 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to delete.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 827

def delete request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.delete..to_h

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

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

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

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

  @instances_stub.delete 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_access_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #delete_access_config(access_config: nil, instance: nil, network_interface: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Deletes an access config from an instance's network interface.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::DeleteAccessConfigInstanceRequest.new

# Call the delete_access_config method.
result = client.delete_access_config request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #delete_access_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to delete_access_config via a request object, either of type DeleteAccessConfigInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::DeleteAccessConfigInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #delete_access_config(access_config: nil, instance: nil, network_interface: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to delete_access_config 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).

    Parameters:

    • access_config (::String) (defaults to: nil)

      The name of the access config to delete.

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • network_interface (::String) (defaults to: nil)

      The name of the network interface.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 925

def delete_access_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.delete_access_config..to_h

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

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

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

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

  @instances_stub.delete_access_config 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#detach_disk(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #detach_disk(device_name: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Detaches a disk from an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::DetachDiskInstanceRequest.new

# Call the detach_disk method.
result = client.detach_disk request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #detach_disk(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to detach_disk via a request object, either of type DetachDiskInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::DetachDiskInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #detach_disk(device_name: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to detach_disk 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).

    Parameters:

    • device_name (::String) (defaults to: nil)

      The device name of the disk to detach. Make a get() request on the instance to view currently attached disks and device names.

    • instance (::String) (defaults to: nil)

      Instance name for this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1021

def detach_disk request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.detach_disk..to_h

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

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

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

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

  @instances_stub.detach_disk 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Instance #get(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::Instance

Returns the specified Instance resource.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetInstanceRequest.new

# Call the get method.
result = client.get request

# The returned object is of type Google::Cloud::Compute::V1::Instance.
p result

Overloads:

  • #get(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Instance

    Pass arguments to get via a request object, either of type GetInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::Instance

    Pass arguments to get 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to return.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1113

def get request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get..to_h

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

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

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

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

  @instances_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

#get_effective_firewalls(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::InstancesGetEffectiveFirewallsResponse #get_effective_firewalls(instance: nil, network_interface: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::InstancesGetEffectiveFirewallsResponse

Returns effective firewalls applied to an interface of the instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetEffectiveFirewallsInstanceRequest.new

# Call the get_effective_firewalls method.
result = client.get_effective_firewalls request

# The returned object is of type Google::Cloud::Compute::V1::InstancesGetEffectiveFirewallsResponse.
p result

Overloads:

  • #get_effective_firewalls(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::InstancesGetEffectiveFirewallsResponse

    Pass arguments to get_effective_firewalls via a request object, either of type GetEffectiveFirewallsInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetEffectiveFirewallsInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_effective_firewalls(instance: nil, network_interface: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::InstancesGetEffectiveFirewallsResponse

    Pass arguments to get_effective_firewalls 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • network_interface (::String) (defaults to: nil)

      The name of the network interface to get the effective firewalls.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1198

def get_effective_firewalls request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get_effective_firewalls..to_h

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

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

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

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

  @instances_stub.get_effective_firewalls 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

#get_guest_attributes(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::GuestAttributes #get_guest_attributes(instance: nil, project: nil, query_path: nil, variable_key: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::GuestAttributes

Returns the specified guest attributes entry.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetGuestAttributesInstanceRequest.new

# Call the get_guest_attributes method.
result = client.get_guest_attributes request

# The returned object is of type Google::Cloud::Compute::V1::GuestAttributes.
p result

Overloads:

  • #get_guest_attributes(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::GuestAttributes

    Pass arguments to get_guest_attributes via a request object, either of type GetGuestAttributesInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetGuestAttributesInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_guest_attributes(instance: nil, project: nil, query_path: nil, variable_key: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::GuestAttributes

    Pass arguments to get_guest_attributes 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • query_path (::String) (defaults to: nil)

      Specifies the guest attributes path to be queried.

    • variable_key (::String) (defaults to: nil)

      Specifies the key for the guest attributes entry.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1285

def get_guest_attributes request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get_guest_attributes..to_h

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

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

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

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

  @instances_stub.get_guest_attributes 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

#get_iam_policy(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Policy #get_iam_policy(options_requested_policy_version: nil, project: nil, resource: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::Policy

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetIamPolicyInstanceRequest.new

# Call the get_iam_policy method.
result = client.get_iam_policy request

# The returned object is of type Google::Cloud::Compute::V1::Policy.
p result

Overloads:

  • #get_iam_policy(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Policy

    Pass arguments to get_iam_policy via a request object, either of type GetIamPolicyInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetIamPolicyInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_iam_policy(options_requested_policy_version: nil, project: nil, resource: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::Policy

    Pass arguments to get_iam_policy 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).

    Parameters:

    • options_requested_policy_version (::Integer) (defaults to: nil)

      Requested IAM Policy version.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • resource (::String) (defaults to: nil)

      Name or id of the resource for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1370

def get_iam_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get_iam_policy..to_h

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

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

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

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

  @instances_stub.get_iam_policy 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

#get_screenshot(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Screenshot #get_screenshot(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::Screenshot

Returns the screenshot from the specified instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetScreenshotInstanceRequest.new

# Call the get_screenshot method.
result = client.get_screenshot request

# The returned object is of type Google::Cloud::Compute::V1::Screenshot.
p result

Overloads:

  • #get_screenshot(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Screenshot

    Pass arguments to get_screenshot via a request object, either of type GetScreenshotInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetScreenshotInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_screenshot(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::Screenshot

    Pass arguments to get_screenshot 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1453

def get_screenshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get_screenshot..to_h

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

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

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

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

  @instances_stub.get_screenshot 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

#get_serial_port_output(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::SerialPortOutput #get_serial_port_output(instance: nil, port: nil, project: nil, start: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::SerialPortOutput

Returns the last 1 MB of serial port output from the specified instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetSerialPortOutputInstanceRequest.new

# Call the get_serial_port_output method.
result = client.get_serial_port_output request

# The returned object is of type Google::Cloud::Compute::V1::SerialPortOutput.
p result

Overloads:

  • #get_serial_port_output(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::SerialPortOutput

    Pass arguments to get_serial_port_output via a request object, either of type GetSerialPortOutputInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetSerialPortOutputInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_serial_port_output(instance: nil, port: nil, project: nil, start: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::SerialPortOutput

    Pass arguments to get_serial_port_output 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance for this request.

    • port (::Integer) (defaults to: nil)

      Specifies which COM or serial port to retrieve data from.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • start (::Integer) (defaults to: nil)

      Specifies the starting byte position of the output to return. To start with the first byte of output to the specified port, omit this field or set it to 0. If the output for that byte position is available, this field matches the start parameter sent with the request. If the amount of serial console output exceeds the size of the buffer (1 MB), the oldest output is discarded and is no longer available. If the requested start position refers to discarded output, the start position is adjusted to the oldest output still available, and the adjusted start position is returned as the start property value. You can also provide a negative start position, which translates to the most recent number of bytes written to the serial port. For example, -3 is interpreted as the most recent 3 bytes written to the serial console.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1540

def get_serial_port_output request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get_serial_port_output..to_h

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

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

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

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

  @instances_stub.get_serial_port_output 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

#get_shielded_instance_identity(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::ShieldedInstanceIdentity #get_shielded_instance_identity(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::ShieldedInstanceIdentity

Returns the Shielded Instance Identity of an instance

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::GetShieldedInstanceIdentityInstanceRequest.new

# Call the get_shielded_instance_identity method.
result = client.get_shielded_instance_identity request

# The returned object is of type Google::Cloud::Compute::V1::ShieldedInstanceIdentity.
p result

Overloads:

  • #get_shielded_instance_identity(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::ShieldedInstanceIdentity

    Pass arguments to get_shielded_instance_identity via a request object, either of type GetShieldedInstanceIdentityInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::GetShieldedInstanceIdentityInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_shielded_instance_identity(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::ShieldedInstanceIdentity

    Pass arguments to get_shielded_instance_identity 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name or id of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1623

def get_shielded_instance_identity request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.get_shielded_instance_identity..to_h

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

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

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

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

  @instances_stub.get_shielded_instance_identity 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

#insert(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #insert(instance_resource: nil, project: nil, request_id: nil, source_instance_template: nil, source_machine_image: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Creates an instance resource in the specified project using the data included in the request.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::InsertInstanceRequest.new

# Call the insert method.
result = client.insert request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #insert(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to insert via a request object, either of type Google::Cloud::Compute::V1::InsertInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::InsertInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #insert(instance_resource: nil, project: nil, request_id: nil, source_instance_template: nil, source_machine_image: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to 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).

    Parameters:

    • instance_resource (::Google::Cloud::Compute::V1::Instance, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • source_instance_template (::String) (defaults to: nil)

      Specifies instance template to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to an instance template: - https://www.googleapis.com/compute/v1/projects/project /global/instanceTemplates/instanceTemplate - projects/project/global/instanceTemplates/instanceTemplate - global/instanceTemplates/instanceTemplate

    • source_machine_image (::String) (defaults to: nil)

      Specifies the machine image to use to create the instance. This field is optional. It can be a full or partial URL. For example, the following are all valid URLs to a machine image: - https://www.googleapis.com/compute/v1/projects/project/global/global /machineImages/machineImage - projects/project/global/global/machineImages/machineImage - global/machineImages/machineImage

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1712

def insert request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.insert..to_h

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

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

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

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

  @instances_stub.insert 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Instance> #list(filter: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil, zone: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Instance>

Retrieves the list of instances contained within the specified zone.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::ListInstancesRequest.new

# Call the list method.
result = client.list request

# The returned object is of type Google::Cloud::Compute::V1::InstanceList.
p result

Overloads:

  • #list(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Instance>

    Pass arguments to list via a request object, either of type ListInstancesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::ListInstancesRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list(filter: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil, zone: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Instance>

    Pass arguments to list 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).

    Parameters:

    • filter (::String) (defaults to: nil)

      A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. These two types of filter expressions cannot be mixed in one request. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either =, !=, >, <, <=, >= or :. For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. The :* comparison can be used to test whether a key has been defined. For example, to find all objects with owner label use: labels.owner:* You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example: (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) If you want to use a regular expression, use the eq (equal) or ne (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: fieldname eq unquoted literal fieldname eq 'single quoted literal' fieldname eq "double quoted literal" (fieldname1 eq literal) (fieldname2 ne "literal") The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use name ne .*instance. You cannot combine constraints on multiple fields using regular expressions.

    • max_results (::Integer) (defaults to: nil)

      The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500)

    • order_by (::String) (defaults to: nil)

      Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by name or creationTimestamp desc is supported.

    • page_token (::String) (defaults to: nil)

      Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • return_partial_success (::Boolean) (defaults to: nil)

      Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1812

def list request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.list..to_h

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

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

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

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

  @instances_stub.list request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @instances_stub, :list, "items", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_referrers(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Reference> #list_referrers(filter: nil, instance: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil, zone: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Reference>

Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::ListReferrersInstancesRequest.new

# Call the list_referrers method.
result = client.list_referrers request

# The returned object is of type Google::Cloud::Compute::V1::InstanceListReferrers.
p result

Overloads:

  • #list_referrers(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Reference>

    Pass arguments to list_referrers via a request object, either of type ListReferrersInstancesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::ListReferrersInstancesRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_referrers(filter: nil, instance: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil, zone: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Reference>

    Pass arguments to list_referrers 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).

    Parameters:

    • filter (::String) (defaults to: nil)

      A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. These two types of filter expressions cannot be mixed in one request. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either =, !=, >, <, <=, >= or :. For example, if you are filtering Compute Engine instances, you can exclude instances named example-instance by specifying name != example-instance. The :* comparison can be used to test whether a key has been defined. For example, to find all objects with owner label use: labels.owner:* You can also filter nested fields. For example, you could specify scheduling.automaticRestart = false to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") By default, each expression is an AND expression. However, you can include AND and OR expressions explicitly. For example: (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) If you want to use a regular expression, use the eq (equal) or ne (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: fieldname eq unquoted literal fieldname eq 'single quoted literal' fieldname eq "double quoted literal" (fieldname1 eq literal) (fieldname2 ne "literal") The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use name ne .*instance. You cannot combine constraints on multiple fields using regular expressions.

    • instance (::String) (defaults to: nil)

      Name of the target instance scoping this request, or '-' if the request should span over all instances in the container.

    • max_results (::Integer) (defaults to: nil)

      The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500)

    • order_by (::String) (defaults to: nil)

      Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using orderBy="creationTimestamp desc". This sorts results based on the creationTimestamp field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by name or creationTimestamp desc is supported.

    • page_token (::String) (defaults to: nil)

      Specifies a page token to use. Set pageToken to the nextPageToken returned by a previous list request to get the next page of results.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • return_partial_success (::Boolean) (defaults to: nil)

      Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1906

def list_referrers request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.list_referrers..to_h

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

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

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

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

  @instances_stub.list_referrers request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @instances_stub, :list_referrers, "items", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#perform_maintenance(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #perform_maintenance(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Perform a manual maintenance on the instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::PerformMaintenanceInstanceRequest.new

# Call the perform_maintenance method.
result = client.perform_maintenance request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #perform_maintenance(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to perform_maintenance via a request object, either of type PerformMaintenanceInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::PerformMaintenanceInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #perform_maintenance(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to perform_maintenance 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 1992

def perform_maintenance request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.perform_maintenance..to_h

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

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

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

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

  @instances_stub.perform_maintenance 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#remove_resource_policies(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #remove_resource_policies(instance: nil, instances_remove_resource_policies_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Removes resource policies from an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::RemoveResourcePoliciesInstanceRequest.new

# Call the remove_resource_policies method.
result = client.remove_resource_policies request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #remove_resource_policies(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to remove_resource_policies via a request object, either of type RemoveResourcePoliciesInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::RemoveResourcePoliciesInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #remove_resource_policies(instance: nil, instances_remove_resource_policies_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to remove_resource_policies 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • instances_remove_resource_policies_request_resource (::Google::Cloud::Compute::V1::InstancesRemoveResourcePoliciesRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2088

def remove_resource_policies request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.remove_resource_policies..to_h

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

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

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

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

  @instances_stub.remove_resource_policies 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#reset(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #reset(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

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.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::ResetInstanceRequest.new

# Call the reset method.
result = client.reset request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #reset(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to reset via a request object, either of type ResetInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::ResetInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #reset(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to reset 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2182

def reset request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.reset..to_h

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

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

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

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

  @instances_stub.reset 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#resume(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #resume(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Resumes an instance that was suspended using the instances().suspend method.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::ResumeInstanceRequest.new

# Call the resume method.
result = client.resume request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #resume(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to resume via a request object, either of type ResumeInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::ResumeInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #resume(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to resume 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to resume.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2276

def resume request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.resume..to_h

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

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

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

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

  @instances_stub.resume 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#send_diagnostic_interrupt(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceResponse #send_diagnostic_interrupt(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceResponse

Sends diagnostic interrupt to the instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceRequest.new

# Call the send_diagnostic_interrupt method.
result = client.send_diagnostic_interrupt request

# The returned object is of type Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceResponse.
p result

Overloads:

  • #send_diagnostic_interrupt(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceResponse

    Pass arguments to send_diagnostic_interrupt via a request object, either of type SendDiagnosticInterruptInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #send_diagnostic_interrupt(instance: nil, project: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::SendDiagnosticInterruptInstanceResponse

    Pass arguments to send_diagnostic_interrupt 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2368

def send_diagnostic_interrupt request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.send_diagnostic_interrupt..to_h

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

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

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

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

  @instances_stub.send_diagnostic_interrupt 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

#set_deletion_protection(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_deletion_protection(deletion_protection: nil, project: nil, request_id: nil, resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets deletion protection on the instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetDeletionProtectionInstanceRequest.new

# Call the set_deletion_protection method.
result = client.set_deletion_protection request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_deletion_protection(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_deletion_protection via a request object, either of type SetDeletionProtectionInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetDeletionProtectionInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_deletion_protection(deletion_protection: nil, project: nil, request_id: nil, resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_deletion_protection 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).

    Parameters:

    • deletion_protection (::Boolean) (defaults to: nil)

      Whether the resource should be protected against deletion.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • resource (::String) (defaults to: nil)

      Name or id of the resource for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2455

def set_deletion_protection request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_deletion_protection..to_h

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

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

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

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

  @instances_stub.set_deletion_protection 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_disk_auto_delete(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_disk_auto_delete(auto_delete: nil, device_name: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets the auto-delete flag for a disk attached to an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetDiskAutoDeleteInstanceRequest.new

# Call the set_disk_auto_delete method.
result = client.set_disk_auto_delete request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_disk_auto_delete(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_disk_auto_delete via a request object, either of type SetDiskAutoDeleteInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetDiskAutoDeleteInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_disk_auto_delete(auto_delete: nil, device_name: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_disk_auto_delete 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).

    Parameters:

    • auto_delete (::Boolean) (defaults to: nil)

      Whether to auto-delete the disk when the instance is deleted.

    • device_name (::String) (defaults to: nil)

      The device name of the disk to modify. Make a get() request on the instance to view currently attached disks and device names.

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2553

def set_disk_auto_delete request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_disk_auto_delete..to_h

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

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

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

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

  @instances_stub.set_disk_auto_delete 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_iam_policy(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Policy #set_iam_policy(project: nil, resource: nil, zone: nil, zone_set_policy_request_resource: nil) ⇒ ::Google::Cloud::Compute::V1::Policy

Sets the access control policy on the specified resource. Replaces any existing policy.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetIamPolicyInstanceRequest.new

# Call the set_iam_policy method.
result = client.set_iam_policy request

# The returned object is of type Google::Cloud::Compute::V1::Policy.
p result

Overloads:

  • #set_iam_policy(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::Policy

    Pass arguments to set_iam_policy via a request object, either of type SetIamPolicyInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetIamPolicyInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_iam_policy(project: nil, resource: nil, zone: nil, zone_set_policy_request_resource: nil) ⇒ ::Google::Cloud::Compute::V1::Policy

    Pass arguments to set_iam_policy 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).

    Parameters:

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • resource (::String) (defaults to: nil)

      Name or id of the resource for this request.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

    • zone_set_policy_request_resource (::Google::Cloud::Compute::V1::ZoneSetPolicyRequest, ::Hash) (defaults to: nil)

      The body resource for this request

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2647

def set_iam_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_iam_policy..to_h

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

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

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

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

  @instances_stub.set_iam_policy 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

#set_labels(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_labels(instance: nil, instances_set_labels_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetLabelsInstanceRequest.new

# Call the set_labels method.
result = client.set_labels request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_labels(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_labels via a request object, either of type SetLabelsInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetLabelsInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_labels(instance: nil, instances_set_labels_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_labels 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • instances_set_labels_request_resource (::Google::Cloud::Compute::V1::InstancesSetLabelsRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2734

def set_labels request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_labels..to_h

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

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

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

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

  @instances_stub.set_labels 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_machine_resources(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_machine_resources(instance: nil, instances_set_machine_resources_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Changes the number and/or type of accelerator for a stopped instance to the values specified in the request.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetMachineResourcesInstanceRequest.new

# Call the set_machine_resources method.
result = client.set_machine_resources request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_machine_resources(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_machine_resources via a request object, either of type SetMachineResourcesInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetMachineResourcesInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_machine_resources(instance: nil, instances_set_machine_resources_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_machine_resources 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • instances_set_machine_resources_request_resource (::Google::Cloud::Compute::V1::InstancesSetMachineResourcesRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2830

def set_machine_resources request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_machine_resources..to_h

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

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

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

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

  @instances_stub.set_machine_resources 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_machine_type(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_machine_type(instance: nil, instances_set_machine_type_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Changes the machine type for a stopped instance to the machine type specified in the request.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetMachineTypeInstanceRequest.new

# Call the set_machine_type method.
result = client.set_machine_type request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_machine_type(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_machine_type via a request object, either of type SetMachineTypeInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetMachineTypeInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_machine_type(instance: nil, instances_set_machine_type_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_machine_type 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • instances_set_machine_type_request_resource (::Google::Cloud::Compute::V1::InstancesSetMachineTypeRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 2926

def set_machine_type request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_machine_type..to_h

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

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

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

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

  @instances_stub.set_machine_type 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_metadata(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_metadata(instance: nil, metadata_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets metadata for the specified instance to the data included in the request.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetMetadataInstanceRequest.new

# Call the set_metadata method.
result = client. request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_metadata(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_metadata via a request object, either of type SetMetadataInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetMetadataInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_metadata(instance: nil, metadata_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_metadata 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • metadata_resource (::Google::Cloud::Compute::V1::Metadata, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3022

def  request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs...to_h

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

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

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

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

  @instances_stub. 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_min_cpu_platform(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_min_cpu_platform(instance: nil, instances_set_min_cpu_platform_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetMinCpuPlatformInstanceRequest.new

# Call the set_min_cpu_platform method.
result = client.set_min_cpu_platform request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_min_cpu_platform(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_min_cpu_platform via a request object, either of type SetMinCpuPlatformInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetMinCpuPlatformInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_min_cpu_platform(instance: nil, instances_set_min_cpu_platform_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_min_cpu_platform 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • instances_set_min_cpu_platform_request_resource (::Google::Cloud::Compute::V1::InstancesSetMinCpuPlatformRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3118

def set_min_cpu_platform request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_min_cpu_platform..to_h

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

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

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

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

  @instances_stub.set_min_cpu_platform 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_name(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_name(instance: nil, instances_set_name_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets name of an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetNameInstanceRequest.new

# Call the set_name method.
result = client.set_name request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_name(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_name via a request object, either of type SetNameInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetNameInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_name(instance: nil, instances_set_name_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_name 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • instances_set_name_request_resource (::Google::Cloud::Compute::V1::InstancesSetNameRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3214

def set_name request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_name..to_h

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

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

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

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

  @instances_stub.set_name 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_scheduling(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_scheduling(instance: nil, project: nil, request_id: nil, scheduling_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a TERMINATED state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetSchedulingInstanceRequest.new

# Call the set_scheduling method.
result = client.set_scheduling request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_scheduling(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_scheduling via a request object, either of type SetSchedulingInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetSchedulingInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_scheduling(instance: nil, project: nil, request_id: nil, scheduling_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_scheduling 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Instance name for this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • scheduling_resource (::Google::Cloud::Compute::V1::Scheduling, ::Hash) (defaults to: nil)

      The body resource for this request

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3310

def set_scheduling request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_scheduling..to_h

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

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

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

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

  @instances_stub.set_scheduling 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_security_policy(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_security_policy(instance: nil, instances_set_security_policy_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets the Google Cloud Armor security policy for the specified instance. For more information, see Google Cloud Armor Overview

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetSecurityPolicyInstanceRequest.new

# Call the set_security_policy method.
result = client.set_security_policy request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_security_policy(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_security_policy via a request object, either of type SetSecurityPolicyInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetSecurityPolicyInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_security_policy(instance: nil, instances_set_security_policy_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_security_policy 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the Instance resource to which the security policy should be set. The name should conform to RFC1035.

    • instances_set_security_policy_request_resource (::Google::Cloud::Compute::V1::InstancesSetSecurityPolicyRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      Name of the zone scoping this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3406

def set_security_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_security_policy..to_h

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

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

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

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

  @instances_stub.set_security_policy 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_service_account(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_service_account(instance: nil, instances_set_service_account_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetServiceAccountInstanceRequest.new

# Call the set_service_account method.
result = client. request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_service_account(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_service_account via a request object, either of type SetServiceAccountInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetServiceAccountInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_service_account(instance: nil, instances_set_service_account_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_service_account 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to start.

    • instances_set_service_account_request_resource (::Google::Cloud::Compute::V1::InstancesSetServiceAccountRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3502

def  request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs...to_h

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

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

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

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

  @instances_stub. 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_shielded_instance_integrity_policy(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_shielded_instance_integrity_policy(instance: nil, project: nil, request_id: nil, shielded_instance_integrity_policy_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetShieldedInstanceIntegrityPolicyInstanceRequest.new

# Call the set_shielded_instance_integrity_policy method.
result = client.set_shielded_instance_integrity_policy request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_shielded_instance_integrity_policy(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_shielded_instance_integrity_policy via a request object, either of type SetShieldedInstanceIntegrityPolicyInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetShieldedInstanceIntegrityPolicyInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_shielded_instance_integrity_policy(instance: nil, project: nil, request_id: nil, shielded_instance_integrity_policy_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_shielded_instance_integrity_policy 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name or id of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • shielded_instance_integrity_policy_resource (::Google::Cloud::Compute::V1::ShieldedInstanceIntegrityPolicy, ::Hash) (defaults to: nil)

      The body resource for this request

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3598

def set_shielded_instance_integrity_policy request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_shielded_instance_integrity_policy..to_h

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

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

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

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

  @instances_stub.set_shielded_instance_integrity_policy 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#set_tags(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #set_tags(instance: nil, project: nil, request_id: nil, tags_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Sets network tags for the specified instance to the data included in the request.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SetTagsInstanceRequest.new

# Call the set_tags method.
result = client.set_tags request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #set_tags(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_tags via a request object, either of type SetTagsInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SetTagsInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #set_tags(instance: nil, project: nil, request_id: nil, tags_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to set_tags 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • tags_resource (::Google::Cloud::Compute::V1::Tags, ::Hash) (defaults to: nil)

      The body resource for this request

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3694

def set_tags request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.set_tags..to_h

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

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

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

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

  @instances_stub.set_tags 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#simulate_maintenance_event(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #simulate_maintenance_event(instance: nil, project: nil, request_id: nil, with_extended_notifications: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SimulateMaintenanceEventInstanceRequest.new

# Call the simulate_maintenance_event method.
result = client.simulate_maintenance_event request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #simulate_maintenance_event(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to simulate_maintenance_event via a request object, either of type SimulateMaintenanceEventInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SimulateMaintenanceEventInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #simulate_maintenance_event(instance: nil, project: nil, request_id: nil, with_extended_notifications: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to simulate_maintenance_event 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • with_extended_notifications (::Boolean) (defaults to: nil)

      Determines whether the customers receive notifications before migration. Only applicable to SF vms.

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3790

def simulate_maintenance_event request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.simulate_maintenance_event..to_h

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

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

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

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

  @instances_stub.simulate_maintenance_event 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#start(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #start(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::StartInstanceRequest.new

# Call the start method.
result = client.start request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #start(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to start via a request object, either of type StartInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::StartInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #start(instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to start 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to start.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3884

def start request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.start..to_h

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

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

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

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

  @instances_stub.start 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#start_with_encryption_key(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #start_with_encryption_key(instance: nil, instances_start_with_encryption_key_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::StartWithEncryptionKeyInstanceRequest.new

# Call the start_with_encryption_key method.
result = client.start_with_encryption_key request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #start_with_encryption_key(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to start_with_encryption_key via a request object, either of type StartWithEncryptionKeyInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::StartWithEncryptionKeyInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #start_with_encryption_key(instance: nil, instances_start_with_encryption_key_request_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to start_with_encryption_key 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to start.

    • instances_start_with_encryption_key_request_resource (::Google::Cloud::Compute::V1::InstancesStartWithEncryptionKeyRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 3980

def start_with_encryption_key request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.start_with_encryption_key..to_h

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

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

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

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

  @instances_stub.start_with_encryption_key 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#stop(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #stop(discard_local_ssd: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::StopInstanceRequest.new

# Call the stop method.
result = client.stop request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #stop(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to stop via a request object, either of type StopInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::StopInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #stop(discard_local_ssd: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to stop 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).

    Parameters:

    • discard_local_ssd (::Boolean) (defaults to: nil)

      This property is required if the instance has any attached Local SSD disks. If false, Local SSD data will be preserved when the instance is suspended. If true, the contents of any attached Local SSD disks will be discarded.

    • instance (::String) (defaults to: nil)

      Name of the instance resource to stop.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4076

def stop request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.stop..to_h

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

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

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

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

  @instances_stub.stop 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#suspend(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #suspend(discard_local_ssd: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::SuspendInstanceRequest.new

# Call the suspend method.
result = client.suspend request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #suspend(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to suspend via a request object, either of type SuspendInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::SuspendInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #suspend(discard_local_ssd: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to suspend 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).

    Parameters:

    • discard_local_ssd (::Boolean) (defaults to: nil)

      This property is required if the instance has any attached Local SSD disks. If false, Local SSD data will be preserved when the instance is suspended. If true, the contents of any attached Local SSD disks will be discarded.

    • instance (::String) (defaults to: nil)

      Name of the instance resource to suspend.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4172

def suspend request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.suspend..to_h

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

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

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

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

  @instances_stub.suspend 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#test_iam_permissions(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::TestPermissionsResponse #test_iam_permissions(project: nil, resource: nil, test_permissions_request_resource: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::TestPermissionsResponse

Returns permissions that a caller has on the specified resource.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::TestIamPermissionsInstanceRequest.new

# Call the test_iam_permissions method.
result = client.test_iam_permissions request

# The returned object is of type Google::Cloud::Compute::V1::TestPermissionsResponse.
p result

Overloads:

  • #test_iam_permissions(request, options = nil) ⇒ ::Google::Cloud::Compute::V1::TestPermissionsResponse

    Pass arguments to test_iam_permissions via a request object, either of type TestIamPermissionsInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::TestIamPermissionsInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #test_iam_permissions(project: nil, resource: nil, test_permissions_request_resource: nil, zone: nil) ⇒ ::Google::Cloud::Compute::V1::TestPermissionsResponse

    Pass arguments to test_iam_permissions 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).

    Parameters:

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • resource (::String) (defaults to: nil)

      Name or id of the resource for this request.

    • test_permissions_request_resource (::Google::Cloud::Compute::V1::TestPermissionsRequest, ::Hash) (defaults to: nil)

      The body resource for this request

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4266

def test_iam_permissions request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.test_iam_permissions..to_h

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

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

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

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

  @instances_stub.test_iam_permissions 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

#universe_domainString

The effective universe domain

Returns:

  • (String)


231
232
233
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 231

def universe_domain
  @instances_stub.universe_domain
end

#update(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #update(instance: nil, instance_resource: nil, minimal_action: nil, most_disruptive_allowed_action: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::UpdateInstanceRequest.new

# Call the update method.
result = client.update request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #update(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update via a request object, either of type UpdateInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::UpdateInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update(instance: nil, instance_resource: nil, minimal_action: nil, most_disruptive_allowed_action: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name of the instance resource to update.

    • instance_resource (::Google::Cloud::Compute::V1::Instance, ::Hash) (defaults to: nil)

      The body resource for this request

    • minimal_action (::String) (defaults to: nil)

      Specifies the action to take when updating an instance even if the updated properties do not require it. If not specified, then Compute Engine acts based on the minimum action that the updated properties require. Check the MinimalAction enum for the list of possible values.

    • most_disruptive_allowed_action (::String) (defaults to: nil)

      Specifies the most disruptive action that can be taken on the instance as part of the update. Compute Engine returns an error if the instance properties require a more disruptive action as part of the instance update. Valid options from lowest to highest are NO_EFFECT, REFRESH, and RESTART. Check the MostDisruptiveAllowedAction enum for the list of possible values.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4359

def update request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.update..to_h

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

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

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

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

  @instances_stub.update 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_access_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #update_access_config(access_config_resource: nil, instance: nil, network_interface: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::UpdateAccessConfigInstanceRequest.new

# Call the update_access_config method.
result = client.update_access_config request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #update_access_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_access_config via a request object, either of type UpdateAccessConfigInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::UpdateAccessConfigInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_access_config(access_config_resource: nil, instance: nil, network_interface: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_access_config 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).

    Parameters:

    • access_config_resource (::Google::Cloud::Compute::V1::AccessConfig, ::Hash) (defaults to: nil)

      The body resource for this request

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • network_interface (::String) (defaults to: nil)

      The name of the network interface where the access config is attached.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4457

def update_access_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.update_access_config..to_h

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

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

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

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

  @instances_stub.update_access_config 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_display_device(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #update_display_device(display_device_resource: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::UpdateDisplayDeviceInstanceRequest.new

# Call the update_display_device method.
result = client.update_display_device request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #update_display_device(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_display_device via a request object, either of type UpdateDisplayDeviceInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::UpdateDisplayDeviceInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_display_device(display_device_resource: nil, instance: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_display_device 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).

    Parameters:

    • display_device_resource (::Google::Cloud::Compute::V1::DisplayDevice, ::Hash) (defaults to: nil)

      The body resource for this request

    • instance (::String) (defaults to: nil)

      Name of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4553

def update_display_device request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.update_display_device..to_h

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

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

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

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

  @instances_stub.update_display_device 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_network_interface(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #update_network_interface(instance: nil, network_interface: nil, network_interface_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::UpdateNetworkInterfaceInstanceRequest.new

# Call the update_network_interface method.
result = client.update_network_interface request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #update_network_interface(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_network_interface via a request object, either of type UpdateNetworkInterfaceInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::UpdateNetworkInterfaceInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_network_interface(instance: nil, network_interface: nil, network_interface_resource: nil, project: nil, request_id: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_network_interface 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      The instance name for this request.

    • network_interface (::String) (defaults to: nil)

      The name of the network interface to update.

    • network_interface_resource (::Google::Cloud::Compute::V1::NetworkInterface, ::Hash) (defaults to: nil)

      The body resource for this request

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4651

def update_network_interface request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.update_network_interface..to_h

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

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

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

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

  @instances_stub.update_network_interface 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_shielded_instance_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation #update_shielded_instance_config(instance: nil, project: nil, request_id: nil, shielded_instance_config_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.

Examples:

Basic example

require "google/cloud/compute/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Compute::V1::Instances::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Compute::V1::UpdateShieldedInstanceConfigInstanceRequest.new

# Call the update_shielded_instance_config method.
result = client.update_shielded_instance_config request

# The returned object is of type Google::Cloud::Compute::V1::Operation.
p result

Overloads:

  • #update_shielded_instance_config(request, options = nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_shielded_instance_config via a request object, either of type UpdateShieldedInstanceConfigInstanceRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Compute::V1::UpdateShieldedInstanceConfigInstanceRequest, ::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.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_shielded_instance_config(instance: nil, project: nil, request_id: nil, shielded_instance_config_resource: nil, zone: nil) ⇒ ::Gapic::GenericLRO::Operation

    Pass arguments to update_shielded_instance_config 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).

    Parameters:

    • instance (::String) (defaults to: nil)

      Name or id of the instance scoping this request.

    • project (::String) (defaults to: nil)

      Project ID for this request.

    • request_id (::String) (defaults to: nil)

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

    • shielded_instance_config_resource (::Google::Cloud::Compute::V1::ShieldedInstanceConfig, ::Hash) (defaults to: nil)

      The body resource for this request

    • zone (::String) (defaults to: nil)

      The name of the zone for this request.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

  • result (::Gapic::GenericLRO::Operation)
  • operation (::Gapic::Rest::TransportOperation)

Returns:

  • (::Gapic::GenericLRO::Operation)

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
# File 'lib/google/cloud/compute/v1/instances/rest/client.rb', line 4747

def update_shielded_instance_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

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

  # 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
   = @config.rpcs.update_shielded_instance_config..to_h

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

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

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

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

  @instances_stub.update_shielded_instance_config 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?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end