lib/google/cloud/compute/v1/region_disks/rest/client.rb in google-cloud-compute-v1-1.8.0 vs lib/google/cloud/compute/v1/region_disks/rest/client.rb in google-cloud-compute-v1-1.9.0
- old
+ new
@@ -147,17 +147,26 @@
# Yield the configuration if needed
yield @config if block_given?
# Create credentials
credentials = @config.credentials
- credentials ||= Credentials.default scope: @config.scope
+ # 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 == Client.configure.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
+
@region_operations = ::Google::Cloud::Compute::V1::RegionOperations::Rest::Client.new do |config|
config.credentials = credentials
+ config.quota_project = @quota_project_id
config.endpoint = @config.endpoint
end
@region_disks_stub = ::Google::Cloud::Compute::V1::RegionDisks::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
end
@@ -181,12 +190,10 @@
# @param request [::Google::Cloud::Compute::V1::AddResourcePoliciesRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload add_resource_policies(disk: nil, project: nil, region: nil, region_disks_add_resource_policies_request_resource: nil, request_id: nil)
# 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).
@@ -217,21 +224,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.add_resource_policies.metadata.to_h
- # Set x-goog-api-client header
+ # 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.add_resource_policies.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.add_resource_policies.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.add_resource_policies request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -242,16 +253,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.
#
@@ -262,12 +269,10 @@
# @param request [::Google::Cloud::Compute::V1::CreateSnapshotRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload create_snapshot(disk: nil, project: nil, region: nil, request_id: nil, snapshot_resource: nil)
# Pass arguments to `create_snapshot` 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).
@@ -298,21 +303,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.create_snapshot.metadata.to_h
- # Set x-goog-api-client header
+ # 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.create_snapshot.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.create_snapshot.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.create_snapshot request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -323,16 +332,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots.
#
@@ -343,12 +348,10 @@
# @param request [::Google::Cloud::Compute::V1::DeleteRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload delete(disk: nil, project: nil, region: nil, request_id: nil)
# 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).
@@ -377,21 +380,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.delete.metadata.to_h
- # Set x-goog-api-client header
+ # 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.delete.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.delete.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.delete request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -402,16 +409,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Returns a specified regional persistent disk.
#
@@ -422,12 +425,10 @@
# @param request [::Google::Cloud::Compute::V1::GetRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload get(disk: nil, project: nil, region: nil)
# 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).
@@ -454,32 +455,32 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.get.metadata.to_h
- # Set x-goog-api-client header
+ # 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.get.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.get.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.get request, options do |result, response|
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Gets the access control policy for a resource. May be empty if no such policy or resource exists.
#
@@ -490,12 +491,10 @@
# @param request [::Google::Cloud::Compute::V1::GetIamPolicyRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload get_iam_policy(options_requested_policy_version: nil, project: nil, region: nil, resource: nil)
# 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).
@@ -524,32 +523,32 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.get_iam_policy.metadata.to_h
- # Set x-goog-api-client header
+ # 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.get_iam_policy.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.get_iam_policy.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.get_iam_policy request, options do |result, response|
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Creates a persistent regional disk in the specified project using the data included in the request.
#
@@ -560,12 +559,10 @@
# @param request [::Google::Cloud::Compute::V1::InsertRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload insert(disk_resource: nil, project: nil, region: nil, request_id: nil, source_image: nil)
# 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).
@@ -596,21 +593,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.insert.metadata.to_h
- # Set x-goog-api-client header
+ # 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.insert.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.insert.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.insert request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -621,16 +622,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Retrieves the list of persistent disks contained within the specified region.
#
@@ -641,12 +638,10 @@
# @param request [::Google::Cloud::Compute::V1::ListRegionDisksRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload list(filter: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, region: nil, return_partial_success: nil)
# 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).
@@ -681,33 +676,33 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.list.metadata.to_h
- # Set x-goog-api-client header
+ # 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.list.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.list.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.list request, options do |result, response|
result = ::Gapic::Rest::PagedEnumerable.new @region_disks_stub, :list, "items", request, result, options
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Removes resource policies from a regional disk.
#
@@ -718,12 +713,10 @@
# @param request [::Google::Cloud::Compute::V1::RemoveResourcePoliciesRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload remove_resource_policies(disk: nil, project: nil, region: nil, region_disks_remove_resource_policies_request_resource: nil, request_id: nil)
# 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).
@@ -754,21 +747,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.remove_resource_policies.metadata.to_h
- # Set x-goog-api-client header
+ # 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.remove_resource_policies.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.remove_resource_policies.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.remove_resource_policies request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -779,16 +776,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Resizes the specified regional persistent disk.
#
@@ -799,12 +792,10 @@
# @param request [::Google::Cloud::Compute::V1::ResizeRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload resize(disk: nil, project: nil, region: nil, region_disks_resize_request_resource: nil, request_id: nil)
# Pass arguments to `resize` 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).
@@ -835,21 +826,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.resize.metadata.to_h
- # Set x-goog-api-client header
+ # 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.resize.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.resize.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.resize request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -860,16 +855,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Sets the access control policy on the specified resource. Replaces any existing policy.
#
@@ -880,12 +871,10 @@
# @param request [::Google::Cloud::Compute::V1::SetIamPolicyRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload set_iam_policy(project: nil, region: nil, region_set_policy_request_resource: nil, resource: nil)
# 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).
@@ -914,32 +903,32 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.set_iam_policy.metadata.to_h
- # Set x-goog-api-client header
+ # 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.set_iam_policy.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.set_iam_policy.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.set_iam_policy request, options do |result, response|
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Sets the labels on the target regional disk.
#
@@ -950,12 +939,10 @@
# @param request [::Google::Cloud::Compute::V1::SetLabelsRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload set_labels(project: nil, region: nil, region_set_labels_request_resource: nil, request_id: nil, resource: nil)
# 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).
@@ -986,21 +973,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.set_labels.metadata.to_h
- # Set x-goog-api-client header
+ # 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.set_labels.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.set_labels.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.set_labels request, options do |result, response|
result = ::Google::Cloud::Compute::V1::RegionOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: region_operations,
@@ -1011,16 +1002,12 @@
options: options
)
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Returns permissions that a caller has on the specified resource.
#
@@ -1031,12 +1018,10 @@
# @param request [::Google::Cloud::Compute::V1::TestIamPermissionsRegionDiskRequest, ::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.
- # Note: currently retry functionality is not implemented. While it is possible
- # to set it using ::Gapic::CallOptions, it will not be applied
#
# @overload test_iam_permissions(project: nil, region: nil, resource: nil, test_permissions_request_resource: nil)
# 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).
@@ -1065,57 +1050,63 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.test_iam_permissions.metadata.to_h
- # Set x-goog-api-client header
+ # 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.test_iam_permissions.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.test_iam_permissions.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@region_disks_stub.test_iam_permissions request, options do |result, response|
yield result, response if block_given?
return result
end
- rescue ::Faraday::Error => e
- begin
- raise ::Gapic::Rest::Error.wrap_faraday_error e
- rescue ::Gapic::Rest::Error => gapic_error
- raise ::Google::Cloud::Error.from_error gapic_error
- end
+ rescue ::Gapic::Rest::Error => e
+ raise ::Google::Cloud::Error.from_error(e)
end
##
# Configuration class for the RegionDisks REST API.
#
# This class represents the configuration for RegionDisks REST,
- # providing control over credentials, timeouts, retry behavior, logging.
+ # providing control over timeouts, retry behavior, logging, transport
+ # parameters, and other low-level controls. Certain parameters can also be
+ # applied individually to specific RPCs. See
+ # {::Google::Cloud::Compute::V1::RegionDisks::Rest::Client::Configuration::Rpcs}
+ # for a list of RPCs that can be configured independently.
#
# Configuration can be applied globally to all clients, or to a single client
# on construction.
#
- # # Examples
+ # @example
#
- # To modify the global config, setting the timeout for all calls to 10 seconds:
+ # # Modify the global config, setting the timeout for
+ # # add_resource_policies to 20 seconds,
+ # # and all remaining timeouts to 10 seconds.
+ # ::Google::Cloud::Compute::V1::RegionDisks::Rest::Client.configure do |config|
+ # config.timeout = 10.0
+ # config.rpcs.add_resource_policies.timeout = 20.0
+ # end
#
- # ::Google::Cloud::Compute::V1::RegionDisks::Client.configure do |config|
- # config.timeout = 10.0
- # end
+ # # Apply the above configuration only to a new client.
+ # client = ::Google::Cloud::Compute::V1::RegionDisks::Rest::Client.new do |config|
+ # config.timeout = 10.0
+ # config.rpcs.add_resource_policies.timeout = 20.0
+ # end
#
- # To apply the above configuration only to a new client:
- #
- # client = ::Google::Cloud::Compute::V1::RegionDisks::Client.new do |config|
- # config.timeout = 10.0
- # end
- #
# @!attribute [rw] endpoint
# The hostname or hostname:port of the service endpoint.
# Defaults to `"compute.googleapis.com"`.
# @return [::String]
# @!attribute [rw] credentials
@@ -1139,12 +1130,23 @@
# @return [::String]
# @!attribute [rw] timeout
# The call timeout in seconds.
# @return [::Numeric]
# @!attribute [rw] metadata
- # Additional REST headers to be sent with the call.
+ # Additional headers to be sent with the call.
# @return [::Hash{::Symbol=>::String}]
+ # @!attribute [rw] retry_policy
+ # The retry policy. The value is a hash with the following keys:
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
+ # trigger a retry.
+ # @return [::Hash]
+ # @!attribute [rw] quota_project
+ # A separate project against which to charge quota.
+ # @return [::String]
#
class Configuration
extend ::Gapic::Config
config_attr :endpoint, "compute.googleapis.com", ::String
@@ -1155,10 +1157,12 @@
config_attr :scope, nil, ::String, ::Array, nil
config_attr :lib_name, nil, ::String, nil
config_attr :lib_version, nil, ::String, nil
config_attr :timeout, nil, ::Numeric, nil
config_attr :metadata, nil, ::Hash, nil
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
+ config_attr :quota_project, nil, ::String, nil
# @private
def initialize parent_config = nil
@parent_config = parent_config unless parent_config.nil?
@@ -1183,12 +1187,17 @@
# Includes fields providing the configuration for each RPC in this service.
# Each configuration object is of type `Gapic::Config::Method` and includes
# the following configuration fields:
#
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
- #
- # there is one other field (`retry_policy`) that can be set
- # but is currently not supported for REST Gapic libraries.
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
+ # include the following keys:
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
+ # trigger a retry.
#
class Rpcs
##
# RPC-specific configuration for `add_resource_policies`
# @return [::Gapic::Config::Method]