lib/google/cloud/compute/v1/subnetworks/rest/client.rb in google-cloud-compute-v1-0.2.0 vs lib/google/cloud/compute/v1/subnetworks/rest/client.rb in google-cloud-compute-v1-0.3.0
- old
+ new
@@ -16,10 +16,11 @@
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
require "google/cloud/errors"
require "google/cloud/compute/v1/compute_pb"
+require "google/cloud/compute/v1/subnetworks/rest/service_stub"
module Google
module Cloud
module Compute
module V1
@@ -29,29 +30,26 @@
# REST client for the Subnetworks service.
#
# The Subnetworks API.
#
class Client
- include GrpcTranscoding
-
# @private
attr_reader :subnetworks_stub
##
# Configure the Subnetworks Client class.
#
# See {::Google::Cloud::Compute::V1::Subnetworks::Rest::Client::Configuration}
# for a description of the configuration fields.
#
- # ## Example
+ # @example
#
- # To modify the configuration for all Subnetworks clients:
+ # # Modify the configuration for all Subnetworks clients
+ # ::Google::Cloud::Compute::V1::Subnetworks::Rest::Client.configure do |config|
+ # config.timeout = 10.0
+ # end
#
- # ::Google::Cloud::Compute::V1::Subnetworks::Rest::Client.configure do |config|
- # config.timeout = 10.0
- # end
- #
# @yield [config] Configure the Client client.
# @yieldparam config [Client::Configuration]
#
# @return [Client::Configuration]
#
@@ -64,10 +62,49 @@
break parent_const.configure if parent_const.respond_to? :configure
namespace.pop
end
default_config = Client::Configuration.new parent_config
+ 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.delete.timeout = 600.0
+
+ default_config.rpcs.expand_ip_cidr_range.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_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.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_usable.timeout = 600.0
+ default_config.rpcs.list_usable.retry_policy = {
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
+ }
+
+ default_config.rpcs.patch.timeout = 600.0
+
+ default_config.rpcs.set_iam_policy.timeout = 600.0
+
+ default_config.rpcs.set_private_ip_google_access.timeout = 600.0
+
+ default_config.rpcs.test_iam_permissions.timeout = 600.0
+
default_config
end
yield @configure if block_given?
@configure
end
@@ -93,46 +130,38 @@
end
##
# Create a new Subnetworks REST client object.
#
- # ## Examples
+ # @example
#
- # To create a new Subnetworks REST client with the default
- # configuration:
+ # # Create a client using the default configuration
+ # client = ::Google::Cloud::Compute::V1::Subnetworks::Rest::Client.new
#
- # client = ::Google::Cloud::Compute::V1::Subnetworks::Rest::Client.new
+ # # Create a client using a custom configuration
+ # client = ::Google::Cloud::Compute::V1::Subnetworks::Rest::Client.new do |config|
+ # config.timeout = 10.0
+ # end
#
- # To create a new Subnetworks REST client with a custom
- # configuration:
- #
- # client = ::Google::Cloud::Compute::V1::Subnetworks::Rest::Client.new do |config|
- # config.timeout = 10.0
- # end
- #
# @yield [config] Configure the Subnetworks client.
# @yieldparam config [Client::Configuration]
#
def initialize
- # These require statements are intentionally placed here to initialize
- # the REST modules only when it's required.
- require "gapic/rest"
-
# Create the configuration object
@config = Configuration.new Client.configure
# Yield the configuration if needed
yield @config if block_given?
# Create credentials
credentials = @config.credentials
credentials ||= Credentials.default scope: @config.scope
- if credentials.is_a?(String) || credentials.is_a?(Hash)
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
credentials = Credentials.new credentials, scope: @config.scope
end
- @client_stub = ::Gapic::Rest::ClientStub.new endpoint: @config.endpoint, credentials: credentials
+ @subnetworks_stub = ::Google::Cloud::Compute::V1::Subnetworks::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
end
# Service calls
##
@@ -176,16 +205,16 @@
# @param page_token [::String]
# Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results.
# @param project [::String]
# Project ID for this request.
# @param return_partial_success [::Boolean]
- # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today.
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::SubnetworkAggregatedList]
+ # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false.
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::String, ::Google::Cloud::Compute::V1::SubnetworksScopedList>]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::SubnetworkAggregatedList]
+ # @return [::Gapic::Rest::PagedEnumerable<::String, ::Google::Cloud::Compute::V1::SubnetworksScopedList>]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def aggregated_list request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -193,31 +222,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.aggregated_list.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.aggregated_list.timeout,
metadata: call_metadata
- uri, _body, query_string_params = transcode_aggregated_list request
- response = @client_stub.make_get_request(
- uri: uri,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::SubnetworkAggregatedList.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.aggregated_list request, options do |result, response|
+ result = ::Gapic::Rest::PagedEnumerable.new @subnetworks_stub, :aggregated_list, "items", request, result, options
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -251,15 +278,15 @@
# 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 subnetwork [::String]
# Name of the Subnetwork resource to delete.
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::Operation]
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::BaseOperation]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::Operation]
+ # @return [::Gapic::Rest::BaseOperation]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def delete request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -267,31 +294,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.delete.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.delete.timeout,
metadata: call_metadata
- uri, _body, query_string_params = transcode_delete request
- response = @client_stub.make_delete_request(
- uri: uri,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.delete request, options do |result, response|
+ result = ::Gapic::Rest::BaseOperation.new result
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -327,15 +352,15 @@
# The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
# @param subnetwork [::String]
# Name of the Subnetwork resource to update.
# @param subnetworks_expand_ip_cidr_range_request_resource [::Google::Cloud::Compute::V1::SubnetworksExpandIpCidrRangeRequest, ::Hash]
# The body resource for this request
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::Operation]
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::BaseOperation]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::Operation]
+ # @return [::Gapic::Rest::BaseOperation]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def expand_ip_cidr_range request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -343,32 +368,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.expand_ip_cidr_range.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.expand_ip_cidr_range.timeout,
metadata: call_metadata
- uri, body, query_string_params = transcode_expand_ip_cidr_range request
- response = @client_stub.make_post_request(
- uri: uri,
- body: body,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.expand_ip_cidr_range request, options do |result, response|
+ result = ::Gapic::Rest::BaseOperation.new result
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -396,11 +418,11 @@
# Project ID for this request.
# @param region [::String]
# Name of the region scoping this request.
# @param subnetwork [::String]
# Name of the Subnetwork resource to return.
- # @yield [result, env] Access the result along with the Faraday environment object
+ # @yield [result, response] Access the result along with the Faraday response object
# @yieldparam result [::Google::Cloud::Compute::V1::Subnetwork]
# @yieldparam response [::Faraday::Response]
#
# @return [::Google::Cloud::Compute::V1::Subnetwork]
#
@@ -412,30 +434,28 @@
# 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 = {}
+ call_metadata = @config.rpcs.get.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.get.timeout,
metadata: call_metadata
- uri, _body, _query_string_params = transcode_get request
- response = @client_stub.make_get_request(
- uri: uri,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Subnetwork.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.get request, options do |result, response|
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -465,11 +485,11 @@
# Project ID for this request.
# @param region [::String]
# The name of the region for this request.
# @param resource [::String]
# Name or id of the resource for this request.
- # @yield [result, env] Access the result along with the Faraday environment object
+ # @yield [result, response] Access the result along with the Faraday response object
# @yieldparam result [::Google::Cloud::Compute::V1::Policy]
# @yieldparam response [::Faraday::Response]
#
# @return [::Google::Cloud::Compute::V1::Policy]
#
@@ -481,31 +501,28 @@
# 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 = {}
+ call_metadata = @config.rpcs.get_iam_policy.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout,
metadata: call_metadata
- uri, _body, query_string_params = transcode_get_iam_policy request
- response = @client_stub.make_get_request(
- uri: uri,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Policy.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.get_iam_policy request, options do |result, response|
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -539,15 +556,15 @@
# 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 subnetwork_resource [::Google::Cloud::Compute::V1::Subnetwork, ::Hash]
# The body resource for this request
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::Operation]
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::BaseOperation]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::Operation]
+ # @return [::Gapic::Rest::BaseOperation]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def insert request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -555,32 +572,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.insert.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.insert.timeout,
metadata: call_metadata
- uri, body, query_string_params = transcode_insert request
- response = @client_stub.make_post_request(
- uri: uri,
- body: body,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.insert request, options do |result, response|
+ result = ::Gapic::Rest::BaseOperation.new result
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -625,16 +639,16 @@
# @param project [::String]
# Project ID for this request.
# @param region [::String]
# Name of the region scoping this request.
# @param return_partial_success [::Boolean]
- # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today.
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::SubnetworkList]
+ # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false.
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Subnetwork>]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::SubnetworkList]
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::Subnetwork>]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def list request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -642,31 +656,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.list.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.list.timeout,
metadata: call_metadata
- uri, _body, query_string_params = transcode_list request
- response = @client_stub.make_get_request(
- uri: uri,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::SubnetworkList.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.list request, options do |result, response|
+ result = ::Gapic::Rest::PagedEnumerable.new @subnetworks_stub, :list, "items", request, result, options
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -709,16 +721,16 @@
# @param page_token [::String]
# Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results.
# @param project [::String]
# Project ID for this request.
# @param return_partial_success [::Boolean]
- # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false and the logic is the same as today.
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::UsableSubnetworksAggregatedList]
+ # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false.
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::UsableSubnetwork>]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::UsableSubnetworksAggregatedList]
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::UsableSubnetwork>]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def list_usable request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -726,31 +738,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.list_usable.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.list_usable.timeout,
metadata: call_metadata
- uri, _body, query_string_params = transcode_list_usable request
- response = @client_stub.make_get_request(
- uri: uri,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::UsableSubnetworksAggregatedList.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.list_usable request, options do |result, response|
+ result = ::Gapic::Rest::PagedEnumerable.new @subnetworks_stub, :list_usable, "items", request, result, options
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -788,15 +798,15 @@
# The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
# @param subnetwork [::String]
# Name of the Subnetwork resource to patch.
# @param subnetwork_resource [::Google::Cloud::Compute::V1::Subnetwork, ::Hash]
# The body resource for this request
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::Operation]
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::BaseOperation]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::Operation]
+ # @return [::Gapic::Rest::BaseOperation]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def patch request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -804,32 +814,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.patch.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.patch.timeout,
metadata: call_metadata
- uri, body, query_string_params = transcode_patch request
- response = @client_stub.make_patch_request(
- uri: uri,
- body: body,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.patch request, options do |result, response|
+ result = ::Gapic::Rest::BaseOperation.new result
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -859,11 +866,11 @@
# The name of the region for this request.
# @param region_set_policy_request_resource [::Google::Cloud::Compute::V1::RegionSetPolicyRequest, ::Hash]
# The body resource for this request
# @param resource [::String]
# Name or id of the resource for this request.
- # @yield [result, env] Access the result along with the Faraday environment object
+ # @yield [result, response] Access the result along with the Faraday response object
# @yieldparam result [::Google::Cloud::Compute::V1::Policy]
# @yieldparam response [::Faraday::Response]
#
# @return [::Google::Cloud::Compute::V1::Policy]
#
@@ -875,31 +882,28 @@
# 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 = {}
+ call_metadata = @config.rpcs.set_iam_policy.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout,
metadata: call_metadata
- uri, body, _query_string_params = transcode_set_iam_policy request
- response = @client_stub.make_post_request(
- uri: uri,
- body: body,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Policy.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.set_iam_policy request, options do |result, response|
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -935,15 +939,15 @@
# The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
# @param subnetwork [::String]
# Name of the Subnetwork resource.
# @param subnetworks_set_private_ip_google_access_request_resource [::Google::Cloud::Compute::V1::SubnetworksSetPrivateIpGoogleAccessRequest, ::Hash]
# The body resource for this request
- # @yield [result, env] Access the result along with the Faraday environment object
- # @yieldparam result [::Google::Cloud::Compute::V1::Operation]
+ # @yield [result, response] Access the result along with the Faraday response object
+ # @yieldparam result [::Gapic::Rest::BaseOperation]
# @yieldparam response [::Faraday::Response]
#
- # @return [::Google::Cloud::Compute::V1::Operation]
+ # @return [::Gapic::Rest::BaseOperation]
#
# @raise [::Google::Cloud::Error] if the REST call is aborted.
def set_private_ip_google_access request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?
@@ -951,32 +955,29 @@
# 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 = {}
+ call_metadata = @config.rpcs.set_private_ip_google_access.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.set_private_ip_google_access.timeout,
metadata: call_metadata
- uri, body, query_string_params = transcode_set_private_ip_google_access request
- response = @client_stub.make_post_request(
- uri: uri,
- body: body,
- params: query_string_params,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.set_private_ip_google_access request, options do |result, response|
+ result = ::Gapic::Rest::BaseOperation.new result
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -1006,11 +1007,11 @@
# The name of the region for this request.
# @param resource [::String]
# Name or id of the resource for this request.
# @param test_permissions_request_resource [::Google::Cloud::Compute::V1::TestPermissionsRequest, ::Hash]
# The body resource for this request
- # @yield [result, env] Access the result along with the Faraday environment object
+ # @yield [result, response] Access the result along with the Faraday response object
# @yieldparam result [::Google::Cloud::Compute::V1::TestPermissionsResponse]
# @yieldparam response [::Faraday::Response]
#
# @return [::Google::Cloud::Compute::V1::TestPermissionsResponse]
#
@@ -1022,31 +1023,28 @@
# 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 = {}
+ call_metadata = @config.rpcs.test_iam_permissions.metadata.to_h
# Set x-goog-api-client header
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]
- options.apply_defaults timeout: @config.timeout,
+ options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout,
metadata: call_metadata
- uri, body, _query_string_params = transcode_test_iam_permissions request
- response = @client_stub.make_post_request(
- uri: uri,
- body: body,
- options: options
- )
- result = ::Google::Cloud::Compute::V1::TestPermissionsResponse.decode_json response.body, ignore_unknown_fields: true
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata
- yield result, response if block_given?
- result
+ @subnetworks_stub.test_iam_permissions request, options do |result, response|
+ yield result, response if block_given?
+ return result
+ end
rescue ::Faraday::Error => e
gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e
raise ::Google::Cloud::Error.from_error(gapic_error)
end
@@ -1097,10 +1095,13 @@
# The library version as recorded in instrumentation and logging
# @return [::String]
# @!attribute [rw] timeout
# The call timeout in seconds.
# @return [::Numeric]
+ # @!attribute [rw] metadata
+ # Additional REST headers to be sent with the call.
+ # @return [::Hash{::Symbol=>::String}]
#
class Configuration
extend ::Gapic::Config
config_attr :endpoint, "compute.googleapis.com", ::String
@@ -1110,15 +1111,133 @@
end
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
# @private
def initialize parent_config = nil
@parent_config = parent_config unless parent_config.nil?
yield self if block_given?
+ end
+
+ ##
+ # Configurations for individual RPCs
+ # @return [Rpcs]
+ #
+ def rpcs
+ @rpcs ||= begin
+ parent_rpcs = nil
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
+ Rpcs.new parent_rpcs
+ end
+ end
+
+ ##
+ # Configuration RPC class for the Subnetworks API.
+ #
+ # 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.
+ #
+ class Rpcs
+ ##
+ # RPC-specific configuration for `aggregated_list`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :aggregated_list
+ ##
+ # RPC-specific configuration for `delete`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :delete
+ ##
+ # RPC-specific configuration for `expand_ip_cidr_range`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :expand_ip_cidr_range
+ ##
+ # RPC-specific configuration for `get`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :get
+ ##
+ # RPC-specific configuration for `get_iam_policy`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :get_iam_policy
+ ##
+ # RPC-specific configuration for `insert`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :insert
+ ##
+ # RPC-specific configuration for `list`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :list
+ ##
+ # RPC-specific configuration for `list_usable`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :list_usable
+ ##
+ # RPC-specific configuration for `patch`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :patch
+ ##
+ # RPC-specific configuration for `set_iam_policy`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :set_iam_policy
+ ##
+ # RPC-specific configuration for `set_private_ip_google_access`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :set_private_ip_google_access
+ ##
+ # RPC-specific configuration for `test_iam_permissions`
+ # @return [::Gapic::Config::Method]
+ #
+ attr_reader :test_iam_permissions
+
+ # @private
+ def initialize parent_rpcs = nil
+ aggregated_list_config = parent_rpcs.aggregated_list if parent_rpcs.respond_to? :aggregated_list
+ @aggregated_list = ::Gapic::Config::Method.new aggregated_list_config
+ delete_config = parent_rpcs.delete if parent_rpcs.respond_to? :delete
+ @delete = ::Gapic::Config::Method.new delete_config
+ expand_ip_cidr_range_config = parent_rpcs.expand_ip_cidr_range if parent_rpcs.respond_to? :expand_ip_cidr_range
+ @expand_ip_cidr_range = ::Gapic::Config::Method.new expand_ip_cidr_range_config
+ get_config = parent_rpcs.get if parent_rpcs.respond_to? :get
+ @get = ::Gapic::Config::Method.new get_config
+ get_iam_policy_config = parent_rpcs.get_iam_policy if parent_rpcs.respond_to? :get_iam_policy
+ @get_iam_policy = ::Gapic::Config::Method.new get_iam_policy_config
+ insert_config = parent_rpcs.insert if parent_rpcs.respond_to? :insert
+ @insert = ::Gapic::Config::Method.new insert_config
+ list_config = parent_rpcs.list if parent_rpcs.respond_to? :list
+ @list = ::Gapic::Config::Method.new list_config
+ list_usable_config = parent_rpcs.list_usable if parent_rpcs.respond_to? :list_usable
+ @list_usable = ::Gapic::Config::Method.new list_usable_config
+ patch_config = parent_rpcs.patch if parent_rpcs.respond_to? :patch
+ @patch = ::Gapic::Config::Method.new patch_config
+ set_iam_policy_config = parent_rpcs.set_iam_policy if parent_rpcs.respond_to? :set_iam_policy
+ @set_iam_policy = ::Gapic::Config::Method.new set_iam_policy_config
+ set_private_ip_google_access_config = parent_rpcs.set_private_ip_google_access if parent_rpcs.respond_to? :set_private_ip_google_access
+ @set_private_ip_google_access = ::Gapic::Config::Method.new set_private_ip_google_access_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
+
+ yield self if block_given?
+ end
end
end
end
end
end