lib/google/cloud/compute/v1/backend_services/rest/client.rb in google-cloud-compute-v1-1.8.0 vs lib/google/cloud/compute/v1/backend_services/rest/client.rb in google-cloud-compute-v1-1.9.0
- old
+ new
@@ -154,17 +154,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
+
@global_operations = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::Client.new do |config|
config.credentials = credentials
+ config.quota_project = @quota_project_id
config.endpoint = @config.endpoint
end
@backend_services_stub = ::Google::Cloud::Compute::V1::BackendServices::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
end
@@ -188,12 +197,10 @@
# @param request [::Google::Cloud::Compute::V1::AddSignedUrlKeyBackendServiceRequest, ::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_signed_url_key(backend_service: nil, project: nil, request_id: nil, signed_url_key_resource: nil)
# Pass arguments to `add_signed_url_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).
@@ -222,21 +229,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.add_signed_url_key.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_signed_url_key.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.add_signed_url_key.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.add_signed_url_key request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -246,16 +257,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 all BackendService resources, regional and global, available to the specified project.
#
@@ -266,12 +273,10 @@
# @param request [::Google::Cloud::Compute::V1::AggregatedListBackendServicesRequest, ::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 aggregated_list(filter: nil, include_all_scopes: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil)
# 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).
@@ -306,33 +311,33 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.aggregated_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.aggregated_list.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.aggregated_list.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.aggregated_list request, options do |result, response|
result = ::Gapic::Rest::PagedEnumerable.new @backend_services_stub, :aggregated_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
##
# Deletes the specified BackendService resource.
#
@@ -343,12 +348,10 @@
# @param request [::Google::Cloud::Compute::V1::DeleteBackendServiceRequest, ::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(backend_service: nil, project: 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).
@@ -375,21 +378,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
@backend_services_stub.delete request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -399,16 +406,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 a key for validating requests with signed URLs for this backend service.
#
@@ -419,12 +422,10 @@
# @param request [::Google::Cloud::Compute::V1::DeleteSignedUrlKeyBackendServiceRequest, ::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_signed_url_key(backend_service: nil, key_name: nil, project: nil, request_id: nil)
# Pass arguments to `delete_signed_url_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).
@@ -453,21 +454,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.delete_signed_url_key.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_signed_url_key.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.delete_signed_url_key.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.delete_signed_url_key request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -477,16 +482,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 the specified BackendService resource. Gets a list of available backend services.
#
@@ -497,12 +498,10 @@
# @param request [::Google::Cloud::Compute::V1::GetBackendServiceRequest, ::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(backend_service: nil, project: 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).
@@ -527,32 +526,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
@backend_services_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 most recent health check results for this BackendService. Example request body: { "group": "/zones/us-east1-b/instanceGroups/lb-backend-example" }
#
@@ -563,12 +562,10 @@
# @param request [::Google::Cloud::Compute::V1::GetHealthBackendServiceRequest, ::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_health(backend_service: nil, project: nil, resource_group_reference_resource: nil)
# Pass arguments to `get_health` 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).
@@ -594,32 +591,32 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.get_health.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_health.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.get_health.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.get_health 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.
#
@@ -630,12 +627,10 @@
# @param request [::Google::Cloud::Compute::V1::GetIamPolicyBackendServiceRequest, ::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, 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).
@@ -662,32 +657,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
@backend_services_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 BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview .
#
@@ -698,12 +693,10 @@
# @param request [::Google::Cloud::Compute::V1::InsertBackendServiceRequest, ::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(backend_service_resource: nil, project: nil, request_id: 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).
@@ -730,21 +723,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
@backend_services_stub.insert request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -754,16 +751,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 BackendService resources available to the specified project.
#
@@ -774,12 +767,10 @@
# @param request [::Google::Cloud::Compute::V1::ListBackendServicesRequest, ::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, 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).
@@ -812,33 +803,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
@backend_services_stub.list request, options do |result, response|
result = ::Gapic::Rest::PagedEnumerable.new @backend_services_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
##
# Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
#
@@ -849,12 +840,10 @@
# @param request [::Google::Cloud::Compute::V1::PatchBackendServiceRequest, ::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 patch(backend_service: nil, backend_service_resource: nil, project: nil, request_id: nil)
# Pass arguments to `patch` 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).
@@ -883,21 +872,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.patch.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.patch.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.patch.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.patch request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -907,16 +900,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 edge security policy for the specified backend service.
#
@@ -927,12 +916,10 @@
# @param request [::Google::Cloud::Compute::V1::SetEdgeSecurityPolicyBackendServiceRequest, ::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_edge_security_policy(backend_service: nil, project: nil, request_id: nil, security_policy_reference_resource: nil)
# Pass arguments to `set_edge_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).
@@ -961,21 +948,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.set_edge_security_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_edge_security_policy.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.set_edge_security_policy.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.set_edge_security_policy request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -985,16 +976,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.
#
@@ -1005,12 +992,10 @@
# @param request [::Google::Cloud::Compute::V1::SetIamPolicyBackendServiceRequest, ::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(global_set_policy_request_resource: nil, project: 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).
@@ -1037,32 +1022,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
@backend_services_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 Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview
#
@@ -1073,12 +1058,10 @@
# @param request [::Google::Cloud::Compute::V1::SetSecurityPolicyBackendServiceRequest, ::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_security_policy(backend_service: nil, project: nil, request_id: nil, security_policy_reference_resource: nil)
# 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).
@@ -1107,21 +1090,25 @@
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
# Customize the options with defaults
call_metadata = @config.rpcs.set_security_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_security_policy.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.set_security_policy.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.set_security_policy request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -1131,16 +1118,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
##
# Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview.
#
@@ -1151,12 +1134,10 @@
# @param request [::Google::Cloud::Compute::V1::UpdateBackendServiceRequest, ::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 update(backend_service: nil, backend_service_resource: nil, project: nil, request_id: 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).
@@ -1185,21 +1166,25 @@
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 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.update.timeout,
- metadata: call_metadata
+ metadata: call_metadata,
+ retry_policy: @config.rpcs.update.retry_policy
options.apply_defaults timeout: @config.timeout,
- metadata: @config.metadata
+ metadata: @config.metadata,
+ retry_policy: @config.retry_policy
@backend_services_stub.update request, options do |result, response|
result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation(
operation: result,
client: global_operations,
@@ -1209,41 +1194,43 @@
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
##
# Configuration class for the BackendServices REST API.
#
# This class represents the configuration for BackendServices 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::BackendServices::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_signed_url_key to 20 seconds,
+ # # and all remaining timeouts to 10 seconds.
+ # ::Google::Cloud::Compute::V1::BackendServices::Rest::Client.configure do |config|
+ # config.timeout = 10.0
+ # config.rpcs.add_signed_url_key.timeout = 20.0
+ # end
#
- # ::Google::Cloud::Compute::V1::BackendServices::Client.configure do |config|
- # config.timeout = 10.0
- # end
+ # # Apply the above configuration only to a new client.
+ # client = ::Google::Cloud::Compute::V1::BackendServices::Rest::Client.new do |config|
+ # config.timeout = 10.0
+ # config.rpcs.add_signed_url_key.timeout = 20.0
+ # end
#
- # To apply the above configuration only to a new client:
- #
- # client = ::Google::Cloud::Compute::V1::BackendServices::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
@@ -1267,12 +1254,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
@@ -1283,10 +1281,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?
@@ -1311,12 +1311,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_signed_url_key`
# @return [::Gapic::Config::Method]