lib/google/cloud/compute/v1/disks/rest/client.rb in google-cloud-compute-v1-2.0.0 vs lib/google/cloud/compute/v1/disks/rest/client.rb in google-cloud-compute-v1-2.1.0

- old
+ new

@@ -101,10 +101,12 @@ default_config.rpcs.set_labels.timeout = 600.0 default_config.rpcs.test_iam_permissions.timeout = 600.0 + default_config.rpcs.update.timeout = 600.0 + default_config end yield @configure if block_given? @configure end @@ -496,11 +498,11 @@ rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## - # Returns a specified persistent disk. Gets a list of available persistent disks by making a list() request. + # Returns the specified persistent disk. # # @overload get(request, options = nil) # Pass arguments to `get` via a request object, either of type # {::Google::Cloud::Compute::V1::GetDiskRequest} or an equivalent Hash. # @@ -1157,10 +1159,92 @@ rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## + # Updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license. + # + # @overload update(request, options = nil) + # Pass arguments to `update` via a request object, either of type + # {::Google::Cloud::Compute::V1::UpdateDiskRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::Compute::V1::UpdateDiskRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload update(disk: nil, disk_resource: nil, paths: nil, project: nil, request_id: nil, update_mask: nil, zone: nil) + # 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). + # + # @param disk [::String] + # The disk name for this request. + # @param disk_resource [::Google::Cloud::Compute::V1::Disk, ::Hash] + # The body resource for this request + # @param paths [::String] + # @param project [::String] + # Project ID for this request. + # @param request_id [::String] + # An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000). + # @param update_mask [::String] + # update_mask indicates fields to be updated as part of this request. + # @param zone [::String] + # The name of the zone for this request. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::GenericLRO::Operation] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::GenericLRO::Operation] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + def update request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::UpdateDiskRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.update.metadata.to_h + + # Set x-goog-api-client and x-goog-user-project headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Cloud::Compute::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.update.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @disks_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 + + ## # Configuration class for the Disks REST API. # # This class represents the configuration for Disks REST, # providing control over timeouts, retry behavior, logging, transport # parameters, and other low-level controls. Certain parameters can also be @@ -1194,13 +1278,13 @@ # @!attribute [rw] credentials # Credentials to send with calls. You may provide any of the following types: # * (`String`) The path to a service account key file in JSON format # * (`Hash`) A service account key as a Hash # * (`Google::Auth::Credentials`) A googleauth credentials object - # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html)) + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) # * (`Signet::OAuth2::Client`) A signet oauth2 client object - # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html)) + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) # * (`nil`) indicating no credentials # @return [::Object] # @!attribute [rw] scope # The OAuth scopes # @return [::Array<::String>] @@ -1344,10 +1428,15 @@ ## # RPC-specific configuration for `test_iam_permissions` # @return [::Gapic::Config::Method] # attr_reader :test_iam_permissions + ## + # RPC-specific configuration for `update` + # @return [::Gapic::Config::Method] + # + attr_reader :update # @private def initialize parent_rpcs = nil add_resource_policies_config = parent_rpcs.add_resource_policies if parent_rpcs.respond_to? :add_resource_policies @add_resource_policies = ::Gapic::Config::Method.new add_resource_policies_config @@ -1373,9 +1462,11 @@ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config set_labels_config = parent_rpcs.set_labels if parent_rpcs.respond_to? :set_labels @set_labels = ::Gapic::Config::Method.new set_labels_config test_iam_permissions_config = parent_rpcs.test_iam_permissions if parent_rpcs.respond_to? :test_iam_permissions @test_iam_permissions = ::Gapic::Config::Method.new test_iam_permissions_config + update_config = parent_rpcs.update if parent_rpcs.respond_to? :update + @update = ::Gapic::Config::Method.new update_config yield self if block_given? end end end